Cucumber/Webrat 不遵循redirect_to
我正在运行 Rails 3.0.0、rspec-rails 2.0.0.beta.20、webrat 0.7.2.beta.1、cucumber-rails 0.3.2 我有这样的场景:
Scenario:
Given I am on the new account page
And I fill in "Name" with "John Doe"
When I press "Create"
Then I should be on the access page
当我运行它时,我得到:
expected: "/access",
got: "/accounts"
就像它没有遵循控制器中的redirect_to:
#accounts_controller.rb
def create
@account = Account.new(params[:account])
if @account.save
flash[:notice] = "Saved!"
redirect_to access_url
else
flash[:alert] = "Error!"
render :new
end
end
我错过了一个步骤吗?我以为 webrat 遵循了所有重定向。谢谢
使用 launchy gem 我得到一个页面,上面写着:
“您正在被重定向”,并带有指向 access_path 的链接
?
I am running rails 3.0.0, rspec-rails 2.0.0.beta.20, webrat 0.7.2.beta.1, cucumber-rails 0.3.2
I have this scenario:
Scenario:
Given I am on the new account page
And I fill in "Name" with "John Doe"
When I press "Create"
Then I should be on the access page
When I run it I get:
expected: "/access",
got: "/accounts"
Like its not following the redirect_to in the controller:
#accounts_controller.rb
def create
@account = Account.new(params[:account])
if @account.save
flash[:notice] = "Saved!"
redirect_to access_url
else
flash[:alert] = "Error!"
render :new
end
end
Am I missing a step? I thought webrat followed all redirects. Thanks
Using launchy gem I get a page that says:
"You are being redirected" with a link to the access_path
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定这是否适用于 Rails 3,但是你可以尝试一下这个方法“follow_redirect!”
Not sure if this applies in Rails 3, but can you just try this method "follow_redirect!"
这是在这里回答的:
Webrat和Rails:在click_button之后使用assert_contain给我“你正在被重定向”
解决方案对我有用。
this is answered here:
Webrat and Rails: Using assert_contain after click_button gives me "You are being redirected"
solution worked for me.
我找到了这个对我有帮助的解决方案。
http://baldowl.github.com /2010/12/06/coercing-cucumber-and-webrat-to-cooperate.html
I found this solution which helped me.
http://baldowl.github.com/2010/12/06/coercing-cucumber-and-webrat-to-cooperate.html