Skip to content

Commit

Permalink
Change driver to Poltergeist
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgibson committed Feb 2, 2017
1 parent c259e1b commit 700355c
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ gem "rake", "0.9.2.2"
gem "rspec", "2.11.0"
gem "minitest", "5.8.4"
gem "cucumber", "1.3.20"
gem "capybara", "~> 2.0"
gem "capybara-webkit", "~> 1.1"
gem "capybara", "~> 2.12.0"
gem "poltergeist", "1.13.0"

gem "rest-client", "1.6.7"
gem "nokogiri", "1.5.5"
22 changes: 14 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
builder (3.2.2)
capybara (2.10.1)
capybara (2.12.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.1.0)
capybara (~> 2.0, >= 2.0.2)
json
cliver (0.3.2)
cucumber (1.3.20)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
Expand All @@ -22,13 +21,17 @@ GEM
diff-lcs (1.1.3)
gherkin (2.12.2)
multi_json (~> 1.3)
json (2.0.3)
mime-types (2.99.3)
minitest (5.8.4)
multi_json (1.12.1)
multi_test (0.1.2)
nokogiri (1.5.5)
plek (1.11.0)
poltergeist (1.13.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
public_suffix (2.0.5)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
Expand All @@ -43,19 +46,22 @@ GEM
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara (~> 2.0)
capybara-webkit (~> 1.1)
capybara (~> 2.12.0)
cucumber (= 1.3.20)
minitest (= 5.8.4)
nokogiri (= 1.5.5)
plek (= 1.11.0)
poltergeist (= 1.13.0)
rake (= 0.9.2.2)
rest-client (= 1.6.7)
rspec (= 2.11.0)
Expand Down
3 changes: 2 additions & 1 deletion features/calendars.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ Feature: Calendars

@normal
Scenario: check bank holidays JSON format is consistent
When I visit "/bank-holidays.json"
Given I am testing through the full stack
When I request "/bank-holidays.json"
Then JSON is returned
2 changes: 1 addition & 1 deletion features/frontend.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Feature: Frontend
@normal
Scenario: check campaign pages load
When I visit "/workplacepensions"
Then I should get a 200 status code
Then I should be at a location path of "/workplace-pensions"

@normal
Scenario: check browse page load, and links
Expand Down
5 changes: 5 additions & 0 deletions features/javascript_errors.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Smokey Javascript Error detection

@normal
Scenario: Smokey detects JS errors
When I inject a JavaScript error on the page, Smokey raises an exception
2 changes: 1 addition & 1 deletion features/step_definitions/calendar_steps.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'json'

Then /^JSON is returned$/ do
JSON.parse(page.body).class.should == Hash
JSON.parse(@response.body).class.should == Hash
end
11 changes: 10 additions & 1 deletion features/step_definitions/smokey_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ def should_see(text)
end

Then /^I should be at a location path of "(.*)"$/ do |location_path|
@response['location'].should == "#{@host}#{location_path}"
url = "#{@host}#{location_path}"
if @response
@response['location'].should == url
else
page.current_url.should == url
end
end

When /^I click "(.*?)"$/ do |link_text|
Expand Down Expand Up @@ -203,3 +208,7 @@ def random_path_selection(opts={})
anchor_tags = opts[:anchor_tags] || []
anchor_tags.map { |anchor| anchor.attributes["href"].value }.sample(size)
end

When /^I inject a JavaScript error on the page, Smokey raises an exception$/ do
expect { page.driver.execute_script('1.error') }.to raise_error
end
4 changes: 2 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'nokogiri'
require 'capybara/cucumber'
require 'capybara/webkit'
require 'capybara/poltergeist'
require 'uri'
require 'plek'

Expand All @@ -14,5 +14,5 @@
ENV["EXPECTED_GOVUK_WEBSITE_ROOT"] = 'https://www.gov.uk'
end

Capybara.default_driver = :webkit
Capybara.app_host = ENV["GOVUK_WEBSITE_ROOT"]
Capybara.default_driver = :poltergeist
2 changes: 1 addition & 1 deletion features/support/mechanize.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Before do
if ENV['RATE_LIMIT_TOKEN']
page.driver.header 'Rate-Limit-Token', ENV['RATE_LIMIT_TOKEN']
page.driver.add_headers 'Rate-Limit-Token' => ENV['RATE_LIMIT_TOKEN']
end
end
7 changes: 1 addition & 6 deletions features/support/visiting_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

def visit_path(path)
if ENV['AUTH_USERNAME'] && ENV['AUTH_PASSWORD']
auth_string = Base64.encode64("#{ENV['AUTH_USERNAME']}:#{ENV['AUTH_PASSWORD']}").strip
page.driver.header "Authorization", "Basic #{auth_string}"
page.driver.basic_authorize(ENV['AUTH_USERNAME'], ENV['AUTH_PASSWORD'])
end

if path.match(%r[\?])
visit "#{path}&cachebust=#{rand.to_s}"
else
visit "#{path}?cachebust=#{rand.to_s}"
end

page.driver.error_messages.should == []
end

def visit_without_auth(path)
Expand All @@ -21,6 +18,4 @@ def visit_without_auth(path)
else
visit "#{path}?cachebust=#{rand.to_s}"
end

page.driver.error_messages.should == []
end
10 changes: 0 additions & 10 deletions features/whitehall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,3 @@ Feature: Whitehall
When I visit "/government/statistics/announcements"
Then I should get a 200 status code
And the elapsed time should be less than 2 seconds

# Speak to David Illsley or Neil Williams before editing this test
@high
Scenario: Banknote feature works
Given I am testing through the full stack
And I force a varnish cache miss
And I am benchmarking
When I visit "/banknote"
# Redirects are transparently followed, so the end status code is 200
Then I should get a 200 status code

0 comments on commit 700355c

Please sign in to comment.