Skip to content

Commit e2f5321

Browse files
committed
initializes cucumber
1 parent e429a68 commit e2f5321

File tree

8 files changed

+207
-1
lines changed

8 files changed

+207
-1
lines changed

Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ gem 'es6-rails'
3232
# Use Capistrano for deployment
3333
# gem 'capistrano-rails', group: :development
3434

35+
group :test do
36+
gem 'cucumber-rails', '~> 1.4.3', require: false
37+
gem 'capybara-webkit', '~> 1.11.1'
38+
gem 'poltergeist', '~> 1.9.0'
39+
end
40+
3541
group :development, :test do
3642
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
3743
gem 'byebug'

Gemfile.lock

+45
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ GEM
3636
minitest (~> 5.1)
3737
thread_safe (~> 0.3, >= 0.3.4)
3838
tzinfo (~> 1.1)
39+
addressable (2.4.0)
3940
arel (6.0.3)
4041
babel-source (5.8.26)
4142
babel-transpiler (0.7.0)
@@ -45,6 +46,17 @@ GEM
4546
debug_inspector (>= 0.0.1)
4647
builder (3.2.2)
4748
byebug (9.0.0)
49+
capybara (2.7.1)
50+
addressable
51+
mime-types (>= 1.16)
52+
nokogiri (>= 1.3.3)
53+
rack (>= 1.0.0)
54+
rack-test (>= 0.5.4)
55+
xpath (~> 2.0)
56+
capybara-webkit (1.11.1)
57+
capybara (>= 2.3.0, < 2.8.0)
58+
json
59+
cliver (0.3.2)
4860
coffee-rails (4.1.1)
4961
coffee-script (>= 2.2.0)
5062
railties (>= 4.0.0, < 5.1.x)
@@ -53,14 +65,33 @@ GEM
5365
execjs
5466
coffee-script-source (1.10.0)
5567
concurrent-ruby (1.0.2)
68+
cucumber (2.3.3)
69+
builder (>= 2.1.2)
70+
cucumber-core (~> 1.4.0)
71+
cucumber-wire (~> 0.0.1)
72+
diff-lcs (>= 1.1.3)
73+
gherkin (~> 3.2.0)
74+
multi_json (>= 1.7.5, < 2.0)
75+
multi_test (>= 0.1.2)
76+
cucumber-core (1.4.0)
77+
gherkin (~> 3.2.0)
78+
cucumber-rails (1.4.3)
79+
capybara (>= 1.1.2, < 3)
80+
cucumber (>= 1.3.8, < 3)
81+
mime-types (>= 1.16, < 4)
82+
nokogiri (~> 1.5)
83+
railties (>= 3, < 5)
84+
cucumber-wire (0.0.1)
5685
debug_inspector (0.0.2)
86+
diff-lcs (1.2.5)
5787
erubis (2.7.0)
5888
es6-rails (0.1.0)
5989
babel-transpiler (~> 0.7, >= 0.7.0)
6090
rails (>= 4.0, < 5.0)
6191
sprockets (~> 3.0, >= 3.0.0)
6292
sprockets-es6 (~> 0.8, >= 0.8.1)
6393
execjs (2.6.0)
94+
gherkin (3.2.0)
6495
globalid (0.3.6)
6596
activesupport (>= 4.1.0)
6697
i18n (0.7.0)
@@ -82,8 +113,14 @@ GEM
82113
mini_portile2 (2.0.0)
83114
minitest (5.8.4)
84115
multi_json (1.12.0)
116+
multi_test (0.1.2)
85117
nokogiri (1.6.7.2)
86118
mini_portile2 (~> 2.0.0.rc2)
119+
poltergeist (1.9.0)
120+
capybara (~> 2.1)
121+
cliver (~> 0.3.1)
122+
multi_json (~> 1.0)
123+
websocket-driver (>= 0.2.0)
87124
rack (1.6.4)
88125
rack-test (0.6.3)
89126
rack (>= 1.0)
@@ -149,16 +186,24 @@ GEM
149186
binding_of_caller (>= 0.7.2)
150187
railties (>= 4.0)
151188
sprockets-rails (>= 2.0, < 4.0)
189+
websocket-driver (0.6.3)
190+
websocket-extensions (>= 0.1.0)
191+
websocket-extensions (0.1.2)
192+
xpath (2.0.0)
193+
nokogiri (~> 1.3)
152194

153195
PLATFORMS
154196
ruby
155197

156198
DEPENDENCIES
157199
byebug
200+
capybara-webkit (~> 1.11.1)
158201
coffee-rails (~> 4.1.0)
202+
cucumber-rails (~> 1.4.3)
159203
es6-rails
160204
jbuilder (~> 2.0)
161205
jquery-rails
206+
poltergeist (~> 1.9.0)
162207
rails (= 4.2.4)
163208
sass-rails (~> 5.0)
164209
sdoc (~> 0.4.0)

