2015-05-15 3 views
0

У меня есть следующий тест ...Капибара визитер «неверное число аргументов

describe 'non auth user' do 
    it 'welcomes the user' do 

    #visit home page 
    visit '/' 
    page.should have_content('Upcoming Sessions') 

    #visit all events 
    visit '/events' 
    page.should have_content('All Sessions') 

    #visit recent events 
    visit '/events/recent' 
    page.should have_content('Recent Sessions') 

    #visit upcoming events 
    visit '/events/upcoming' 
    page.should have_content('Upcoming Sessions') 

    end 
end 

... и вот сообщение об ошибке я получаю ...

[email protected] user:learn user$ rspec spec 
UPGRADE WARNING: Honeybadger.configure was removed in v2.0 and has no effect. Please upgrade: https://www.honeybadger.io/s/gem-upgrade 
including Capybara::DSL in the global scope is not recommended! 
.F 

Failures: 

    1) non auth user welcomes the user 
    Failure/Error: visit '/events' 
    ArgumentError: 
     wrong number of arguments (1 for 0) 
    # ./app/controllers/events_controller.rb:19:in `index' 
    # ./app/controllers/application_controller.rb:69:in `block in set_timezone' 
    # ./app/controllers/application_controller.rb:69:in `set_timezone' 
    # ./app/middleware/catch_json_parse_errors.rb:10:in `call' 
    # ./spec/integration/main_spec.rb:24:in `block (2 levels) in <top (required)>' 

Deprecation Warnings: 

-------------------------------------------------------------------------------- 
RSpec::Core::ExampleGroup#example is deprecated and will be removed 
in RSpec 3. There are a few options for what you can use instead: 

    - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc) 
    now yield the example as a block argument, and that is the recommended 
    way to access the current example from those contexts. 
    - The current example is now exposed via `RSpec.current_example`, 
    which is accessible from any context. 
    - If you can't update the code at this call site (e.g. because it is in 
    an extension gem), you can use this snippet to continue making this 
    method available in RSpec 2.99 and RSpec 3: 

     RSpec.configure do |c| 
     c.expose_current_running_example_as :example 
     end 

(Called from /Users/marklocklear/.rvm/gems/[email protected]/gems/capybara-2.0.2/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>') 
-------------------------------------------------------------------------------- 
-------------------------------------------------------------------------------- 
RSpec::Core::ExampleGroup#example is deprecated and will be removed 
in RSpec 3. There are a few options for what you can use instead: 

    - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc) 
    now yield the example as a block argument, and that is the recommended 
    way to access the current example from those contexts. 
    - The current example is now exposed via `RSpec.current_example`, 
    which is accessible from any context. 
    - If you can't update the code at this call site (e.g. because it is in 
    an extension gem), you can use this snippet to continue making this 
    method available in RSpec 2.99 and RSpec 3: 

     RSpec.configure do |c| 
     c.expose_current_running_example_as :example 
     end 

(Called from /Users/marklocklear/.rvm/gems/[email protected]/gems/capybara-2.0.2/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>') 
-------------------------------------------------------------------------------- 


If you need more of the backtrace for any of these deprecations to 
identify where to make the necessary changes, you can configure 
`config.raise_errors_for_deprecations!`, and it will turn the 
deprecation warnings into errors, giving you the full backtrace. 

2 deprecation warnings total 

Finished in 0.44172 seconds 
2 examples, 1 failure 

Failed examples: 

rspec ./spec/integration/main_spec.rb:17 # non auth user welcomes the user 

Randomized with seed 37582 

Примечания линия 24 является визит '/ события'

Здесь находятся капибары и драгоценные камни ... XPath

capybara ([email protected] user:learn user$ gem list xpath && gem list capybara 
*** LOCAL GEMS *** 
xpath (2.0.0, 1.0.0) 
*** LOCAL GEMS *** 
capybara (2.4.4, 2.0.2).4.4, 2.0.2) 

Первый текст, идущий в// работает нормально, но не '/ events'. Нашли какие-то подсказки относительно различных версий капибары и камней xpath. Я попытался указать некоторые более ранние версии этих драгоценных камней в моем Gemfile, но все же не работал.

Редактировать

Здесь находятся соответствующие строки events_controller ...

def index 
    @list_title = 'All Sessions' 
    params[:page].present? ? (@page_title = "#{@list_title} - Page #{params[:page]}") : (@page_title = @list_title) 
    if(@conference) 
     @conference_display = true 
     @events = @conference.events.active.order('session_start ASC').page(params[:page]) 
     @all_events_path = events_path 
    else 
     @events = Event.active.order('session_start DESC').page(params[:page]) 
    end 
    end 

Line 19 является @events = Event.active.order('session_start DESC').page(params[:page])

ответ

0

Во-первых, вы должны разорвать, что на отдельные сценарии/тесты, так как вы утверждая разные вещи.

Пожалуйста, разместите свой контроллер событий, так как это значит, что ошибка запускается. когда вы посещаете /events.

UPDATE:

Вы работаете в conflict между методом страницы Капибары и вашего пагинацией, который я предполагаю, либо на основе Kaminari или will_paginate.

Вы это предупреждение, что подтверждает это:

including Capybara::DSL in the global scope is not recommended!

так удалить Capybara::DSL из вашего spec_helper.rb.

+0

См. Обновление выше ... – Lumbee

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