规格/功能/ album_spec.rb:Rspec的功能测试问题
feature "Album Pages" do
given(:album) { create(:album) } # by Factory_Girl
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
错误:
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"
# ./spec/features/albums_spec.rb:27:in `block (2 levels) in <top (required)>'
应用程序工作正常,如果我点击它重定向到专辑中的网站,按钮其名称显示为<h1>
。我尝试这样做:
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
比我得到了一个网页与bar
为<h1>
,所以我不知道这有什么错我的测试,我可以在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]]
任何想法?
我假设你有代码在github上的某处,我可以查看。 – drKreso
确实如此:[here](https://github.com/pawel7318/footoo)。 – pawel7318