由于未知原因,在RT ch 9中未通过Rspec测试

时间:2014-01-08 20:28:59

标签: ruby railstutorial.org

我目前陷入9.13和9.2之间。我完全从该部分复制了规范和控制器文件,但仍然无法通过Rspec测试。得到这个错误 - 这是常见的吗?我没有在这里发布它。

Failures:

1) User_pages edit with valid information Failure/Error: it { should have_title(new_name) } expected #has_title?("New Name") to return true, got false # ./spec/requests/user_pages_spec.rb:47:in `block (4 levels) in '

2) User_pages edit with valid information Failure/Error: it { should have_selector('div.alert.alert-success') } expected #has_selector?("div.alert.alert-success") to return true, got false # ./spec/requests/user_pages_spec.rb:48:in `block (4 levels) in '

3) User_pages edit with valid information Failure/Error: specify { expect(user.reload.name).to eq new_name }

   expected: "New Name"
        got: "John Smith"

   (compared using ==)
 # ./spec/requests/user_pages_spec.rb:50:in `block (4 levels) in <top (required)>'
4) User_pages edit with valid information Failure/Error: specify { expect(user.reload.email).to eq new_email }

   expected: "new@example.com"
        got: "champion@aol.com"

   (compared using ==)
 # ./spec/requests/user_pages_spec.rb:51:in `block (4 levels) in <top (required)>'
Finished in 4.41 seconds 64 examples, 4 failures

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:47 # User_pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:48 # User_pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:50 # User_pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:51 # User_pages edit with valid information

我在这里发布了一些代码:https://gist.github.com/ephunit/8293106

如果您想查看其他文件,请告诉我?

PS我所有的规格测试在9.13之前都是绿色的。非常感谢任何帮助。

编辑:有趣......当我在网页上做一个runthrough时,单击Webapp中的设置以更新配置文件,并尝试保存新密码,我收到以下错误: 表单包含1个错误。 *密码确认不能为空

即使我试图输入新密码。如果我只是输入原始密码,则会出现同样的错误。这可能就是我失败的原因。

1 个答案:

答案 0 :(得分:0)

Spec_error

 1) User_pages edit with valid information Failure/Error: it { should have_title(new_name) } expected #has_title?("New Name") to return true, got false # ./spec/requests/user_pages_spec.rb:47:in `block (4 levels) in '

如果您没有将 {title:sign-up} 代码放在 view / static-pages 的顶部,则通常会出现此问题(例如:关于页面的标题:约)。我不知道确切的代码,但我遇到了同样的问题,并通过这个解决方案解决了。