###前提・実現したいこと
ローカルで開発を行っています。Rspec,Capybara,poltergeistなどを使ってfeatureスペックを書いています。
https://app.wercker.com/ を用いてCIを回しているのですが、予期せぬエラーが起きてしまいます。
解決方法をアドバイスしていただけると嬉しいです。
- ローカルのテストは全て成功します。 ModelやController,Featureなどのテストを書いています。
結果:
wercker.com: 287 examples, 2 failures, 5 pending
ローカル(mac): 287 examples, 0 failures, 5 pending
※ wercker.com で出力されるエラー。 feature spec全てが落ちているわけではありません。
###発生している問題・エラーメッセージ
ruby
1Failures: 2 3 1) Sample::Customs テストページ should have title "テストページ" 4 Failure/Error: Unable to find matching line from backtrace 5 ActionView::Template::Error: 6 Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true 7 # /cache/bundle-install/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/http/url.rb:67:in `build_host_url' 8 # /cache/bundle-install/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/http/url.rb:42:in `url_for' 9 # /cache/bundle-install/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/routing/route_set.rb:668:in `url_for' 10 # /cache/bundle-install/ruby/2.1.0/gems/actionpack-4.1.4/lib/action_dispatch/routing/url_for.rb:155:in `url_for' 11 # /cache/bundle-install/ruby/2.1.0/gems/actionview-4.1.4/lib/action_view/routing_url_for.rb:83:in `url_for'
###設定ファイル(一部)
ruby
1require 'rspec/rails' 2require 'capybara' 3require 'capybara/rspec' 4require 'capybara/poltergeist' 5Capybara.default_host = 'localhost:3000' 6Capybara.javascript_driver = :poltergeist 7Capybara.register_driver :poltergeist do |app| 8 Capybara::Poltergeist::Driver.new(app, { 9 js_errors: false, 10 timeout: 1000, 11 phantomjs_options: [ 12 '--load-images=no', 13 '--ignore-ssl-errors=yes', 14 '--ssl-protocol=any'] 15 } 16 ) 17end 18Capybara.configure do |config| 19 config.match = :one 20 config.exact_options = true 21 config.ignore_hidden_elements = true 22 config.visible_text_only = true 23end
試したこと
test.rbにdefault_url_optionsの記述
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
と出ているので、test.rb
に
config.action_mailer.default_url_options = { host: 'wercker-test.example.jp' }
を追加しましたが、解決せず。
rails_helperにdefault_url_optionsの設定を記述
http://stackoverflow.com/questions/7182600/rspec-route-testing-and-hosts を参考にrails_helper内に下記の設定を追加しました。が解決せず。
Rails.application.routes.default_url_options[:host] = 'test.host'
その他にもCapybaraのdefault_hostを設定したり、色々行いましたがエラー内容は変わりませんでした。
どこらへんの設定を確認すれば良いのか、などアドバイスをいただると嬉しいです。
宜しくお願いいたします。
あなたの回答
tips
プレビュー