Skip to content

Commit 49fa422

Browse files
committed
Replace poltergeist with apparition; fix failing tests
1 parent c8bd9c3 commit 49fa422

File tree

8 files changed

+56
-101
lines changed

8 files changed

+56
-101
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ before_script:
1414
- npm install
1515
- cp config/database.yml.travis config/database.yml
1616
- psql -c 'create database travis_ci_test;' -U postgres
17-
- RAILS_ENV=test bundle exec rails webdrivers:chromedriver:update
17+
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
1818
script:
1919
- bundle exec rubocop
2020
- $(npm bin)/sass-lint -vq

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ group :development do
111111
end
112112

113113
group :test do
114+
gem "apparition", "~> 0.6"
114115
gem "webmock", "~> 2"
115116
end
116117

@@ -120,13 +121,11 @@ group :development, :test do
120121
gem "cucumber-rails", "1.6.0", require: false
121122
gem "database_cleaner", "~> 1"
122123
gem "factory_girl_rails", "~> 4"
123-
gem "poltergeist", "~> 1"
124124
gem "rails-controller-testing"
125125
gem "rspec-core", "~> 3"
126126
gem "rspec-rails", "~> 3"
127127
gem "rubocop", "0.52.0"
128128
gem "rubocop-github", "0.9.0"
129-
gem "selenium-webdriver", "~> 3"
130129
gem "webdrivers", "~> 4"
131130
end
132131

Gemfile.lock

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ GEM
6969
safely_block (>= 0.1.1)
7070
user_agent_parser
7171
uuidtools
72+
apparition (0.6.0)
73+
capybara (~> 3.13, < 4)
74+
websocket-driver (>= 0.6.5)
7275
arel (7.1.4)
7376
ast (2.4.0)
7477
autoprefixer-rails (9.5.1)
@@ -122,7 +125,6 @@ GEM
122125
rake (< 13.0)
123126
chronic (0.10.2)
124127
climate_control (0.2.0)
125-
cliver (0.3.2)
126128
cocoon (1.2.12)
127129
coderay (1.1.2)
128130
concurrent-ruby (1.1.5)
@@ -275,10 +277,6 @@ GEM
275277
pg_search (2.1.7)
276278
activerecord (>= 4.2)
277279
activesupport (>= 4.2)
278-
poltergeist (1.18.1)
279-
capybara (>= 2.1, < 4)
280-
cliver (~> 0.3.1)
281-
websocket-driver (>= 0.2.0)
282280
powerpack (0.1.2)
283281
premailer (1.11.1)
284282
addressable
@@ -484,6 +482,7 @@ DEPENDENCIES
484482
activerecord-session_store (~> 1)
485483
acts_as_paranoid!
486484
ahoy_matey (~> 1.6)
485+
apparition (~> 0.6)
487486
aws-sdk (~> 2.3)
488487
aws-sdk-rails (~> 1)
489488
better_errors (~> 2)
@@ -524,7 +523,6 @@ DEPENDENCIES
524523
paperclip (~> 5.2)
525524
pg (~> 1.1)
526525
pg_search
527-
poltergeist (~> 1)
528526
premailer-rails (~> 1)
529527
puma (~> 3)
530528
rack-attack (~> 5)
@@ -561,7 +559,6 @@ DEPENDENCIES
561559
sass-rails (~> 5.0)
562560
sdoc
563561
select2-rails
564-
selenium-webdriver (~> 3)
565562
sentry-raven (~> 0.15)
566563
sprockets-image_compressor (~> 0)
567564
uglifier (>= 1.3.0)

spec/features/action_pages/tweet_action_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@
2626

2727
it "allows vistors to tweet at representatives" do
2828
visit action_page_path(tweet_action)
29-
3029
expect(page).not_to have_content("THANK YOU!")
3130
fill_in "street_address", with: "1630 Ravello Drive"
3231
fill_in "zipcode", with: "94109"
3332
click_on "Look up your reps"
34-
35-
expect(page).to have_content("Default message")
3633
click_on "Tweet @sisko"
37-
3834
expect(page).to have_content("THANK YOU!")
3935
end
4036
end

spec/features/admin/action_creation_spec.rb

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
fill_in_basic_info(title: "Very Important Action",
99
summary: "A summary",
1010
description: "A description")
11-
click_on "Next"
11+
next_section
1212

1313
select_action_type("tweet")
1414
fill_in "Message", with: "A message"
15-
click_on "Next"
15+
next_section
16+
17+
# skip banner selection
18+
next_section
1619

17-
skip_image_selection
1820
fill_in_social_media
19-
# Skip partners
20-
click_on "Next"
2121

