features/safe_stubbing/safe_mocking.feature in bogus-0.1.0 vs features/safe_stubbing/safe_mocking.feature in bogus-0.1.1

- old
+ new

@@ -13,23 +13,24 @@ mock(object).method_name(*args) { return_value } You can only mock methods that actually exist on an object. It will also work with methods that the object `responds_to?`, but (obviously) without being able to check the method signature. Background: - Given a file named "foo.rb" with: + Given a file named "library.rb" with: """ruby class Library def checkout(book) end end """ Scenario: Mocking methods that exist on real object Then spec file with following content should pass: """ruby - describe Library do + require_relative 'library' + describe Library do it "does something" do library = Library.new mock(library).checkout("some book") { :checked_out } library.checkout("some book").should == :checked_out @@ -38,10 +39,12 @@ """ Scenario: Mocking methods that do not exist on real object Then spec file with following content should fail: """ruby + require_relative 'library' + describe Library do it "does something" do library = Library.new mock(library).buy("some book") { :bought } library.buy("some book") @@ -50,10 +53,12 @@ """ Scenario: Mocking methods with wrong number of arguments Then spec file with following content should fail: """ruby + require_relative 'library' + describe Library do it "does something" do library = Library.new mock(library).checkout("some book", "another book") { :bought } library.checkout("some book", "another book") @@ -62,9 +67,11 @@ """ Scenario: Mocks require the methods to be called Then spec file with following content should fail: """ruby + require_relative 'library' + describe Library do it "does something" do library = Library.new mock(library).checkout("some book") { :bought } end