2013-04-10 1 views
1

Я новичок в Rails, и я читаю учебник по RubyOnRails от Michael Hartl ... Я прочитал о аналогичных проблемах в главе 9, но я не решил свою собственную проблему, так что вот мой репозиторий github и неудавшийся тест ... может быть, кто-то может мне помочь, спасибо так много;)Глава 9 тест не выполнен Рубиновое руководство по рельсам

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)>' 

Edit после Paul Фиораванти ответ:

Ok, спасибо ... Я изменил его для этого:

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)>' 

ответ

1

Your user_pages_spec.rb test говорит:

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

Вы забыли sign_in перед тем visit ING в edit_user_path.

Here's the tutorial's equivalent spec.

Edit:

Что касается вашего второго вопроса см эквивалентной ссылки в Rails Tutorial here. Сравните ваш user_pages_spec.rbhere и here: вы можете увидеть, что вы пытаетесь fill_in в "Confirm Password" поле и "Confirmation" поле, только один из которых на самом деле существует в вашем приложении ...

+0

Спасибо за ответ, я исправил, но все еще 5 ошибок. Я сравнил код, который вы мне дали, и я думаю, что это правильно. – manguiti

+0

См. Редактирование вопроса; у вас может быть только опечатка. –

0

Убедитесь, что вы даете каждому пользователю действительный запоминающий токен с помощью консоли rails перед запуском набора тестов. Следуйте 8.2.4 для получения точных инструкций.

Смежные вопросы