Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding cucumber test for the general request form
- Loading branch information
Showing
27 changed files
with
433 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% | ||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | ||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | ||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" | ||
%> | ||
default: <%= std_opts %> features | ||
wip: --tags @wip:3 --wip features | ||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Feature: General requests | ||
In order to provide GDS with feedback | ||
As a government employee | ||
I want a means to contact GDS in the cases when my request does not covered by the other forms | ||
|
||
Background: | ||
* the following user has SSO access: | ||
| Name | Email | Job title | Organisation | | ||
| John Smith | john.smith@email.com | Developer | Cabinet Office | | ||
|
||
Scenario: successful request | ||
When the user submits the following general request: | ||
| Details | URL | | ||
| The site is down | http://www.gov.uk | | ||
Then the following ticket is raised in ZenDesk: | ||
| Subject | Requester email | Requester name | Job title | Organisation | | ||
| Govt Agency General Issue | john.smith@email.com | John Smith | Developer | cabinet_office | | ||
And the ticket is tagged with "govt_agency_general" | ||
And the comment on the ticket is: | ||
""" | ||
[Url] | ||
http://www.gov.uk | ||
[Additional] | ||
The site is down | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
When /^the user submits the following general request:$/ do |request_details_table| | ||
request_details = request_details_table.hashes.first | ||
|
||
visit '/' | ||
|
||
click_on "General" | ||
|
||
assert page.has_content?("Report a problem") | ||
|
||
fill_in "Name", :with => @user_details["Name"] | ||
fill_in "Email", :with => @user_details["Email"] | ||
fill_in "Job title", :with => @user_details["Job title"] | ||
select @user_details["Organisation"], :from => 'Organisation' | ||
|
||
fill_in "Details", :with => request_details['Details'] | ||
fill_in "URL (if applicable)", :with => request_details['URL'] | ||
|
||
click_on "Submit" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Given /^the following user has SSO access:$/ do |user_details| | ||
user = stub_everything('user', :name => "user", :has_permission? => true) | ||
@user_details = user_details.hashes.first | ||
|
||
login_as user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Then /^the following ticket is raised in ZenDesk:$/ do |ticket_properties_table| | ||
expected_ticket_props = ticket_properties_table.hashes.first | ||
@raised_ticket = @zendesk_api.ticket | ||
|
||
assert_equal expected_ticket_props["Subject"], @raised_ticket.subject | ||
assert_equal expected_ticket_props["Requester email"], @raised_ticket.email | ||
assert_equal expected_ticket_props["Requester name"], @raised_ticket.name | ||
assert_equal expected_ticket_props["Job title"], @raised_ticket.job | ||
assert_equal expected_ticket_props["Organisation"], @raised_ticket.organisation | ||
end | ||
|
||
Then /^the ticket is tagged with "(.*?)"$/ do |expected_tags| | ||
assert_equal expected_tags, @raised_ticket.tags.join(" ") | ||
end | ||
|
||
Then /^the comment on the ticket is:$/ do |expected_comment_string| | ||
assert_equal expected_comment_string, @raised_ticket.comment | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'capybara/poltergeist' | ||
|
||
Capybara.register_driver :rack_test do |app| | ||
Capybara::RackTest::Driver.new(app, :browser => :chrome) | ||
end | ||
Capybara.register_driver :poltergeist do |app| | ||
Capybara::Poltergeist::Driver.new(app, timeout: 5, debug: true) | ||
end | ||
Capybara.javascript_driver = :poltergeist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. | ||
# It is recommended to regenerate this file in the future when you upgrade to a | ||
# newer version of cucumber-rails. Consider adding your own code to a new file | ||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb | ||
# files. | ||
|
||
require 'cucumber/rails' | ||
|
||
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In | ||
# order to ease the transition to Capybara we set the default here. If you'd | ||
# prefer to use XPath just remove this line and adjust any selectors in your | ||
# steps to use the XPath syntax. | ||
Capybara.default_selector = :css | ||
|
||
# By default, any exception happening in your Rails application will bubble up | ||
# to Cucumber so that your scenario will fail. This is a different from how | ||
# your application behaves in the production environment, where an error page will | ||
# be rendered instead. | ||
# | ||
# Sometimes we want to override this default behaviour and allow Rails to rescue | ||
# exceptions and display an error page (just like when the app is running in production). | ||
# Typical scenarios where you want to do this is when you test your error pages. | ||
# There are two ways to allow Rails to rescue exceptions: | ||
# | ||
# 1) Tag your scenario (or feature) with @allow-rescue | ||
# | ||
# 2) Set the value below to true. Beware that doing this globally is not | ||
# recommended as it will mask a lot of errors for you! | ||
# | ||
ActionController::Base.allow_rescue = false | ||
|
||
# Remove/comment out the lines below if your app doesn't have a database. | ||
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. | ||
# begin | ||
# DatabaseCleaner.strategy = :transaction | ||
# rescue NameError | ||
# raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." | ||
# end | ||
|
||
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. | ||
# See the DatabaseCleaner documentation for details. Example: | ||
# | ||
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do | ||
# # { :except => [:widgets] } may not do what you expect here | ||
# # as tCucumber::Rails::Database.javascript_strategy overrides | ||
# # this setting. | ||
# DatabaseCleaner.strategy = :truncation | ||
# end | ||
# | ||
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do | ||
# DatabaseCleaner.strategy = :transaction | ||
# end | ||
# | ||
|
||
# Possible values are :truncation and :transaction | ||
# The :transaction strategy is faster, but might give you threading problems. | ||
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature | ||
Cucumber::Rails::Database.javascript_strategy = :truncation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "warden/test/helpers" | ||
|
||
module GdsSsoHelper | ||
def login_as(user) | ||
GDS::SSO.test_user = user | ||
end | ||
end | ||
|
||
World(GdsSsoHelper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Before do | ||
stub_zendesk_organisation_list | ||
stub_zendesk_ticket_submission | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'webmock/cucumber' | ||
|
||
WebMock.disable_net_connect!(:allow_localhost => true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require_relative '../../test/zendesk_organisation_list_helper' | ||
require_relative '../../test/zendesk_api_stubs' | ||
|
||
World(ZendeskOrganisationListHelper) | ||
World(ZendeskApiStubsHelper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. | ||
# It is recommended to regenerate this file in the future when you upgrade to a | ||
# newer version of cucumber-rails. Consider adding your own code to a new file | ||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb | ||
# files. | ||
|
||
|
||
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks | ||
|
||
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first | ||
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? | ||
|
||
begin | ||
require 'cucumber/rake/task' | ||
|
||
namespace :cucumber do | ||
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| | ||
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. | ||
t.fork = true # You may get faster startup if you set this to false | ||
t.profile = 'default' | ||
end | ||
|
||
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| | ||
t.binary = vendored_cucumber_bin | ||
t.fork = true # You may get faster startup if you set this to false | ||
t.profile = 'wip' | ||
end | ||
|
||
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t| | ||
t.binary = vendored_cucumber_bin | ||
t.fork = true # You may get faster startup if you set this to false | ||
t.profile = 'rerun' | ||
end | ||
|
||
desc 'Run all features' | ||
task :all => [:ok, :wip] | ||
|
||
task :statsetup do | ||
require 'rails/code_statistics' | ||
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') | ||
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') | ||
end | ||
end | ||
desc 'Alias for cucumber:ok' | ||
task :cucumber => 'cucumber:ok' | ||
|
||
task :default => :cucumber | ||
|
||
task :features => :cucumber do | ||
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" | ||
end | ||
|
||
# In case we don't have ActiveRecord, append a no-op task that we can depend upon. | ||
task 'db:test:prepare' do | ||
end | ||
|
||
task :stats => 'cucumber:statsetup' | ||
rescue LoadError | ||
desc 'cucumber rake task not available (cucumber not installed)' | ||
task :cucumber do | ||
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.