Created
January 23, 2012 17:02
-
-
Save roolo/1664264 to your computer and use it in GitHub Desktop.
RSpec test
This file contains 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
require 'spec_helper' | |
describe "Books" do | |
describe "PUT /books/:id" do | |
it "updates a book" do | |
book = {name: 'Alchandira', description: 'Something'} | |
updated_book = {name: 'Cave', description: 'Something'} | |
# Create book | |
post books_path, book: book | |
response.status.should eq(302) | |
# Verify creation | |
new_book = Book.find_by_name book[:name] | |
new_book.nil?.should_not eq true | |
# Update book | |
put book_path(new_book), book: updated_book | |
response.status.should eq(302) | |
# Verify the change | |
new_book_updated = Book.find_by_name updated_book[:name] | |
new_book_updated.nil?.should_not eq true | |
new_book_updated.id.should eq new_book.id | |
new_book_updated.name.should eq updated_book[:name] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment