-
-
Save MaherSaif/1390282 to your computer and use it in GitHub Desktop.
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
| # Make a user that we'll add a book to. | |
| user = User.create! | |
| controller.stub(:current_user) { user } | |
| # This prints []. The book list is empty. | |
| p user.books | |
| # Expect a book to be added to the user. This fails (see below) | |
| expect { | |
| post :create, :id => asin | |
| }.to change { user.books }.from([]).to([book]) | |
| # Failure/Error: expect { | |
| # books should have initially been [], but was [#<Book id: 1, asin: "the-asin", title: "Hamlet", authors: "Bill Shakes", pages: 0, is_ebook: false, image_url: nil, icon_url: nil, details_url: "http://example.com/hamlet", created_at: "2011-11-23 21:47:45", updated_at: "2011-11-23 21:47:45", editorial_review: nil>] | |
| # This seems wrong. `user.books` *is* initially []. Help? I'm running RSpec 2.7.1 on Ruby 1.8.7 and Rails 3.0.9. It also happens with RSpec 2.5. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment