Hi I am struggling to run my integration/feature tests via the Ci, please do let me know what am I doing wrong here.
Running specs locally works without any issues
The strangeness of this is that it dose not want to run because it seems to have problems finding application .css or .js
the gitlab CI setup :
image: ruby:2.3.0
cache:
paths:
- .bundle
- vendor/
stages:
- test
- integration
- codecov
before_script:
- export COMPILE=0
- export PHANTOM_JS=phantomjs-2.1.1-linux-x86_64
- export RAILS_ENV=test
- gem install bundler
- bundle install --path vendor/
- mkdir ~/tmp
- pushd ~/tmp
- wget --max-redirect=40
http://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
- tar xf $PHANTOM_JS.tar.bz2
- mv $PHANTOM_JS phantomjs
- ln -s ~/tmp/phantomjs/bin/phantomjs /usr/bin/phantomjs
- phantomjs --version
- popd
rspec:
stage: test
services:
- postgres:latest
- redis:latest
variables:
POSTGRES_DB: package_analysis_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: runner
script:
- apt-get update -qq && apt-get install -y -qq nodejs postgresql-
client libpq-dev
- gem install bundler --no-ri --no-rdoc
- cp config/_database.yml config/database.yml
- cp config/_redis.yml config/redis.yml
- cp config/_sidekiq.yml config/sidekiq.yml
- cp config/_settings.yml config/settings.yml
- bundle exec rake db:drop RAILS_ENV=test
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:schema:load RAILS_ENV=test
- bundle exec rake db:structure:load RAILS_ENV=test
- bundle exec rake db:seed RAILS_ENV=test
- bundle exec rake assets:precompile RAILS_ENV=test
- bundle exec rspec --exclude-pattern spec/features/*_spec.rb
artifacts:
paths:
- coverage/
rspec-integration:
stage: integration
services:
- postgres:latest
- redis:latest
variables:
POSTGRES_DB: package_analysis_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: runner
script:
- apt-get update -qq && apt-get install -y -qq nodejs postgresql-
client libpq-dev
- gem install bundler --no-ri --no-rdoc
- cp config/_database.yml config/database.yml
- cp config/_redis.yml config/redis.yml
- cp config/_sidekiq.yml config/sidekiq.yml
- cp config/_settings.yml config/settings.yml
- bundle exec rake db:drop RAILS_ENV=test
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:schema:load RAILS_ENV=test
- bundle exec rake db:structure:load RAILS_ENV=test
- bundle exec rake db:seed RAILS_ENV=test
- bundle exec rake assets:precompile RAILS_ENV=test
- bundle exec rspec spec/features
pages:
stage: codecov
dependencies:
- rspec
script:
- mv coverage/ public/
artifacts:
paths:
- public
expire_in: 30 days
only:
- staging
this is how the 'head' of the error looks like:
1) User processes late orders entering late orders #index
Failure/Error: raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #
{env['PATH_INFO'].inspect}"
ActionController::RoutingError:
No route matches [GET] "/assets/application.css"
# /builds/justcode/packageanalysis/vendor/ruby/2.3.0/gems/web-console-
2.0.0/lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
# /builds/justcode/packageanalysis/vendor/ruby/2.3.0/gems/web-console-
2.0.0/lib/action_dispatch/debug_exceptions.rb:13:in `call'
# /builds/justcode/packageanalysis/vendor/ruby/2.3.0/gems/actionpack-
4.2.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
# /builds/justcode/packageanalysis/vendor/ruby/2.3.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:38:in
`call_app'
Once its the application js the other tie its the css file. I am confused on what to do with this
this is also my capybara setup from the test helpers :
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'capybara/rails'
Capybara.register_driver :poltergeist do |app|
options = {
js_errors: true,
cookies: true,
inspector: true,
window_size: [2_500, 2_500]
}
Capybara::Poltergeist::Driver.new(app, options)
end
Capybara.default_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Capybara.default_selector = :css
What worked for me was to move to headless chrome and use my own image.
https://hub.docker.com/r/grfx/ruby-chromedriver/ (ruby 2.3, chromedriver 2.33, node, postgresql-client)
ALSO do turn off caching for the time between now and merge to master(main) branch if You used a different image setting.
The gitlab-ci setup was reduced to essential settings :
image: 'grfx/ruby-chromedriver:latest'
cache:
paths:
#- .bundle
#- vendor/
#- public/
stages:
- test
- codecov
before_script:
- export RAILS_ENV=test
- bundle install --path vendor/
rspec:
stage: test
services:
- postgres:latest
- redis:latest
variables:
POSTGRES_DB: package_analysis_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: runner
script:
- cp config/_database.yml config/database.yml
- cp config/_redis.yml config/redis.yml
- cp config/_sidekiq.yml config/sidekiq.yml
- cp config/_settings.yml config/settings.yml
- bundle exec rake db:drop RAILS_ENV=test
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:schema:load RAILS_ENV=test
- bundle exec rake db:structure:load RAILS_ENV=test
- bundle exec rake db:seed RAILS_ENV=test
- bundle exec rspec
artifacts:
paths:
- coverage/
- public/
pages:
stage: codecov
dependencies:
- rspec
script:
- mv coverage/ public/
artifacts:
paths:
- public
expire_in: 30 days
only:
- staging
gems used :
gem 'selenium-webdriver', '~> 3.9'
gem 'webdrivers'
gem 'capybara', '~> 2.16.1'
rspec setup (rails_helper)
require 'capybara/rspec'
require 'selenium-webdriver'
require 'capybara/rails'
Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new(
args: %w(headless disable-gpu no-sandbox)
)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
Capybara.javascript_driver = :chrome
Capybara.default_driver = :chrome
Capybara.default_selector = :css
Looks like you're using single quotes instead of double quotes when defining the route:
"No route matches [#{env['REQUEST_METHOD']}] # {env['PATH_INFO'].inspect}"