我有一个assigment进行简单的BDD测试。值不被编辑。黄瓜+水豚
我的情况是这样的:
Background: movies in database
Given the following movies exist:
| title | rating | director | release_date |
| Star Wars | PG | George Lucas | 1977-05-25 |
| Blade Runner | PG | Ridley Scott | 1982-06-25 |
| Alien | R | | 1979-05-25 |
| THX-1138 | R | George Lucas | 1971-03-11 |
Scenario: add director to existing movie
When I go to the edit page for "Alien"
And I fill in "Director" with "Ridley Scott"
And I press "Update Movie Info"
Then the director of "Alien" should be "Ridley Scott
我的步骤是这样的:
When /^(?:|I)go to (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^(?:|I)fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
When /^(?:|I)press "([^"]*)"$/ do |button|
click_button(button)
end
Then /^the director of "([^"]*)" should be "([^"]*)"$/ do |movie, director|
film = Movie.find_by_title(movie)
puts page.body
assert film.director.should == director
end
我的问题是,导演值不编辑。我无法将其与导演进行比较。
其他值被正确赋值,例如我可以断言“film.rating.should == director”并且得到那个预期的“Ridley Scott”得到了“R”。但对于导演我没有。
这不是问题与我已创建字段编辑导演或数据库,我有一个指向列。
我的直觉是,数据库没有重新加载,但我无法为此找到一个命令。
我会很高兴的任何帮助:)
答:
我忘了,包括:导演在我的模型,它能够wasn`t以检索参数。 Thnx寻求帮助,因为我从中学到了任何帮助。
你迁移DB的'test'环境,为'cucumber'环境exaclty? – 2014-12-07 17:26:07
我使用了rake db:test:prepared,它仍然没有传递编辑后的值 – Kazik 2014-12-08 03:51:59
'RAILS_ENV = test rake db:migrate'你使用的测试数据库名为'test' – 2014-12-08 09:05:15