2222
tempermental {
2323
click_button "Save"
@@ -30,18 +30,18 @@
3030
fill_in_basic_info(title: "Very Important Action",
3131
summary: "A summary",
3232
description: "A description")
33-
click_on "Next"
33+
next_section
3434

3535
select_action_type("petition")
3636
fill_in_editor "#action_page_petition_attributes_description",
3737
with: "A petititon letter"
3838
fill_in "Goal", with: 1000
39-
click_on "Next"
39+
next_section
40+
41+
# skip banner selection
42+
next_section
4043

41-
skip_image_selection
4244
fill_in_social_media
43-
# Skip partners
44-
click_on "Next"
4545

4646
tempermental {
4747
click_button "Save"
@@ -54,18 +54,18 @@
5454
fill_in_basic_info(title: "Very Important Action",
5555
summary: "A summary",
5656
description: "A description")
57-
click_on "Next"
57+
next_section
5858

5959
select_action_type("email")
6060
fill_in "To", with: "[email protected]"
6161
fill_in "Subject", with: "Subject"
6262
fill_in "Message", with: "An email"
63-
click_on "Next"
63+
next_section
64+
65+
# skip banner selection
66+
next_section
6467

65-
skip_image_selection
6668
fill_in_social_media
67-
# Skip partners
68-
click_on "Next"
6969

7070
tempermental {
7171
click_button "Save"
@@ -78,17 +78,17 @@
7878
fill_in_basic_info(title: "Very Important Action",
7979
summary: "A summary",
8080
description: "A description")
81-
click_on "Next"
81+
next_section
8282

8383
select_action_type("congress_message")
8484
fill_in "Subject", with: "Subject"
8585
fill_in "Message", with: "A message"
86-
click_on "Next"
86+
next_section
87+
88+
# skip banner selection
89+
next_section
8790

88-
skip_image_selection
8991
fill_in_social_media
90-
# Skip partners
91-
click_on "Next"
9292

9393
tempermental {
9494
click_button "Save"
@@ -101,17 +101,17 @@
101101
fill_in_basic_info(title: "Very Important Action",
102102
summary: "A summary",
103103
description: "A description")
104-
click_on "Next"
104+
next_section
105105

106106
select_action_type "call"
107107
fill_in_editor "#action_page_call_campaign_attributes_message",
108108
with: "Call script"
109-
click_on "Next"
109+
next_section
110+
111+
# skip banner selection
112+
next_section
110113

111-
skip_image_selection
112114
fill_in_social_media
113-
# Skip partners
114-
click_on "Next"
115115

116116
tempermental {
117117
click_button "Save"
@@ -126,17 +126,15 @@ def fill_in_basic_info(title:, summary:, description:)
126126
fill_in_select2 "#action_page_category_id", with: category.title
127127
end
128128

129-
def skip_image_selection
129+
def next_section
130130
click_on "Next"
131-
sleep 0.1
132-
click_on "Next"
133-
sleep 0.1
131+
sleep 0.05
134132
end
135133

136134
def fill_in_social_media
137135
fill_in "Share Message", with: "Twitter message"
138136
fill_in "Title", with: "A social media title"
139-
click_on "Next"
137+
next_section
140138
end
141139

142140
def select_action_type(type)

spec/features/users_spec.rb

Lines changed: 0 additions & 40 deletions
This file was deleted.

spec/rails_helper.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
abort("The Rails environment is running in production mode!") if Rails.env.production?
66
require "spec_helper"
77
require "rspec/rails"
8-
require "selenium/webdriver"
9-
require "webdrivers"
8+
require "capybara/apparition"
109

1110
# Add additional requires below this line. Rails is not loaded until this point!
1211

@@ -30,24 +29,25 @@
3029
ActiveRecord::Migration.maintain_test_schema!
3130

3231

33-
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
34-
:loggingPrefs => {
35-
browser: "ALL",
36-
client: "ALL",
37-
driver: "ALL",
38-
server: "ALL"
39-
},
40-
"chromeOptions" => {
32+
apparition_opts = {
33+
window_size: [1400, 900],
34+
screen_size: [1920, 1090],
35+
browser_options: {
4136
"w3c" => false,
42-
"args" => ["headless", "disable-gpu", "--window-size=1400,900"].tap do |a|
43-
a.push("no-sandbox") if ENV["TRAVIS"]
44-
end
37+
"args" => ["headless", "disable-gpu", "--window-size=1400,900"]
4538
}
46-
)
39+
}
40+
41+
if ENV["TRAVIS"]
42+
apparition_opts[:browser_options] = {
43+
"remote-debugging-address" => "127.0.0.1",
44+
"remote-debugging-port" => 9222
45+
}
46+
apparition_opts[:remote] = true
47+
end
4748

4849
Capybara.register_driver :chrome_headless do |app|
49-
Capybara::Selenium::Driver.new(app, browser: :chrome,
50-
desired_capabilities: capabilities)
50+
Capybara::Apparition::Driver.new(app, apparition_opts)
5151
end
5252

5353
Capybara.server = :puma

spec/support/feature_helpers.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ def sign_in_user(user)
77
click_button "Sign in"
88
end
99

10+
def sign_out_user(user)
11+
find("#nav-modal-toggle").click
12+
find("input[value='Logout']", visible: :all, match: :first).click
13+
end
14+
1015
def disable_call_tool
1116
allow(CallTool).to receive(:enabled?).and_return(false)
1217
end
1318

1419
def fill_in_editor(locator, with:)
1520
within_frame find(locator, visible: :all).sibling("div").find("iframe") do
16-
within_frame find("iframe") do
21+
within_frame find("#epiceditor-editor-frame") do
1722
find("body").set(with)
1823
end
1924
end

0 commit comments

Comments
 (0)