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:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 && metacity --sm-disable --replace 2> metacity.err &
cache: bundler
bundler_args:
- "--without development --deployment --jobs=3 --retry=3"

View file

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

View file

@ -71,7 +71,8 @@ GEM
tzinfo (~> 1.1)
acts_as_tree (2.6.1)
activerecord (>= 3.0.0)
addressable (2.4.0)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.4)
attribute_normalizer (1.2.0)
base32 (0.3.2)
@ -101,15 +102,16 @@ GEM
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capybara (2.7.1)
capybara (2.13.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
capybara-webkit (1.14.0)
capybara (>= 2.3.0, < 2.14.0)
json
chronic (0.10.2)
coderay (1.1.1)
coffee-rails (4.1.1)
@ -159,7 +161,6 @@ GEM
railties (>= 3.0.0)
faker (1.7.3)
i18n (~> 0.5)
ffi (1.9.10)
gaffe (1.2.0)
rails (>= 4.0.0)
git-version-bump (0.15.1)
@ -199,7 +200,7 @@ GEM
interception (0.5)
iso (0.2.1)
i18n
jquery-rails (4.2.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
@ -269,6 +270,7 @@ GEM
pry-stack_explorer (0.4.9.2)
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
public_suffix (2.0.5)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.5)
@ -372,7 +374,7 @@ GEM
rspec (~> 3.0)
rspec-support (3.4.1)
ruby-filemagic (0.7.1)
ruby-ole (1.2.12)
ruby-ole (1.2.12.1)
ruby-prof (0.15.9)
ruby-units (2.0.0)
ruby_parser (3.8.2)
@ -387,10 +389,6 @@ GEM
tilt (>= 1.1, < 3)
select2-rails (4.0.3)
thor (~> 0.14)
selenium-webdriver (2.53.1)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
sexp_processor (4.7.0)
simple-navigation (3.14.0)
activesupport (>= 2.3.2)
@ -437,7 +435,7 @@ GEM
rack (>= 1.0.0)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.6)
tilt (2.0.7)
tins (1.13.2)
ttfunk (1.4.0)
twitter-bootstrap-rails (2.2.8)
@ -447,7 +445,7 @@ GEM
railties (>= 3.1)
twitter-text (1.13.4)
unf (~> 0.1.0)
tzinfo (1.2.2)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.1.3)
execjs (>= 0.3.0, < 3)
@ -462,7 +460,6 @@ GEM
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
websocket (1.2.3)
whenever (0.9.7)
chronic (>= 0.6.3)
wikicloth (0.8.3)
@ -490,6 +487,7 @@ DEPENDENCIES
capistrano-rails
capistrano-rvm
capybara
capybara-webkit
connection_pool
coveralls
daemons
@ -537,7 +535,6 @@ DEPENDENCIES
ruby-units
sass-rails
select2-rails
selenium-webdriver
simple-navigation (~> 3.14.0)
simple-navigation-bootstrap
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
within("#order_article_#{oa.id}") do
click_link I18n.t('ui.delete')
page.driver.browser.switch_to.alert.accept
end
expect(page).to_not have_selector("#order_article_#{oa.id}")
expect(OrderArticle.exists?(oa.id)).to be true
@ -70,7 +69,6 @@ feature 'settling an order', js: true do
goa2.destroy
within("#order_article_#{oa.id}") do
click_link I18n.t('ui.delete')
page.driver.browser.switch_to.alert.accept
end
expect(page).to_not have_selector("#order_article_#{oa.id}")
expect(OrderArticle.exists?(oa.id)).to be false
@ -146,10 +144,8 @@ feature 'settling an order', js: true do
click_link article.name
within("#group_order_articles_#{oa.id}") do
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
expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done
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
end
@ -158,8 +154,8 @@ feature 'settling an order', js: true do
click_link article.name
within("#group_order_article_#{goa1.id}") do
4.times { find('button[data-increment]').click }
sleep 1
end
expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done
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
end

View file

@ -29,9 +29,10 @@ feature Order, js: true do
end
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')
find('input[type="submit"]').click
expect(page).to have_selector('.alert-success')
expect(Order.count).to eq 1
expect(Order.first.supplier).to eq article.supplier
end
@ -50,8 +51,7 @@ feature Order, js: true do
# and close the order
visit orders_path
click_link_or_button I18n.t('orders.index.action_end')
accept_alert
sleep 0.8
expect(page).to have_selector('.alert-success')
order.reload
oa.reload
end

View file

@ -6,29 +6,17 @@ require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
Capybara.javascript_driver = :webkit
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
# ## Mock Framework
#
# 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
# We use capybara with webkit, and need database_cleaner
config.before(:each) do
DatabaseCleaner.strategy = (RSpec.current_example.metadata[:js] ? :truncation : :transaction)
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
ActionMailer::Base.deliveries.clear
end