This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Movie | |
| attr_accessor :title | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MovieShelf | |
| attr_accessor :movies | |
| def initialize | |
| @movies = [] | |
| end | |
| def lookup(movie) | |
| @movies.detect {|m| m == movie} | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> shelf = MovieShelf.new | |
| => #<MovieShelf:0x36eb88 @movies=[]> | |
| >> m = Movie.new | |
| => #<Movie:0x33b328> | |
| >> m.title = "Juno" | |
| => "Juno" | |
| >> m2 = Movie.new | |
| => #<Movie:0x39968> | |
| >> m2.title = "Transformers" | |
| => "Transformers" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context "a movie shelf" do | |
| setup { @shelf = MovieShelf.new } | |
| should "let the user store a movie" do | |
| juno = Movie.new("Juno") | |
| shelf.store juno | |
| assert shelf.contains?(juno) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Movie | |
| attr_accessor :title | |
| def initialize(title) | |
| self.title = title | |
| end | |
| end | |
| class MovieShelf | |
| def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context "a movie shelf" do | |
| setup { @shelf = MovieShelf.new } | |
| should "show how many movies are stored" do | |
| juno = Movie.new("Juno") | |
| transformers = Movie.new("Transformers") | |
| shelf.store juno | |
| shelf.store transformers | |
| assert_equal 2, shelf.movies_count | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MovieShelf | |
| def initialize | |
| @movies = [] | |
| end | |
| def store(movie) | |
| @movies << movie | |
| end | |
| def contains?(movie) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it "should be successful" do | |
| Account.expects(:new).with(:current_user => @user, :first_name => "Test", :last_name => "Test").returns(@account) | |
| @account.expects(:login_method=).with(CONFIG::LOGIN::OpenID) | |
| @account.expects(:has_email_and_password=).at_least_once | |
| @account.expects(:has_openid=).twice | |
| do_edit | |
| response.should be_success | |
| response.should render_template("edit") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it "has been modified a lot of times" do | |
| Dependency.stubs(:a_method) | |
| NoLongerADependency.stubs(:something).returns(false) | |
| AnotherDependency.stubs(:nonexistent_method).returns(10) | |
| MyClass.new.do_something | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mocha::Configuration.prevent(:stubbing_non_existent_method) #prevents stubbing of non-existent methods | |
| Mocha::Configuration.prevent(:stubbing_method_unnecessarily) #prevents stubbing of unused methods | |
| Mocha::Configuration.prevent(:stubbing_non_public_method) #prevents stubbing of non-public methods | |
| Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object) #prevents stubbing on concrete objects |
OlderNewer