Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/extended_should_receive_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_accepts_list_of_methods

def test_contraints_apply_to_all_expectations
@mock.should_receive(:foo, :bar => :baz).with(1)
ex = assert_raises(check_failed_error) { @obj.foo(2) }
ex = assert_raises(check_failed_error) { @obj.bar(2) }
assert_raises(check_failed_error) { @obj.foo(2) }
assert_raises(check_failed_error) { @obj.bar(2) }
assert_equal :baz, @obj.bar(1)
end

Expand Down
11 changes: 7 additions & 4 deletions test/new_instances_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def self.make

class Cat
attr_reader :name
def initialize(name, &block)
attr_reader :kw
def initialize(name, **kw, &block)
@name = name
@kw = kw
block.call(self) if block_given?
end
end
Expand Down Expand Up @@ -94,24 +96,25 @@ def test_new_instances_will_pass_args_to_new
obj.should_receive(:meow).and_return(:scratch)
end
x = :not_called
m = Cat.new("Fido") { x = :called }
m = Cat.new("Fido", a: 42) { x = :called }
assert_equal :scratch, m.meow
assert_equal "Fido", m.name
assert_equal :called, x
assert_equal({ a: 42 }, m.kw)
end

# Some versions of the software had problems invoking the block after a
# second stubbing.
def test_new_gets_block_after_restubbing
flexstub(Cat).new_instances { }
x = :not_called
m = Cat.new("Fido") { x = :called }
Cat.new("Fido") { x = :called }
assert_equal :called, x
flexmock_teardown

flexstub(Cat).new_instances { }
x = :not_called
m = Cat.new("Fido") { x = :called }
Cat.new("Fido") { x = :called }
assert_equal :called, x
end

Expand Down
2 changes: 1 addition & 1 deletion test/partial_mock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def test_partial_mocks_leaves_NoMethodError_exceptions_raised_by_the_original_me
exception = assert_raises(NameError) do
obj.mocked_method
end
assert_match /undefined method `does_not_exist' for/, exception.message
assert_match(/undefined method `does_not_exist' for/, exception.message)
end

def test_it_checks_whether_mocks_are_forbidden_before_forwarding_the_call
Expand Down