features/safe_stubbing/safe_stubbing.feature in bogus-0.1.0 vs features/safe_stubbing/safe_stubbing.feature in bogus-0.1.1
- old
+ new
@@ -5,23 +5,24 @@
The stubbing syntax is:
stub(object).method_name(arg1, arg2, ...) { return_value }
Background:
- Given a file named "foo.rb" with:
+ Given a file named "library.rb" with:
"""ruby
class Library
def checkout(book)
end
end
"""
Scenario: Stubbing 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
stub(library).checkout("some book") { :checked_out }
library.checkout("some book").should == :checked_out
@@ -30,10 +31,12 @@
"""
Scenario: Stubbing 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
stub(library).buy("some book") { :bought }
end
@@ -41,10 +44,12 @@
"""
Scenario: Stubbing 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
stub(library).checkout("some book", "another book") { :bought }
end
@@ -52,10 +57,12 @@
"""
Scenario: Stubs allow the methods to be called
Then spec file with following content should pass:
"""ruby
+ require_relative 'library'
+
describe Library do
it "does something" do
library = Library.new
stub(library).checkout("some book") { :bought }
end
@@ -63,9 +70,11 @@
"""
Scenario: Stubbing methods multiple times
Then spec file with following content should fail:
"""ruby
+ require_relative 'library'
+
describe Library do
it "stubbing with too many arguments" do
library = Library.new
stub(library).checkout("some book") { :bought }