@@ -142,9 +142,10 @@ 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' |
| 147 |
+ gem 'launchy', require: false |
|
| 146 | 148 |
gem 'poltergeist' |
| 147 |
- gem 'capybara-select2', require: false |
|
| 148 | 149 |
gem 'pry-rails' |
| 149 | 150 |
gem 'rr' |
| 150 | 151 |
gem 'rspec', '~> 3.2' |
@@ -627,6 +627,7 @@ DEPENDENCIES |
||
| 627 | 627 |
jsonpath (~> 0.5.6) |
| 628 | 628 |
kaminari (~> 0.16.1) |
| 629 | 629 |
kramdown (~> 1.3.3) |
| 630 |
+ launchy |
|
| 630 | 631 |
letter_opener_web |
| 631 | 632 |
liquid (~> 3.0.3) |
| 632 | 633 |
listen (~> 3.0.5) |
@@ -2,16 +2,18 @@ require 'rails_helper' |
||
| 2 | 2 |
require 'capybara/rails' |
| 3 | 3 |
require 'capybara/poltergeist' |
| 4 | 4 |
require 'capybara-select2' |
| 5 |
+require 'helpers/capybara_poltergeist_screenshot' |
|
| 5 | 6 |
|
| 6 | 7 |
Capybara.register_driver :poltergeist do |app| |
| 7 |
- Capybara::Poltergeist::Driver.new(app, timeout: 60) |
|
| 8 |
+ Capybara::Poltergeist::Driver.new(app, timeout: 2) |
|
| 8 | 9 |
end |
| 9 | 10 |
|
| 10 | 11 |
Capybara.javascript_driver = :poltergeist |
| 11 |
-Capybara.default_max_wait_time = 60 |
|
| 12 |
+Capybara.default_max_wait_time = 2 |
|
| 12 | 13 |
|
| 13 | 14 |
RSpec.configure do |config| |
| 14 | 15 |
config.include Warden::Test::Helpers |
| 16 |
+ config.include Capybara::PoltergeistScreenshot |
|
| 15 | 17 |
config.before :suite do |
| 16 | 18 |
Warden.test_mode! |
| 17 | 19 |
end |
@@ -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 |
@@ -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 |
@@ -0,0 +1,12 @@ |
||
| 1 |
+require 'launchy' |
|
| 2 |
+ |
|
| 3 |
+module Capybara |
|
| 4 |
+ module PoltergeistScreenshot |
|
| 5 |
+ def screenshot_and_open_image(full: false) |
|
| 6 |
+ timestamp = Time.now.strftime('%Y-%m-%d-%H-%M-%S')
|
|
| 7 |
+ screenshot_path = "tmp/capybara/screenshot_#{timestamp}_#{SecureRandom.hex}.png"
|
|
| 8 |
+ page.save_screenshot(screenshot_path, full: full) |
|
| 9 |
+ Launchy.open screenshot_path |
|
| 10 |
+ end |
|
| 11 |
+ end |
|
| 12 |
+end |