Fix specs after update (switching to webkit)

This commit is contained in:
wvengen 2017-04-01 15:12:05 +02:00 committed by wvengen
parent ddf7402a3b
commit b857b10814
6 changed files with 21 additions and 42 deletions

View file

@ -13,7 +13,6 @@ env: COVERALLS=1
before_install: before_install:
- export DISPLAY=:99.0 - export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start - sh -e /etc/init.d/xvfb start
- sleep 3 && metacity --sm-disable --replace 2> metacity.err &
cache: bundler cache: bundler
bundler_args: bundler_args:
- "--without development --deployment --jobs=3 --retry=3" - "--without development --deployment --jobs=3 --retry=3"

View file

@ -103,8 +103,7 @@ group :test do
gem 'factory_girl_rails' gem 'factory_girl_rails'
gem 'faker' gem 'faker'
gem 'capybara' gem 'capybara'
# webkit and poltergeist don't seem to work yet gem 'capybara-webkit'
gem 'selenium-webdriver'
gem 'database_cleaner' gem 'database_cleaner'
gem 'connection_pool' gem 'connection_pool'
# need to include rspec components before i18n-spec or rake fails in test environment # need to include rspec components before i18n-spec or rake fails in test environment

View file

@ -71,7 +71,8 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
acts_as_tree (2.6.1) acts_as_tree (2.6.1)
activerecord (>= 3.0.0) activerecord (>= 3.0.0)
addressable (2.4.0) addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.4) arel (6.0.4)
attribute_normalizer (1.2.0) attribute_normalizer (1.2.0)
base32 (0.3.2) base32 (0.3.2)
@ -101,15 +102,16 @@ GEM
capistrano-rvm (0.1.2) capistrano-rvm (0.1.2)
capistrano (~> 3.0) capistrano (~> 3.0)
sshkit (~> 1.2) sshkit (~> 1.2)
capybara (2.7.1) capybara (2.13.0)
addressable addressable
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
xpath (~> 2.0) xpath (~> 2.0)
childprocess (0.5.9) capybara-webkit (1.14.0)
ffi (~> 1.0, >= 1.0.11) capybara (>= 2.3.0, < 2.14.0)
json
chronic (0.10.2) chronic (0.10.2)
coderay (1.1.1) coderay (1.1.1)
coffee-rails (4.1.1) coffee-rails (4.1.1)
@ -159,7 +161,6 @@ GEM
railties (>= 3.0.0) railties (>= 3.0.0)
faker (1.7.3) faker (1.7.3)
i18n (~> 0.5) i18n (~> 0.5)
ffi (1.9.10)
gaffe (1.2.0) gaffe (1.2.0)
rails (>= 4.0.0) rails (>= 4.0.0)
git-version-bump (0.15.1) git-version-bump (0.15.1)
@ -199,7 +200,7 @@ GEM
interception (0.5) interception (0.5)
iso (0.2.1) iso (0.2.1)
i18n i18n
jquery-rails (4.2.2) jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
@ -269,6 +270,7 @@ GEM
pry-stack_explorer (0.4.9.2) pry-stack_explorer (0.4.9.2)
binding_of_caller (>= 0.7) binding_of_caller (>= 0.7)
pry (>= 0.9.11) pry (>= 0.9.11)
public_suffix (2.0.5)
quiet_assets (1.1.0) quiet_assets (1.1.0)
railties (>= 3.1, < 5.0) railties (>= 3.1, < 5.0)
rack (1.6.5) rack (1.6.5)
@ -372,7 +374,7 @@ GEM
rspec (~> 3.0) rspec (~> 3.0)
rspec-support (3.4.1) rspec-support (3.4.1)
ruby-filemagic (0.7.1) ruby-filemagic (0.7.1)
ruby-ole (1.2.12) ruby-ole (1.2.12.1)
ruby-prof (0.15.9) ruby-prof (0.15.9)
ruby-units (2.0.0) ruby-units (2.0.0)
ruby_parser (3.8.2) ruby_parser (3.8.2)
@ -387,10 +389,6 @@ GEM
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
select2-rails (4.0.3) select2-rails (4.0.3)
thor (~> 0.14) thor (~> 0.14)
selenium-webdriver (2.53.1)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
sexp_processor (4.7.0) sexp_processor (4.7.0)
simple-navigation (3.14.0) simple-navigation (3.14.0)
activesupport (>= 2.3.2) activesupport (>= 2.3.2)
@ -437,7 +435,7 @@ GEM
rack (>= 1.0.0) rack (>= 1.0.0)
thor (0.19.4) thor (0.19.4)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.6) tilt (2.0.7)
tins (1.13.2) tins (1.13.2)
ttfunk (1.4.0) ttfunk (1.4.0)
twitter-bootstrap-rails (2.2.8) twitter-bootstrap-rails (2.2.8)
@ -447,7 +445,7 @@ GEM
railties (>= 3.1) railties (>= 3.1)
twitter-text (1.13.4) twitter-text (1.13.4)
unf (~> 0.1.0) unf (~> 0.1.0)
tzinfo (1.2.2) tzinfo (1.2.3)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (3.1.3) uglifier (3.1.3)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
@ -462,7 +460,6 @@ GEM
binding_of_caller (>= 0.7.2) binding_of_caller (>= 0.7.2)
railties (>= 4.0) railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
websocket (1.2.3)
whenever (0.9.7) whenever (0.9.7)
chronic (>= 0.6.3) chronic (>= 0.6.3)
wikicloth (0.8.3) wikicloth (0.8.3)
@ -490,6 +487,7 @@ DEPENDENCIES
capistrano-rails capistrano-rails
capistrano-rvm capistrano-rvm
capybara capybara
capybara-webkit
connection_pool connection_pool
coveralls coveralls
daemons daemons
@ -537,7 +535,6 @@ DEPENDENCIES
ruby-units ruby-units
sass-rails sass-rails
select2-rails select2-rails
selenium-webdriver
simple-navigation (~> 3.14.0) simple-navigation (~> 3.14.0)
simple-navigation-bootstrap simple-navigation-bootstrap
simple_form simple_form

