2012-11-14 5 views
2

:js => true이 포함 된 Rsped가 포함 된 Capybara 스크립트가 있는데, 스크립트를 별도로 실행할 때 잘 작동합니다. 예! 내가 스크립트를 실행하면Guard 모든 사양을 실행하면 Capybara + JS 테스트 결과가 반환됩니다. '부팅 중에 랙 어플리케이션 시간 초과'

# spec/requests/capybara_and_js_spec.rb 
require 'spec_helper' 

describe "Associating Articles with Menus" do 
    it "should include javascript", js: true do 
    visit root_path 
    page.should have_selector('script') 
    end 
end 

내가 얻을 : 여기에 스크립트의 내가 Guard Run all를 통해 내 사양의 모든과 같은 스크립트를 실행할 때

. 
Finished in 4.22 seconds 
1 example, 0 failures 

그러나, 나는이 얻을이 (I는 생략했습니다 나는했습니다 몇 천 개 시험)

........................*...*..............Rack application timed out during boot 
Rack application timed out during boot 
F..................................... 

답변

4

는이 문제를 연구 꽤 많은 시간을 할애하고, 문제에 대한 몇 가지 흥미로운 블로그 게시물을 찾았지만 해결책으로는 나를 위해 일하지 않는다.

내가 그렇게처럼, 웹킷과 심령에 카피 바라 셀레늄의 기본 JS 드라이버로 전환 :

# Gemfile 
gem "capybara-webkit" 

# spec/spec_helper.rb 
Spork.prefork do 
    Capybara.javascript_driver = :webkit 
end 

# Gemfile 
    gem "poltergeist" 

# spec/spec_helper.rb 
Spork.prefork do 
    require 'capybara/poltergeist' 
    Capybara.javascript_driver = :poltergeist 
end 

하지만

여기에 내가 시도 옵션은 어느 쪽이든을 가진 운.

this thread

this article 내가 시도 :

# spec/spec_helper.rb 
Spork.prefork do 
    Capybara.server_boot_timeout = 600 # Default is 10 my entire suite 
end         # takes ~550s to run, that's why I 
             # attempted such a large boot timeout in 
             # case the time was from beginning of suite 
             # execution. 

를 아무 소용.

은 그 때 나는 this article 발견, 그래서 시도 :

# spec/spec_helper.rb 
# initial advice was for cucumber, and thus recommended this to be placed in 
# the features/env.rb file 
def find_available_port 
    server = TCPServer.new('127.0.0.1', 0) 
    server.addr[1] 
ensure 
    server.close if server 
end 

if ENV['TDDIUM'] then 
    Capybara.server_port = find_available_port 
end 

하지만 그와 운.

는 또한 DatabaseCleaner 아직도 per this issue on StackOverflow.

행운, FactoryGirl에서 내 공장 멋지게 연주했다 확인하기 위해 내 database_cleaner 설정을 확인.

다음 나는과 같이, 내 Guardfile 내 낮은 수준의 RSpec에 테스트에서 내 카피 바라 시험을 구문 분석을 시도 :

group 'integration tests' do 
    # Capybara Tests 
    guard 'rspec', spec_paths: ['spec/requests'] do 
    watch(%r{^spec/requests/.+_spec\.rb}) 
    end 
    # Cucumber Feature Tests 
    guard 'cucumber', bundler: true do 
    watch(%r{^features/.+\.feature$}) 
    end 
end 

group 'unit tests' do 
    rspec_paths = ['spec/controllers', 'spec/helpers', 'spec/models', 'spec/views'] 
    # RSpec Unit Tests 
    guard 'rspec', spec_paths: rspec_paths do 
    watch(%r{^spec/.+_spec\.rb$}) 
    end 
    # Jasmine JS Unit Tests 
    guard 'jasmine', all_on_start: false, all_after_pass: false do 
    watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$}) 
    end 
end 

과 성공을! 마침내!

3

나는 많은 시간을 보낸 후에 같은 문제가 있었다. 나는 3001 번 포트에서 다른 레일 서버를 실행하고 있다고 생각합니다. 서버를 종료하면 제 큐크가 매력처럼 작동합니다.

내가 도움이되기를 바랍니다.

관련 문제