Merge pull request #1435 from omniscopeio/capybara-stability

Improves wait time when writing test you expect to fail

Dominik Sander 8 years ago
parent
commit
dd76553662
4 changed files with 10 additions and 8 deletions
  1. 1 1
      Gemfile
  2. 4 2
      spec/capybara_helper.rb
  3. 4 4
      spec/features/admin_users_spec.rb
  4. 1 1
      spec/features/create_an_agent_spec.rb

+ 1 - 1
Gemfile

@@ -142,9 +142,9 @@ group :development do
142 142
 
143 143
   group :test do
144 144
     gem 'coveralls', require: false
145
+    gem 'capybara-select2', require: false
145 146
     gem 'delorean'
146 147
     gem 'poltergeist'
147
-    gem 'capybara-select2', require: false
148 148
     gem 'pry-rails'
149 149
     gem 'rr'
150 150
     gem 'rspec', '~> 3.2'

+ 4 - 2
spec/capybara_helper.rb

@@ -3,12 +3,14 @@ require 'capybara/rails'
3 3
 require 'capybara/poltergeist'
4 4
 require 'capybara-select2'
5 5
 
6
+CAPYBARA_TIMEOUT = ENV['CI'] == 'true' ? 60 : 5
7
+
6 8
 Capybara.register_driver :poltergeist do |app|
7
-  Capybara::Poltergeist::Driver.new(app, timeout: 60)
9
+  Capybara::Poltergeist::Driver.new(app, timeout: CAPYBARA_TIMEOUT)
8 10
 end
9 11
 
10 12
 Capybara.javascript_driver = :poltergeist
11
-Capybara.default_max_wait_time = 60
13
+Capybara.default_max_wait_time = CAPYBARA_TIMEOUT
12 14
 
13 15
 RSpec.configure do |config|
14 16
   config.include Warden::Test::Helpers

+ 4 - 4
spec/features/admin_users_spec.rb

@@ -22,7 +22,7 @@ describe Admin::UsersController do
22 22
       visit admin_users_path
23 23
       find(:css, "a[href='/admin/users/#{users(:bob).id}']").click
24 24
       expect(page).to have_text("User 'bob' was deleted.")
25
-      expect(page).not_to have_text('bob@example.com')
25
+      expect(page).to have_no_text('bob@example.com')
26 26
     end
27 27
 
28 28
     context "creating new users" do
@@ -82,12 +82,12 @@ describe Admin::UsersController do
82 82
     context "(de)activating users" do
83 83
       it "does not show deactivation buttons for the current user" do
84 84
         visit admin_users_path
85
-        expect(page).not_to have_css("a[href='/admin/users/#{users(:jane).id}/deactivate']")
85
+        expect(page).to have_no_css("a[href='/admin/users/#{users(:jane).id}/deactivate']")
86 86
       end
87 87
 
88 88
       it "deactivates an existing user" do
89 89
         visit admin_users_path
90
-        expect(page).not_to have_text('inactive')
90
+        expect(page).to have_no_text('inactive')
91 91
         find(:css, "a[href='/admin/users/#{users(:bob).id}/deactivate']").click
92 92
         expect(page).to have_text('inactive')
93 93
         users(:bob).reload
@@ -98,7 +98,7 @@ describe Admin::UsersController do
98 98
         users(:bob).deactivate!
99 99
         visit admin_users_path
100 100
         find(:css, "a[href='/admin/users/#{users(:bob).id}/activate']").click
101
-        expect(page).not_to have_text('inactive')
101
+        expect(page).to have_no_text('inactive')
102 102
         users(:bob).reload
103 103
         expect(users(:bob)).to be_active
104 104
       end

+ 1 - 1
spec/features/create_an_agent_spec.rb

@@ -13,4 +13,4 @@ describe "Creating a new agent", js: true do
13 13
 
14 14
     expect(page).to have_text("Test Trigger Agent")
15 15
   end
16
-end
16
+end