Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RSPEC登录方法返回错误_Ruby On Rails_Ruby_Rspec_Capybara - Fatal编程技术网

Ruby on rails RSPEC登录方法返回错误

Ruby on rails RSPEC登录方法返回错误,ruby-on-rails,ruby,rspec,capybara,Ruby On Rails,Ruby,Rspec,Capybara,我正在尝试通过rspec和水豚登录用户。这是我第一次编写自己的测试,我不确定问题出在哪里,好像我点击了我的应用程序,它工作正常。问题似乎要么是RSPEC没有正确填写字段,要么是没有单击链接或按钮,但我不确定要查找哪个或如何查找 以下是已编辑的测试,用于添加以下内容: it "logs the user in and redirects them to speakeasy home on success" do sign_up_as_hello_world page.should have

我正在尝试通过rspec和水豚登录用户。这是我第一次编写自己的测试,我不确定问题出在哪里,好像我点击了我的应用程序,它工作正常。问题似乎要么是RSPEC没有正确填写字段,要么是没有单击链接或按钮,但我不确定要查找哪个或如何查找

以下是已编辑的测试,用于添加以下内容:

it "logs the user in and redirects them to speakeasy home on success" do
  sign_up_as_hello_world
  page.should have_content 'INSTANT MACHINE TRANSLATION'
end
失败就在这里

  1) Sign up logs the user in and redirects them to speakeasy home on success
 Failure/Error: page.should have_content 'INSTANT MACHINE TRANSLATION'
   expected to find text "INSTANT MACHINE TRANSLATION" in "Speakeasy Technology + Humanity Sign In Invalid username or password New users start out with $5 demo credit Sign Up"
 # ./spec/features/auth_spec.rb:40:in `block (2 levels) in <top (required)>'
我也试过把它作为最后一行,但它也不起作用

click_button "Sign Up"
表单的html在此处单击“注册”链接将“提交”按钮的值更改为“注册”:

<form class="login" action="<%= session_url %>" method="post" id="mainForm">
  <%= auth_token_input%>
  <input type="text" placeholder="Username" name="user[username]" id="username"/>
  <input type="text" placeholder="Email" name="user[email]" id="email"/>
  <input type="password" placeholder="Password" name="user[password]" id="password"/>
  <input type="submit" value="Sign In" class="btn btn-success btn-sm" id="submitButton"/>
  <div style="text-align:center">
  <p>New users start out with $5 demo credit</p>
  <a href="" class="register" id="signUpLink">Sign Up</a>
  </div>
</form>

看起来错误不在注册中,而是在测试预期中。在./spec/features/auth_spec.rb:40中有什么?您说您尝试了单击按钮注册,但您的视图显示它应该是单击按钮注册,包括链接注册将按钮值更改为“注册”。右侧,注册实际上不会引发错误,但会重新呈现带有错误消息的注册表单,当它应该重定向到主页时。所以到目前为止,测试应该失败了,问题是没有正确填写或单击。你能在这里发布用户注册日志并将他们重定向到speakeasy home on success test吗?
<form class="login" action="<%= session_url %>" method="post" id="mainForm">
  <%= auth_token_input%>
  <input type="text" placeholder="Username" name="user[username]" id="username"/>
  <input type="text" placeholder="Email" name="user[email]" id="email"/>
  <input type="password" placeholder="Password" name="user[password]" id="password"/>
  <input type="submit" value="Sign In" class="btn btn-success btn-sm" id="submitButton"/>
  <div style="text-align:center">
  <p>New users start out with $5 demo credit</p>
  <a href="" class="register" id="signUpLink">Sign Up</a>
  </div>
</form>