Ruby on rails 为什么recaptcha不会导致此测试失败?

Ruby on rails 为什么recaptcha不会导致此测试失败?,ruby-on-rails,cucumber,recaptcha,Ruby On Rails,Cucumber,Recaptcha,我正在使用Rails 3.1.0和来自的recaptcha gem。我正在运行一个Cumber测试,检查用户是否可以注册。注册要求用户填写验证码。我知道我的测试不涉及验证码: When /^I create a new account with email: "(.*?)" and password: "(.*?)"$/ do |email, pw| click_link "Sign up" fill_in "Email", :with => email fill_

我正在使用Rails 3.1.0和来自的recaptcha gem。我正在运行一个Cumber测试,检查用户是否可以注册。注册要求用户填写验证码。我知道我的测试不涉及验证码:

When /^I create a new account with email: "(.*?)" and password: "(.*?)"$/ do |email, pw|
    click_link "Sign up"
    fill_in "Email", :with => email
    fill_in "Password", :with => pw
    fill_in "Password confirmation", :with => pw
    click_button "Sign up"
end
但测试还是通过了。我通过使用以下步骤验证页面上是否存在成功注册消息,以及是否不存在recaptcha失败消息来检查成功:

Then /^I should (not )?see "(.*)"$/ do |negate, text|
  if negate
    page.should_not have_content text
  else
    page.should have_content text
  end
end
控制器与建议的第一个控制器几乎相同

类注册控制器

是否有任何原因说明recaptcha不能在测试环境中工作?它在开发中似乎运行良好。

默认情况下,Recaptcha不会在测试和cucumber环境中验证验证码(请参阅和)。如果不是因为这个原因,测试将非常困难,或者验证码将不会非常有用。

只是为了补充Bens的答案并给出一个潜在的解决方法:

为了确保RSpec中的事情不起作用(它“使用recaptcha失败”),我已经做了

before do
  Recaptcha.configuration.skip_verify_env.delete("test")
end

after do
  Recaptcha.configuration.skip_verify_env << "test"
end
在做之前
repactcha.configuration.skip\u verify\u env.delete(“测试”)
结束
事后

Recaptcha.configuration.skip_verify_env我认为可能是这样,但在github页面的任何地方都没有提到它。没有看来源。
before do
  Recaptcha.configuration.skip_verify_env.delete("test")
end

after do
  Recaptcha.configuration.skip_verify_env << "test"
end