2015-11-19 67 views
0

我正在写入功能测试:ruby 2.1.4,rails 4.1.12,rspec (2.14.1),capybara (2.4.1)poltergeist (1.5.1)为什么在CodeShip上使用JavaScript进行Rspec测试失败?

目前我有这样一个特点:

require 'spec_helper' 

feature 'user is able to import videos from YouTube Channel', js: true do 

    before do 
    @user = FactoryGirl.create :user 
    end 

    scenario 'from a simple correct YouTube video link' do 
    VCR.use_cassette('video_sources/youtube_add_single_video') do 

     visit root_path 

     fill_in 'user_email', with: @user.email 
     fill_in 'user_password', with: @user.password 
     click_button 'Log in' 

     visit youtube_import_path 

     expect(page).to have_css("input#query") 
     expect(page).to have_css("a#continue-button") 

     fill_in "query", with: "https://www.youtube.com/watch?v=xZY43QSx3Fk" 

     page.find('#continue-button').trigger('click') 

     # clicking on '#continue-button' call youtube API 
     # receive a video data and store it into DB 

     expect(page).to have_content("Congrats! Your import is complete") 
    end 
    end 

end 

当地一切正常,所有的测试都是绿色。 但在CodeShip上 - 这种情况总是失败。

Capybara::Poltergeist::StatusFailError: 
Request to 'http://127.0.0.1:3000/' failed to reach server, check DNS and/or server status 

但为什么: 为什么...

CodeShip日志说,我找不到理由吗?本地所有测试都是绿色的。

P.S.我试图在行visit root_path之前添加sleep 5,但它没有帮助。

P.S.S.也许的spec_helper.rb这部分将是有益的:

config.before(:suite) do 
    DatabaseCleaner.clean_with(:truncation) 
    Capybara.reset_sessions! 
    end 

    config.before(:each) do 
    DatabaseCleaner[:mongoid].start 
    end 

    config.after(:each) do 
    DatabaseCleaner[:mongoid].clean 
    end 

    config.after(:suite) do 
    Rails.cache.clear 
    end 

回答

0

尝试把sleep(5)visit root_path并再次检查,如果测试失败

+0

它并不能帮助:(我尝试添加'把page.current_url'在'访问root_path'后 - 它返回我''页面:空白“'而不是'”/ sign_in“' – bmalets

+0

看起来像不打开'root_path'页面,但是为什么?O_o – bmalets

+0

AND capybara应该自动等待,shouldn 't it? – bmalets