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

@ -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