【发布时间】:2013-05-23 20:17:48
【问题描述】:
我在 Hartl's Rails 教程的 Section 7.3.1 中,遇到以下错误:
Capybara::ElementNotFound:
no button with value or id or text 'Create my account' found
但据我所知,具有该值的按钮确实存在。
这是 new.html.erb 代码:
<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Create my acccount", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>
这里有人有什么想法吗?
另外,这是测试的一部分:
describe "signup" do
before { visit signup_path }
let(:submit) { "Create my account" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "user@example.com"
fill_in "Password", with: "foobar"
fill_in "Confirmation", with: "foobar"
end
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
end
end
“有效信息”和“无效信息”都失败了也可能一文不值。
【问题讨论】:
-
帐户中多了一个“c”:
<%= f.submit "Create my acccount"。 -
就是这样!谢谢你!现在我该如何投票?
-
为 cmets 投票需要minimum reputation。
标签: ruby-on-rails-3.2 railstutorial.org