spec/mri/unit/opal/rspec/browser_formatter_spec.rb in opal-rspec-0.6.0 vs spec/mri/unit/opal/rspec/browser_formatter_spec.rb in opal-rspec-0.6.1
- old
+ new
@@ -1,32 +1,26 @@
-require 'rspec'
-require 'capybara/rspec'
+require 'mri/spec_helper'
-# Use Rack config exactly as shipped in the GEM
-rack_path = File.join(File.dirname(__FILE__), 'rack/config.ru')
-Capybara.app = Rack::Builder.new_from_string(File.read(rack_path))
+RSpec.describe 'Opal::RSpec::BrowserFormatter', type: :feature, js: true do
+ # Use Rack config exactly as shipped in the GEM
+ before { Capybara.app = Rack::Builder.new_from_string(File.read("#{__dir__}/rack/config.ru")) }
-describe 'Opal::RSpec::BrowserFormatter', type: :feature do
- RSpec.shared_examples :browser do |driver, error_fetcher|
- context "in #{driver}", driver: driver do
- before do
- visit '/'
- # Specs should run in 12 seconds but in case Travis takes longer, provide some cushion
- Capybara.default_wait_time = 40
- end
+ let(:error_fetcher) { page.evaluate_script('window.jsErrors') }
- after do
- js_errors = error_fetcher[page]
- puts "Javascript errors: #{js_errors}" if js_errors.any?
- end
+ before do
+ visit '/'
+ # Specs should run in 12 seconds but in case Travis takes longer, provide some cushion
+ Capybara.default_max_wait_time = 40
+ end
- it 'matches test results' do
- expect(page).to have_content '3 examples, 1 failure, 1 pending'
- expect(page).to have_content 'group'
- expect(page).to have_content 'a skipped example'
- expect(page).to have_content 'a failed example'
- end
- end
+ after do
+ js_errors = error_fetcher
+ puts "Javascript errors: #{js_errors}" if js_errors.any?
end
- include_examples :browser, :selenium, lambda {|page| page.evaluate_script('window.jsErrors') }
+ it 'matches test results' do
+ expect(page).to have_content '3 examples, 1 failure, 1 pending'
+ expect(page).to have_content 'group'
+ expect(page).to have_content 'a skipped example'
+ expect(page).to have_content 'a failed example'
+ end
end