1

Railsの初心者で、Michael HartlのRubyOnRailsチュートリアルを読んでいます...第9章の同様の問題について読みましたが、自分の問題を解決できなかったので、ここに私のgithubリポジトリと失敗したテストがあります...おそらく誰かが私を助けることができます、 本当にありがとう ;)

https://github.com/AntonioCortinaL/sample_app

1) UserPages edit page 
 Failure/Error: it { should have_selector('h1',       text: "Update your profile") }
   expected css "h1" with text "Update your profile" to return something
 # ./spec/requests/user_pages_spec.rb:61:in `block (4 levels) in <top (required)>'

2) UserPages edit page 
 Failure/Error: it { should have_selector('title',    text: "Edit user") }
   expected css "title" with text "Edit user" to return something
 # ./spec/requests/user_pages_spec.rb:62:in `block (4 levels) in <top (required)>'

3) UserPages edit page 
 Failure/Error: it { should have_link('change', href: 'http://gravatar.com/emails') }
   expected link "change" to return something
 # ./spec/requests/user_pages_spec.rb:63:in `block (4 levels) in <top (required)>'

4) UserPages edit with invalid information 
 Failure/Error: before { click_button "Save changes" }
 Capybara::ElementNotFound:
   no button with value or id or text 'Save changes' found
 # (eval):2:in `click_button'
 # ./spec/requests/user_pages_spec.rb:67:in `block (4 levels) in <top (required)>'

5) UserPages edit with valid information 
 Failure/Error: fill_in "Name",             with: new_name
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top (required)>'

6) UserPages edit with valid information 
 Failure/Error: fill_in "Name",             with: new_name
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top (required)>'

7) UserPages edit with valid information 
 Failure/Error: fill_in "Name",             with: new_name
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top (required)>'

8) UserPages edit with valid information 
 Failure/Error: fill_in "Name",             with: new_name
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top (required)>'

9) UserPages edit with valid information 
 Failure/Error: fill_in "Name",             with: new_name
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top (required)>'

Paul Fioravanti の回答後に編集します。

わかりました、ありがとう...これに変更しました:

 before do
  sign_in user
  visit edit_user_path(user) 
 end

今、その5つのエラー

1) UserPages edit with valid information 
 Failure/Error: fill_in "Confirm Password", with: user.password
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Confirm Password' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:81:in `block (4 levels) in <top (required)>'

2) UserPages edit with valid information 
 Failure/Error: fill_in "Confirm Password", with: user.password
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Confirm Password' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:81:in `block (4 levels) in <top (required)>'

3) UserPages edit with valid information 
 Failure/Error: fill_in "Confirm Password", with: user.password
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Confirm Password' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:81:in `block (4 levels) in <top (required)>'

4) UserPages edit with valid information 
 Failure/Error: fill_in "Confirm Password", with: user.password
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Confirm Password' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:81:in `block (4 levels) in <top (required)>'

5) UserPages edit with valid information 
 Failure/Error: fill_in "Confirm Password", with: user.password
 Capybara::ElementNotFound:
   cannot fill in, no text field, text area or password field with id, name, or label 'Confirm Password' found
 # (eval):2:in `fill_in'
 # ./spec/requests/user_pages_spec.rb:81:in `block (4 levels) in <top (required)>'
4

2 に答える 2

1

あなたのuser_pages_spec.rbテストは言う:

describe "edit" do
  let(:user) { FactoryGirl.create(:user) }
  before { visit edit_user_path(user) }
  # ...
end

sign_inする前にを忘れていましvisitedit_user_path

チュートリアルの同等の仕様は次のとおりです。

編集

2 番目の問題については、Rails チュートリアルの同等のリンクを参照してくださいここここでuser_pages_spec.rb を比較してください:フィールドとフィールドを試していることがわかりますが、アプリに実際に存在するのはそのうちの 1 つだけです... fill_in"Confirm Password""Confirmation"

于 2013-04-10T11:06:09.833 に答える
0

テスト スイートを実行する前に、Rails コンソールを使用して各ユーザーに有効な記憶トークンを付与してください。正確な指示については、8.2.4 に従ってください。

于 2014-08-10T21:54:28.090 に答える