config/cucumber.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<%
2+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5+
%>
6+
default: <%= std_opts %> features
7+
wip: --tags @wip:3 --wip features
8+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip

config/database.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ development:
1616
# Warning: The database defined as "test" will be erased and
1717
# re-generated from your development database when you run "rake".
1818
# Do not set this db to the same as development or production.
19-
test:
19+
test: &test
2020
<<: *default
2121
database: db/test.sqlite3
2222

2323
production:
2424
<<: *default
2525
database: db/production.sqlite3
26+
27+
cucumber:
28+
<<: *test

features/step_definitions/.gitkeep

Whitespace-only changes.

features/support/env.rb

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2+
# It is recommended to regenerate this file in the future when you upgrade to a
3+
# newer version of cucumber-rails. Consider adding your own code to a new file
4+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
5+
# files.
6+
7+
require 'cucumber/rails'
8+
9+
# Capybara defaults to CSS3 selectors rather than XPath.
10+
# If you'd prefer to use XPath, just uncomment this line and adjust any
11+
# selectors in your step definitions to use the XPath syntax.
12+
# Capybara.default_selector = :xpath
13+
14+
# By default, any exception happening in your Rails application will bubble up
15+
# to Cucumber so that your scenario will fail. This is a different from how
16+
# your application behaves in the production environment, where an error page will
17+
# be rendered instead.
18+
#
19+
# Sometimes we want to override this default behaviour and allow Rails to rescue
20+
# exceptions and display an error page (just like when the app is running in production).
21+
# Typical scenarios where you want to do this is when you test your error pages.
22+
# There are two ways to allow Rails to rescue exceptions:
23+
#
24+
# 1) Tag your scenario (or feature) with @allow-rescue
25+
#
26+
# 2) Set the value below to true. Beware that doing this globally is not
27+
# recommended as it will mask a lot of errors for you!
28+
#
29+
ActionController::Base.allow_rescue = false
30+
31+
# Remove/comment out the lines below if your app doesn't have a database.
32+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
33+
begin
34+
DatabaseCleaner.strategy = :transaction
35+
rescue NameError
36+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
37+
end
38+
39+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
40+
# See the DatabaseCleaner documentation for details. Example:
41+
#
42+
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
43+
# # { :except => [:widgets] } may not do what you expect here
44+
# # as Cucumber::Rails::Database.javascript_strategy overrides
45+
# # this setting.
46+
# DatabaseCleaner.strategy = :truncation
47+
# end
48+
#
49+
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
50+
# DatabaseCleaner.strategy = :transaction
51+
# end
52+
#
53+
54+
# Possible values are :truncation and :transaction
55+
# The :transaction strategy is faster, but might give you threading problems.
56+
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
57+
Cucumber::Rails::Database.javascript_strategy = :truncation
58+

lib/tasks/cucumber.rake

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2+
# It is recommended to regenerate this file in the future when you upgrade to a
3+
# newer version of cucumber-rails. Consider adding your own code to a new file
4+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
5+
# files.
6+
7+
8+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9+
10+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12+
13+
begin
14+
require 'cucumber/rake/task'
15+
16+
namespace :cucumber do
17+
Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
18+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19+
t.fork = true # You may get faster startup if you set this to false
20+
t.profile = 'default'
21+
end
22+
23+
Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
24+
t.binary = vendored_cucumber_bin
25+
t.fork = true # You may get faster startup if you set this to false
26+
t.profile = 'wip'
27+
end
28+
29+
Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30+
t.binary = vendored_cucumber_bin
31+
t.fork = true # You may get faster startup if you set this to false
32+
t.profile = 'rerun'
33+
end
34+
35+
desc 'Run all features'
36+
task :all => [:ok, :wip]
37+
38+
task :statsetup do
39+
require 'rails/code_statistics'
40+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
41+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
42+
end
43+
44+
task :annotations_setup do
45+
Rails.application.configure do
46+
if config.respond_to?(:annotations)
47+
config.annotations.directories << 'features'
48+
config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
49+
end
50+
end
51+
end
52+
end
53+
desc 'Alias for cucumber:ok'
54+
task :cucumber => 'cucumber:ok'
55+
56+
task :default => :cucumber
57+
58+
task :features => :cucumber do
59+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
60+
end
61+
62+
# In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
63+
task 'test:prepare' do
64+
end
65+
66+
task :stats => 'cucumber:statsetup'
67+
68+
task :notes => 'cucumber:annotations_setup'
69+
rescue LoadError
70+
desc 'cucumber rake task not available (cucumber not installed)'
71+
task :cucumber do
72+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
73+
end
74+
end
75+
76+
end

script/cucumber

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env ruby
2+
3+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4+
if vendored_cucumber_bin
5+
load File.expand_path(vendored_cucumber_bin)
6+
else
7+
require 'rubygems' unless ENV['NO_RUBYGEMS']
8+
require 'cucumber'
9+
load Cucumber::BINARY
10+
end

0 commit comments

Comments
 (0)