specifications / features / album_spec.rb:
feature "Album Pages" do
given(:album) { create(:album) }
scenario "Edit album" do
visit edit_album_path album
fill_in "Name", with: "bar"
expect {click_button "Update Album"}.to change(Album.last, :name).to("bar")
end
end
Error:
1) Album Pages Edit album
Failure/Error: expect {click_button "Update Album"}.to change(Album.last, :name).to("bar")
name should have been changed to "bar", but is now "Gorgeous Granite Table"
The application works fine, and if I press the button, it is redirected to the album site, where its name is displayed as <h1>. I tried this:
scenario "Edit album" do
visit edit_album_path album
fill_in "Name", with: "bar"
click_button "Update Album"
save_and_open_page
#expect {click_button "Update Album"}.to change(Album.last, :name).to("bar")
end
than I got a page with barhow <h1>, so I don’t know what happened to my test, and I see in test.log:
SQL (0.7ms) UPDATE "albums" SET "name" = ?, "updated_at" = ? WHERE "albums"."id" = 1 [["name", "bar"], ["updated_at", Fri, 11 Apr 2014 11:30:00 UTC +00:00]]
Any ideas?
source
share