Skip to content
Open
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
3 changes: 2 additions & 1 deletion test/based_partials_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def test_based_partials_allow_stubbing_defined_methods

def test_based_partials_disallow_stubbing_undefined_methods
dog = Dog.new
assert_raises(NoMethodError, /cannot stub.*wag.*explicitly/) do
ex = assert_raises(NoMethodError) do
flexmock(dog).should_receive(:wag => :mock_value)
end
assert_match(/Cannot stub.*wag.*explicitly/m, ex.message)
end

def test_based_partials_allow_explicitly_stubbing_undefined_methods
Expand Down
9 changes: 6 additions & 3 deletions test/partial_mock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,10 @@ def test_partial_mocks_allow_stubbing_defined_methods_when_using_on
def test_partial_mocks_disallow_stubbing_undefined_methods_when_using_on
dog = Dog.new
flexmock(dog, :on, Dog)
assert_raises(NoMethodError, /meow.*explicitly/) do
ex = assert_raises(NoMethodError) do
dog.should_receive(:meow).and_return(:something)
end
assert_match(/meow.*explicitly/m, ex.message)
end

def test_partial_mocks_properly_detect_methods_defined_through_a_class_hierarchy
Expand Down Expand Up @@ -497,9 +498,10 @@ def test_partial_mocks_will_not_require_explicitly_on_a_class_singleton_method_t
def test_based_partial_mocks_require_explicitly_on_a_non_existing_method_of_a_class_singleton
dog = Class.new
FlexMock.partials_are_based = true
assert_raises(NoMethodError, /bark.*explicitly/) do
ex = assert_raises(NoMethodError) do
flexmock(dog).should_receive(:bark).and_return(:grrr)
end
assert_match(/bark.*explicitly/m, ex.message)
ensure
FlexMock.partials_are_based = false
end
Expand All @@ -511,9 +513,10 @@ def test_partial_mocks_require_explicitly_on_a_class_singleton_method_that_has_b
FlexMock.partials_are_based = true
flexmock(dog).should_receive(:bark).explicitly
flexmock(chiwawa)
assert_raises(NoMethodError, /bark.*explicitly/) do
ex = assert_raises(NoMethodError) do
chiwawa.should_receive(:bark).and_return(:grrr)
end
assert_match(/bark.*explicitly/m, ex.message)
ensure
FlexMock.partials_are_based = false
end
Expand Down