cucumber-rails 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +194 -0
- data/History.txt +101 -1
- data/LICENSE +22 -0
- data/README.md +77 -0
- data/Rakefile +3 -19
- data/config/cucumber.yml +1 -0
- data/cucumber-rails.gemspec +37 -101
- data/dev_tasks/cucumber.rake +1 -1
- data/dev_tasks/rspec.rake +6 -11
- data/features/allow_rescue.feature +63 -0
- data/features/capybara_javascript_drivers.feature +87 -0
- data/features/database_cleaner.feature +44 -0
- data/features/emulate_javascript.feature +34 -0
- data/features/inspect_query_string.feature +37 -0
- data/features/install_cucumber_rails.feature +16 -0
- data/features/mongoid.feature +53 -0
- data/features/multiple_databases.feature +74 -0
- data/features/named_selectors.feature +33 -0
- data/features/no_database.feature +70 -0
- data/features/pseduo_class_selectors.feature +24 -0
- data/features/rerun_profile.feature +38 -0
- data/features/rest_api.feature +47 -0
- data/features/routing.feature +18 -0
- data/features/select_dates.feature +99 -0
- data/features/step_definitions/cucumber_rails_steps.rb +80 -6
- data/features/support/env.rb +8 -2
- data/features/test_unit.feature +43 -0
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +83 -0
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +50 -0
- data/lib/cucumber/rails/capybara.rb +6 -0
- data/lib/cucumber/rails/hooks/active_record.rb +14 -0
- data/lib/cucumber/rails/hooks/allow_rescue.rb +8 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +13 -0
- data/lib/cucumber/rails/hooks/mail.rb +5 -0
- data/lib/cucumber/rails/hooks.rb +4 -0
- data/lib/cucumber/rails/rspec.rb +4 -6
- data/lib/cucumber/rails/world.rb +13 -35
- data/lib/cucumber/rails.rb +8 -0
- data/lib/cucumber/rails3/action_controller.rb +12 -0
- data/lib/cucumber/rails3/active_record.rb +8 -0
- data/lib/cucumber/rails3/application.rb +17 -0
- data/lib/cucumber/rails3.rb +16 -0
- data/lib/cucumber/web/tableish.rb +50 -9
- data/lib/generators/cucumber/feature/feature_generator.rb +8 -17
- data/lib/generators/cucumber/feature/named_arg.rb +2 -0
- data/{templates/feature → lib/generators/cucumber/feature/templates}/feature.erb +10 -12
- data/{templates/feature → lib/generators/cucumber/feature/templates}/steps.erb +1 -1
- data/lib/generators/cucumber/install/USAGE +15 -0
- data/lib/generators/cucumber/install/install_generator.rb +88 -0
- data/lib/generators/cucumber/install/templates/config/cucumber.yml.erb +8 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb +192 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_cs.rb.erb +127 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_da.rb.erb +105 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_de.rb.erb +127 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_es.rb.erb +127 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ja.rb.erb +140 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ko.rb.erb +142 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_no.rb.erb +105 -0
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_pt-BR.rb.erb +132 -0
- data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +36 -0
- data/lib/generators/cucumber/install/templates/support/_rails_prefork.rb.erb +1 -0
- data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/capybara.rb +0 -4
- data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/paths.rb +11 -5
- data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/rails.rb.erb +2 -2
- data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/rails_spork.rb.erb +2 -2
- data/lib/generators/cucumber/install/templates/support/selectors.rb +39 -0
- data/lib/generators/cucumber/install/templates/support/web_steps_warning.txt +19 -0
- data/{templates/skeleton → lib/generators/cucumber/install/templates}/tasks/cucumber.rake.erb +18 -0
- data/spec/cucumber/web/tableish_spec.rb +83 -6
- data/spec/spec_helper.rb +1 -4
- metadata +299 -73
- data/HACKING.rdoc +0 -34
- data/README.rdoc +0 -64
- data/VERSION +0 -1
- data/features/rails2.feature +0 -56
- data/features/rails3.feature +0 -52
- data/features/support/matchers/files.rb +0 -17
- data/generators/cucumber/USAGE +0 -14
- data/generators/cucumber/cucumber_generator.rb +0 -89
- data/generators/cucumber/templates/step_definitions/web_steps_ja.rb.erb +0 -136
- data/generators/feature/USAGE +0 -12
- data/generators/feature/feature_generator.rb +0 -47
- data/lib/cucumber/rails/action_controller.rb +0 -65
- data/lib/cucumber/rails/active_record.rb +0 -34
- data/lib/cucumber/rails/capybara_javascript_emulation.rb +0 -72
- data/lib/cucumber/rails/test_unit.rb +0 -9
- data/lib/generators/cucumber/feature/feature_base.rb +0 -29
- data/lib/generators/cucumber/skeleton/USAGE +0 -21
- data/lib/generators/cucumber/skeleton/skeleton_base.rb +0 -202
- data/lib/generators/cucumber/skeleton/skeleton_generator.rb +0 -64
- data/rvm.yml +0 -22
- data/spec/generators/cucumber/skeleton/skeleton_base_spec.rb +0 -84
- data/spec/spec.opts +0 -2
- data/templates/skeleton/config/cucumber.yml.erb +0 -7
- data/templates/skeleton/environments/cucumber.rb.erb +0 -37
- data/templates/skeleton/step_definitions/capybara_steps.rb.erb +0 -197
- data/templates/skeleton/step_definitions/web_steps_cs.rb.erb +0 -136
- data/templates/skeleton/step_definitions/web_steps_da.rb.erb +0 -114
- data/templates/skeleton/step_definitions/web_steps_de.rb.erb +0 -136
- data/templates/skeleton/step_definitions/web_steps_es.rb.erb +0 -136
- data/templates/skeleton/step_definitions/web_steps_no.rb.erb +0 -114
- data/templates/skeleton/step_definitions/web_steps_pt-BR.rb.erb +0 -140
- data/templates/skeleton/step_definitions/webrat_steps.rb.erb +0 -268
- data/templates/skeleton/support/_rails_each_run.rb +0 -34
- data/templates/skeleton/support/_rails_prefork.rb.erb +0 -10
- data/templates/skeleton/support/webrat.rb +0 -8
- /data/{templates/skeleton → lib/generators/cucumber/install/templates}/script/cucumber +0 -0
- /data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/edit_warning.txt +0 -0
data/generators/cucumber/USAGE
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
Sets up Cucumber in your Rails project. After running this generator you will
|
|
3
|
-
get a new rake task called features.
|
|
4
|
-
|
|
5
|
-
This also generates the necessary files in the features directory.
|
|
6
|
-
|
|
7
|
-
Also see the feature generator, which you can use to generate skeletons
|
|
8
|
-
for new features.
|
|
9
|
-
|
|
10
|
-
Examples:
|
|
11
|
-
`./script/generate cucumber`
|
|
12
|
-
|
|
13
|
-
You can also provide a language argument for localized webrat_steps:
|
|
14
|
-
`./script/generate cucumber de`
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
require 'rbconfig'
|
|
2
|
-
require 'cucumber/platform'
|
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/skeleton/skeleton_base'))
|
|
4
|
-
|
|
5
|
-
# This generator bootstraps a Rails project for use with Cucumber
|
|
6
|
-
class CucumberGenerator < Rails::Generator::Base
|
|
7
|
-
|
|
8
|
-
include Cucumber::Generators::SkeletonBase
|
|
9
|
-
|
|
10
|
-
attr_accessor :driver
|
|
11
|
-
attr_accessor :framework
|
|
12
|
-
attr_reader :language, :template_dir
|
|
13
|
-
|
|
14
|
-
def initialize(runtime_args, runtime_options = {})
|
|
15
|
-
super
|
|
16
|
-
@language = @args.empty? ? 'en' : @args.first
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def manifest
|
|
20
|
-
record do |m|
|
|
21
|
-
check_upgrade_limitations
|
|
22
|
-
create_templates(m, true)
|
|
23
|
-
create_scripts(m, true)
|
|
24
|
-
create_step_definitions(m, true)
|
|
25
|
-
create_feature_support(m, true)
|
|
26
|
-
create_tasks(m, true)
|
|
27
|
-
create_database(m, true)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def framework
|
|
32
|
-
options[:framework] ||= detect_current_framework || detect_default_framework
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def driver
|
|
36
|
-
options[:driver] ||= detect_current_driver || detect_default_driver
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def cucumber_rails_env
|
|
40
|
-
'cucumber'
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def self.gem_root
|
|
44
|
-
File.expand_path('../../../', __FILE__)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def self.source_root
|
|
48
|
-
File.join(gem_root, 'templates', 'skeleton')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def source_root
|
|
52
|
-
self.class.source_root
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
private
|
|
56
|
-
|
|
57
|
-
def banner
|
|
58
|
-
"Usage: #{$0} cucumber (language)"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def after_generate
|
|
62
|
-
print_instructions
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def add_options!(opt)
|
|
66
|
-
opt.separator ''
|
|
67
|
-
opt.separator 'Options:'
|
|
68
|
-
opt.on('--webrat', 'Setup cucumber for use with webrat') do
|
|
69
|
-
options[:driver] = :webrat
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
opt.on('--capybara', 'Setup cucumber for use with capybara') do
|
|
73
|
-
options[:driver] = :capybara
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
opt.on('--rspec', "Setup cucumber for use with RSpec") do
|
|
77
|
-
options[:framework] = :rspec
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
opt.on('--testunit', "Setup cucumber for use with test/unit") do
|
|
81
|
-
options[:framework] = :testunit
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
opt.on('--spork', 'Setup cucumber for use with Spork') do
|
|
85
|
-
options[:spork] = true
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
<%= embed_file('support/edit_warning.txt') %>
|
|
3
|
-
|
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
|
5
|
-
|
|
6
|
-
Given /^"([^\"]*)"ページを表示している$/ do |page_name|
|
|
7
|
-
Given %{I am on #{page_name}}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
When /^"([^\"]*)"ページを表示する$/ do |page_name|
|
|
11
|
-
Given %{I go to #{page_name}}
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
When /^"([^\"]*)"ボタンをクリックする$/ do |button|
|
|
15
|
-
When %{I press "#{button}"}
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
When /^"([^\"]*)"リンクをクリックする$/ do |link|
|
|
19
|
-
When %{I follow "#{link}"}
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
When /^"([^\"]*)"の"([^\"]*)"リンクをクリックする$/ do |parent, link|
|
|
23
|
-
When %{I follow "#{link}" within "#{parent}"}
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
When /^"([^\"]*)"に"([^\"]*)"と入力する$/ do |field, value|
|
|
27
|
-
When %{I fill in "#{field}" with "#{value}"}
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
When /^以下の項目を入力する:$/ do |fields|
|
|
31
|
-
When %{I fill in the following:}, fields
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
When /^"([^\"]*)"から"([^\"]*)"を選択する$/ do |field, value|
|
|
35
|
-
When %{I select "#{value}" from "#{field}"}
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
When /^日時として"([^\"]*)"を選択する$/ do |time|
|
|
39
|
-
When %{I select "#{time}" as the date and time}
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
When /^"([^\"]*)"の日時として"([^\"]*)"を選択する$/ do |datetime_label, datetime|
|
|
43
|
-
When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
When /^時間として"([^\"]*)"を選択する$/ do |time|
|
|
47
|
-
When %{I select "#{time}" as the time}
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
When /^"([^\"]*)"の時間として"([^\"]*)"を選択する$/ do |time_label, time|
|
|
51
|
-
When %{I select "#{time}" as the "#{time_label}" time}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
When /^日付として"([^\"]*)"を選択する$/ do |date|
|
|
55
|
-
When %{I select "#{date}" as the date}
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
When /^"([^\"]*)"の日付として"([^\"]*)"を選択する$/ do |date_label, date|
|
|
59
|
-
When %{I select "#{date}" as the "#{date_label}" date}
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
When /^"([^\"]*)"をチェックする$/ do |field|
|
|
63
|
-
When %{I check "#{field}"}
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
When /^"([^\"]*)"のチェックを外す$/ do |field|
|
|
67
|
-
When %{I uncheck "#{field}"}
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
When /^"([^\"]*)"を選択する$/ do |field|
|
|
71
|
-
When %{I choose "#{field}"}
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
When /^"([^\"]*)"としてファイル"([^\"]*)"を選択する$/ do |field, path|
|
|
75
|
-
When %{I attach the file at "#{path}" to "#{field}"}
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
Then /^"([^\"]*)"と表示されていること$/ do |text|
|
|
79
|
-
Then %{I should see "#{text}"}
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
Then /^"([^\"]*)"に"([^\"]*)"と表示されていること$/ do |selector, text|
|
|
83
|
-
Then %{I should see "#{text}" within "#{selector}"}
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
Then /^\/([^\/]*)\/と表示されていること$/ do |regexp|
|
|
87
|
-
Then %{I should see /#{regexp}/}
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
Then /^"([^\"]*)"に\/([^\/]*)\/と表示されていること$/ do |selector, regexp|
|
|
91
|
-
Then %{I should see \/#{regexp}\/ within "#{selector}"}
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
Then /^"([^\"]*)"と表示されていないこと$/ do |text|
|
|
95
|
-
Then %{I should not see "#{text}"}
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
Then /^"([^\"]*)"に"([^\"]*)"と表示されていないこと$/ do |selector, text|
|
|
99
|
-
Then %{I should not see "#{text}" within "#{selector}"}
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
Then /^\/([^\/]*)\/と表示されていないこと$/ do |regexp|
|
|
103
|
-
Then %{I should not see /#{regexp}/}
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
Then /^"([^\"]*)"に\/([^\/]*)\/と表示されていないこと$/ do |selector, regexp|
|
|
107
|
-
Then %{I should not see \/#{regexp}\/ within "#{selector}"}
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
Then /^入力項目"([^\"]*)"に"([^\"]*)"と表示されていること$/ do |field, value|
|
|
111
|
-
Then %{the "#{field}" field should contain "#{value}"}
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
Then /^入力項目"([^\"]*)"に"([^\"]*)"と表示されていないこと$/ do |field, value|
|
|
115
|
-
Then %{the "#{field}" field should not contain "#{value}"}
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
Then /^"([^\"]*)"がチェックされていること$/ do |label|
|
|
119
|
-
Then %{the "#{label}" checkbox should be checked}
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
Then /^"([^\"]*)"がチェックされていないこと$/ do |label|
|
|
123
|
-
Then %{the "#{label}" checkbox should not be checked}
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
Then /^"([^\"]*)"ページを表示していること$/ do |page_name|
|
|
127
|
-
Then %{I should be on #{page_name}}
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
show_me_the_page = lambda { Then %{show me the page} }
|
|
131
|
-
Then /^ページを表示する$/, &show_me_the_page
|
|
132
|
-
Then /^画面を目視$/, &show_me_the_page
|
|
133
|
-
|
|
134
|
-
# backword-compat for old japanese translation.
|
|
135
|
-
Then /^デバッグ(?:のため)?$/, &show_me_the_page
|
|
136
|
-
|
data/generators/feature/USAGE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
Generates a skeleton for a new feature. Both a simple .feature file and
|
|
3
|
-
a steps.rb file is generated. This generator should be used with moderation.
|
|
4
|
-
See http://github.com/aslakhellesoy/cucumber/wikis/feature-coupled-steps-antipattern
|
|
5
|
-
for details about the dangers involved.
|
|
6
|
-
|
|
7
|
-
This generator can take an optional list of attribute pairs similar to Rails'
|
|
8
|
-
built-in resource generator.
|
|
9
|
-
|
|
10
|
-
Examples:
|
|
11
|
-
`./script/generate feature post` # no attributes
|
|
12
|
-
`./script/generate feature post title:string body:text published:boolean`
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/feature/named_arg')
|
|
2
|
-
require File.join(File.dirname(__FILE__), '../../lib/generators/cucumber/feature/feature_base')
|
|
3
|
-
|
|
4
|
-
# This generator generates a baic feature.
|
|
5
|
-
class FeatureGenerator < Rails::Generator::NamedBase
|
|
6
|
-
|
|
7
|
-
include Cucumber::Generators::FeatureBase
|
|
8
|
-
|
|
9
|
-
def manifest
|
|
10
|
-
record do |m|
|
|
11
|
-
create_directory(m, true)
|
|
12
|
-
create_feature_file(m)
|
|
13
|
-
create_steps_file(m)
|
|
14
|
-
create_support_file(m)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.gem_root
|
|
19
|
-
File.expand_path('../../../', __FILE__)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.source_root
|
|
23
|
-
File.join(gem_root, 'templates', 'feature')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def source_root
|
|
27
|
-
self.class.source_root
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def named_args
|
|
31
|
-
args.map { |arg| NamedArg.new(arg) }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def banner
|
|
37
|
-
"Usage: #{$0} feature ModelName [field:type, field:type]"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def add_options!(opt)
|
|
41
|
-
opt.separator ''
|
|
42
|
-
opt.separator 'Options:'
|
|
43
|
-
opt.on('--capybara=BACKEND', 'Generate a feature that uses a particular Capybara backend') do |backend|
|
|
44
|
-
options[:capybara] = backend
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
if Rails.version.to_f >= 3.0
|
|
2
|
-
module ActionController #:nodoc:
|
|
3
|
-
module AllowRescueException
|
|
4
|
-
extend ActiveSupport::Concern
|
|
5
|
-
include ActiveSupport::Rescuable
|
|
6
|
-
|
|
7
|
-
private
|
|
8
|
-
def process_action(*args)
|
|
9
|
-
if ActionController::Base.allow_rescue
|
|
10
|
-
super
|
|
11
|
-
else
|
|
12
|
-
begin
|
|
13
|
-
super
|
|
14
|
-
rescue Exception => exception
|
|
15
|
-
raise(exception)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
ActionController::Base.class_eval do
|
|
23
|
-
cattr_accessor :allow_rescue
|
|
24
|
-
include ActionController::AllowRescueException
|
|
25
|
-
end
|
|
26
|
-
else
|
|
27
|
-
ActionController::Base.class_eval do
|
|
28
|
-
cattr_accessor :allow_rescue
|
|
29
|
-
|
|
30
|
-
alias_method :rescue_action_without_bypass, :rescue_action
|
|
31
|
-
|
|
32
|
-
def rescue_action(exception)
|
|
33
|
-
if ActionController::Base.allow_rescue
|
|
34
|
-
rescue_action_without_bypass(exception)
|
|
35
|
-
else
|
|
36
|
-
raise exception
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
begin
|
|
43
|
-
ActionController::Failsafe.class_eval do
|
|
44
|
-
alias_method :failsafe_response_without_bypass, :failsafe_response
|
|
45
|
-
|
|
46
|
-
def failsafe_response(exception)
|
|
47
|
-
raise exception
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
rescue NameError # Failsafe was introduced in Rails 2.3.2
|
|
51
|
-
ActionController::Dispatcher.class_eval do
|
|
52
|
-
def self.failsafe_response(output, status, exception = nil)
|
|
53
|
-
raise exception
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
Before('@allow-rescue') do
|
|
59
|
-
@__orig_allow_rescue = ActionController::Base.allow_rescue
|
|
60
|
-
ActionController::Base.allow_rescue = true
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
After('@allow-rescue') do
|
|
64
|
-
ActionController::Base.allow_rescue = @__orig_allow_rescue
|
|
65
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
if defined?(ActiveRecord::Base)
|
|
2
|
-
Before do
|
|
3
|
-
$__cucumber_global_use_txn = !!Cucumber::Rails::World.use_transactional_fixtures if $__cucumber_global_use_txn.nil?
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
|
7
|
-
Cucumber::Rails::World.use_transactional_fixtures = $__cucumber_global_use_txn
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
|
11
|
-
Cucumber::Rails::World.use_transactional_fixtures = false
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
Before do
|
|
15
|
-
if Cucumber::Rails::World.use_transactional_fixtures
|
|
16
|
-
run_callbacks :setup if respond_to?(:run_callbacks)
|
|
17
|
-
else
|
|
18
|
-
DatabaseCleaner.start
|
|
19
|
-
end
|
|
20
|
-
ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
After do
|
|
24
|
-
if Cucumber::Rails::World.use_transactional_fixtures
|
|
25
|
-
run_callbacks :teardown if respond_to?(:run_callbacks)
|
|
26
|
-
else
|
|
27
|
-
DatabaseCleaner.clean
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
else
|
|
31
|
-
module Cucumber::Rails
|
|
32
|
-
def World.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
module Cucumber
|
|
2
|
-
module Rails
|
|
3
|
-
module CapybaraJavascriptEmulation
|
|
4
|
-
def self.included(base)
|
|
5
|
-
base.class_eval do
|
|
6
|
-
alias_method :click_without_javascript_emulation, :click
|
|
7
|
-
alias_method :click, :click_with_javascript_emulation
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def click_with_javascript_emulation
|
|
12
|
-
if link_with_non_get_http_method?
|
|
13
|
-
Capybara::Driver::RackTest::Form.new(driver, js_form(self[:href], emulated_method)).submit(self)
|
|
14
|
-
else
|
|
15
|
-
click_without_javascript_emulation
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def js_form(action, emulated_method, method = 'POST')
|
|
22
|
-
js_form = node.document.create_element('form')
|
|
23
|
-
js_form['action'] = action
|
|
24
|
-
js_form['method'] = method
|
|
25
|
-
|
|
26
|
-
if emulated_method and emulated_method.downcase != method.downcase
|
|
27
|
-
input = node.document.create_element('input')
|
|
28
|
-
input['type'] = 'hidden'
|
|
29
|
-
input['name'] = '_method'
|
|
30
|
-
input['value'] = emulated_method
|
|
31
|
-
js_form.add_child(input)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
js_form
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def link_with_non_get_http_method?
|
|
38
|
-
if ::Rails.version.to_f >= 3.0
|
|
39
|
-
tag_name == 'a' && node['data-method'] && node['data-method'] =~ /(?:delete|put|post)/
|
|
40
|
-
else
|
|
41
|
-
tag_name == 'a' && node['onclick'] && node['onclick'] =~ /var f = document\.createElement\('form'\); f\.style\.display = 'none';/
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def emulated_method
|
|
46
|
-
if ::Rails.version.to_f >= 3.0
|
|
47
|
-
node['data-method']
|
|
48
|
-
else
|
|
49
|
-
node['onclick'][/m\.setAttribute\('value', '([^']*)'\)/, 1]
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
class Capybara::Driver::RackTest::Node
|
|
57
|
-
include Cucumber::Rails::CapybaraJavascriptEmulation
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
|
61
|
-
# Enable javascript emulation
|
|
62
|
-
Capybara::Driver::RackTest::Node.class_eval do
|
|
63
|
-
alias_method :click, :click_with_javascript_emulation
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
|
68
|
-
# Disable javascript emulation
|
|
69
|
-
Capybara::Driver::RackTest::Node.class_eval do
|
|
70
|
-
alias_method :click, :click_without_javascript_emulation
|
|
71
|
-
end
|
|
72
|
-
end
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'test/unit/testresult'
|
|
3
|
-
rescue LoadError => e
|
|
4
|
-
e.message << "\nYou must gem install test-unit. For more info see https://rspec.lighthouseapp.com/projects/16211/tickets/292"
|
|
5
|
-
e.message << "\nAlso make sure you have rack 1.0.0 or higher."
|
|
6
|
-
raise e
|
|
7
|
-
end
|
|
8
|
-
# So that Test::Unit doesn't launch at the end - makes it think it has already been run.
|
|
9
|
-
Test::Unit.run = true if Test::Unit.respond_to?(:run=)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Cucumber
|
|
2
|
-
module Generators
|
|
3
|
-
module FeatureBase
|
|
4
|
-
|
|
5
|
-
def create_directory(m = self, rails2 = false)
|
|
6
|
-
if rails2
|
|
7
|
-
m.directory 'features/step_definitions'
|
|
8
|
-
else
|
|
9
|
-
m.empty_directory 'features/step_definitions'
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def create_feature_file(m = self)
|
|
14
|
-
m.template 'feature.erb', "features/manage_#{plural_name}.feature"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def create_steps_file(m = self)
|
|
18
|
-
m.template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def create_support_file(m = self)
|
|
22
|
-
m.gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
|
|
23
|
-
"#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
Sets up Cucumber in your Rails project. After running this generator you will
|
|
3
|
-
get a new rake task called features.
|
|
4
|
-
|
|
5
|
-
This also generates the necessary files in the features directory.
|
|
6
|
-
|
|
7
|
-
Also see the feature generator, which you can use to generate skeletons
|
|
8
|
-
for new features.
|
|
9
|
-
|
|
10
|
-
Examples (Rails 3):
|
|
11
|
-
`script/rails generate cucumber:skeleton`
|
|
12
|
-
|
|
13
|
-
You can also provide a language argument for localized webrat_steps:
|
|
14
|
-
`script/rails generate cucumber:skeleton de`
|
|
15
|
-
|
|
16
|
-
Examples (Rails 2):
|
|
17
|
-
`script/generate cucumber`
|
|
18
|
-
|
|
19
|
-
You can also provide a language argument for localized webrat_steps:
|
|
20
|
-
`script/generate cucumber de`
|
|
21
|
-
|