View file

@ -53,7 +53,6 @@ feature 'settling an order', js: true do
it 'keeps ordered quantities when article is deleted from resulting order' do it 'keeps ordered quantities when article is deleted from resulting order' do
within("#order_article_#{oa.id}") do within("#order_article_#{oa.id}") do
click_link I18n.t('ui.delete') click_link I18n.t('ui.delete')
page.driver.browser.switch_to.alert.accept
end end
expect(page).to_not have_selector("#order_article_#{oa.id}") expect(page).to_not have_selector("#order_article_#{oa.id}")
expect(OrderArticle.exists?(oa.id)).to be true expect(OrderArticle.exists?(oa.id)).to be true
@ -70,7 +69,6 @@ feature 'settling an order', js: true do
goa2.destroy goa2.destroy
within("#order_article_#{oa.id}") do within("#order_article_#{oa.id}") do
click_link I18n.t('ui.delete') click_link I18n.t('ui.delete')
page.driver.browser.switch_to.alert.accept
end end
expect(page).to_not have_selector("#order_article_#{oa.id}") expect(page).to_not have_selector("#order_article_#{oa.id}")
expect(OrderArticle.exists?(oa.id)).to be false expect(OrderArticle.exists?(oa.id)).to be false
@ -146,10 +144,8 @@ feature 'settling an order', js: true do
click_link article.name click_link article.name
within("#group_order_articles_#{oa.id}") do within("#group_order_articles_#{oa.id}") do
fill_in "r_#{goa1.id}", :with => 5 fill_in "r_#{goa1.id}", :with => 5
# leave input box and wait a bit so that update is sent using ajax
find("#r_#{goa1.id}").native.send_keys :tab
sleep 1
end end
expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done
expect(goa1.reload.result).to eq 5 expect(goa1.reload.result).to eq 5
expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 6 expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 6
end end
@ -158,8 +154,8 @@ feature 'settling an order', js: true do
click_link article.name click_link article.name
within("#group_order_article_#{goa1.id}") do within("#group_order_article_#{goa1.id}") do
4.times { find('button[data-increment]').click } 4.times { find('button[data-increment]').click }
sleep 1
end end
expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done
expect(goa1.reload.result).to eq 7 expect(goa1.reload.result).to eq 7
expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 8 expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 8
end end

View file

@ -29,9 +29,10 @@ feature Order, js: true do
end end
it 'can create a new order' do it 'can create a new order' do
visit new_order_path(supplier_id: article.supplier.id) visit new_order_path(supplier_id: article.supplier_id)
expect(page).to have_text I18n.t('orders.new.title') expect(page).to have_text I18n.t('orders.new.title')
find('input[type="submit"]').click find('input[type="submit"]').click
expect(page).to have_selector('.alert-success')
expect(Order.count).to eq 1 expect(Order.count).to eq 1
expect(Order.first.supplier).to eq article.supplier expect(Order.first.supplier).to eq article.supplier
end end
@ -50,8 +51,7 @@ feature Order, js: true do
# and close the order # and close the order
visit orders_path visit orders_path
click_link_or_button I18n.t('orders.index.action_end') click_link_or_button I18n.t('orders.index.action_end')
accept_alert expect(page).to have_selector('.alert-success')
sleep 0.8
order.reload order.reload
oa.reload oa.reload
end end

View file

@ -6,29 +6,17 @@ require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'capybara/rails' require 'capybara/rails'
Capybara.javascript_driver = :webkit
# Requires supporting ruby files with custom matchers and macros, etc, # Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories. # in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config| RSpec.configure do |config|
# ## Mock Framework # We use capybara with webkit, and need database_cleaner
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
#config.use_transactional_fixtures = true
# We use capybara with selenium, and need database_cleaner
config.before(:each) do config.before(:each) do
DatabaseCleaner.strategy = (RSpec.current_example.metadata[:js] ? :truncation : :transaction) DatabaseCleaner.strategy = (RSpec.current_example.metadata[:js] ? :truncation : :transaction)
DatabaseCleaner.start DatabaseCleaner.start
# maximise window so that buttons can be found on popups
RSpec.current_example.metadata[:js] and page.driver.browser.manage.window.maximize
# clean slate mail queues, not sure why needed - https://github.com/rspec/rspec-rails/issues/661 # clean slate mail queues, not sure why needed - https://github.com/rspec/rspec-rails/issues/661
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
end end