cucumber_rails3_gen 0.1.1 → 0.1.2
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/VERSION +1 -1
- data/bin/cucumber_skeleton +1 -1
- data/lib/generators/cucumber/skeleton/skeleton_generator.rb +141 -144
- data/lib/generators/cucumber/skeleton/templates/step_definitions/capybara_steps.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_cs.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_da.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_de.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_es.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_ja.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_no.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/web_steps_pt-BR.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/step_definitions/webrat_steps.rb.erb +1 -1
- data/lib/generators/cucumber/skeleton/templates/support/rails.rb.erb +4 -5
- data/lib/generators/cucumber/skeleton/templates/support/rails_spork.rb.erb +4 -4
- data/lib/generators/cucumber/skeleton/templates/tasks/cucumber.rake.erb +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/cucumber_skeleton
CHANGED
@@ -1,178 +1,175 @@
|
|
1
1
|
# This generator bootstraps a Rails project for use with Cucumber
|
2
2
|
module Cucumber
|
3
|
-
|
3
|
+
module Generators
|
4
|
+
class SkeletonGenerator < Rails::Generators::Base
|
4
5
|
|
5
|
-
|
6
|
+
argument :language, :type => :string, :required => false, :default => 'en'
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
class_option :shebang, :type => :boolean, :aliases => "--shebang", :group => :cucumber,
|
9
|
+
:desc => "Adds shebang marker to script files"
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
class_option :webrat, :type => :boolean, :aliases => "--webrat", :group => :cucumber,
|
12
|
+
:desc => "Use webrat"
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
class_option :capybara, :type => :boolean, :aliases => "--capybara", :group => :cucumber,
|
15
|
+
:desc => "Use capybara"
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
class_option :rspec, :type => :boolean, :aliases => "--rspec", :group => :cucumber,
|
18
|
+
:desc => "Use rspec"
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
class_option :testunit, :type => :boolean, :aliases => "--testunit", :group => :cucumber,
|
21
|
+
:desc => "Use testunit"
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
class_option :spork, :type => :boolean, :aliases => "--spork", :group => :cucumber,
|
24
|
+
:desc => "Use spork"
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
27
|
+
Config::CONFIG['ruby_install_name'])
|
27
28
|
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
def self.source_root
|
31
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def initialize(*args, &block)
|
36
|
+
super
|
37
|
+
# @language = args.empty? ? 'en' : args.first
|
38
|
+
end
|
39
|
+
|
40
|
+
def my_options
|
41
|
+
@my_options ||= {}
|
42
|
+
end
|
43
|
+
|
44
|
+
def spork?
|
45
|
+
options[:spork]
|
46
|
+
end
|
47
|
+
|
48
|
+
def framework
|
49
|
+
my_options[:framework] ||= detect_current_framework || detect_default_framework
|
50
|
+
end
|
51
|
+
|
52
|
+
def driver
|
53
|
+
my_options[:driver] ||= detect_current_driver || detect_default_driver
|
54
|
+
end
|
42
55
|
|
43
|
-
|
44
|
-
|
45
|
-
|
56
|
+
# def embed_template(source, indent='')
|
57
|
+
# template = File.join(File.dirname(__FILE__), 'templates', source)
|
58
|
+
# ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
|
59
|
+
# end
|
60
|
+
|
61
|
+
def version
|
62
|
+
filename = File.dirname(__FILE__) + '/../../../../VERSION'
|
63
|
+
path = File.expand_path(filename)
|
64
|
+
IO.read(filename).chomp
|
65
|
+
end
|
46
66
|
|
47
|
-
|
48
|
-
|
49
|
-
|
67
|
+
def create_files
|
68
|
+
if File.exist?('features/step_definitions/webrat_steps.rb')
|
69
|
+
STDERR.puts "Please remove features/step_definitions/webrat_steps.rb\n" +
|
70
|
+
"See upgrading instructions for 0.2.0 in History.txt"
|
71
|
+
exit(1)
|
72
|
+
end
|
73
|
+
if File.exist?('features/support/version_check.rb')
|
74
|
+
STDERR.puts "Please remove features/support/version_check.rb\n" +
|
75
|
+
"See upgrading instructions for 0.2.0 in History.txt"
|
76
|
+
exit(1)
|
77
|
+
end
|
50
78
|
|
51
|
-
|
52
|
-
|
53
|
-
end
|
79
|
+
template 'config/cucumber.yml.erb', 'config/cucumber.yml'
|
80
|
+
template 'environments/cucumber.rb.erb', 'config/environments/cucumber.rb'
|
54
81
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
82
|
+
copy_file 'script/cucumber', 'script/cucumber'
|
83
|
+
chmod 'script/cucumber', 0755, :verbose => false, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
|
84
|
+
|
85
|
+
empty_directory 'features/step_definitions'
|
86
|
+
template "step_definitions/#{driver}_steps.rb.erb", 'features/step_definitions/web_steps.rb'
|
87
|
+
if language != 'en'
|
88
|
+
template "step_definitions/web_steps_#{language}.rb.erb", "features/step_definitions/web_steps_#{language}.rb"
|
89
|
+
end
|
90
|
+
|
91
|
+
empty_directory 'features/support'
|
92
|
+
if spork?
|
93
|
+
template 'support/rails_spork.rb.erb', 'features/support/env.rb'
|
94
|
+
else
|
95
|
+
template 'support/rails.rb.erb', 'features/support/env.rb'
|
96
|
+
end
|
97
|
+
copy_file 'support/paths.rb', 'features/support/paths.rb'
|
98
|
+
|
99
|
+
empty_directory 'lib/tasks'
|
100
|
+
template 'tasks/cucumber.rake.erb', 'lib/tasks/cucumber.rake'
|
101
|
+
|
102
|
+
gsub_file 'config/database.yml', /test:.*\n/, "test: &TEST\n"
|
103
|
+
unless File.read('config/database.yml').include? 'cucumber:'
|
104
|
+
gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *TEST"
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
no_tasks do
|
110
|
+
def embed_file(source, indent='')
|
111
|
+
IO.read(File.join(File.dirname(__FILE__), 'templates', source)).gsub(/^/, indent)
|
112
|
+
end
|
65
113
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
exit(1)
|
114
|
+
def embed_template(source, indent='')
|
115
|
+
template = File.join(File.dirname(__FILE__), 'templates', source)
|
116
|
+
ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
|
117
|
+
end
|
71
118
|
end
|
72
|
-
|
73
|
-
|
74
|
-
"
|
75
|
-
exit(1)
|
119
|
+
|
120
|
+
def banner
|
121
|
+
"Usage: #{$0} cucumber (language)"
|
76
122
|
end
|
77
123
|
|
78
|
-
template 'config/cucumber.yml.erb', 'config/cucumber.yml'
|
79
|
-
template 'environments/cucumber.rb.erb', 'config/environments/cucumber.rb'
|
80
|
-
|
81
|
-
copy_file 'script/cucumber', 'script/cucumber'
|
82
|
-
chmod 'script/cucumber', 0755, :verbose => false, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
|
83
124
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
125
|
+
private
|
126
|
+
def empty_directory_with_gitkeep(destination, config = {})
|
127
|
+
empty_directory(destination, config)
|
128
|
+
create_file("#{destination}/.gitkeep") unless options[:skip_git]
|
129
|
+
end
|
130
|
+
|
131
|
+
def first_loadable(libraries)
|
132
|
+
require 'rubygems'
|
133
|
+
libraries.each do |library|
|
134
|
+
begin
|
135
|
+
require library[0]
|
136
|
+
return library[1]
|
137
|
+
rescue LoadError => ignore
|
138
|
+
end
|
139
|
+
end
|
140
|
+
return nil
|
88
141
|
end
|
89
142
|
|
90
|
-
|
91
|
-
|
92
|
-
template 'support/rails_spork.rb.erb', 'features/support/env.rb'
|
93
|
-
else
|
94
|
-
template 'support/rails.rb.erb', 'features/support/env.rb'
|
143
|
+
def detect_current_driver
|
144
|
+
detect_in_env([['capybara', :capybara], ['webrat', :webrat ]])
|
95
145
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
gsub_file 'config/database.yml', /test:.*\n/, "test: &TEST\n"
|
102
|
-
unless File.read('config/database.yml').include? 'cucumber:'
|
103
|
-
gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *TEST"
|
146
|
+
|
147
|
+
def detect_default_driver
|
148
|
+
@default_driver = first_loadable([['capybara', :capybara], ['webrat', :webrat ]])
|
149
|
+
raise "I don't know which driver you want. Use --capybara or --webrat, or gem install capybara or webrat." unless @default_driver
|
150
|
+
@default_driver
|
104
151
|
end
|
105
|
-
|
106
|
-
end
|
107
152
|
|
108
|
-
|
109
|
-
|
110
|
-
|
153
|
+
def detect_current_framework
|
154
|
+
detect_in_env([['spec', :rspec], ['test/unit', :testunit]])
|
155
|
+
end
|
111
156
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
def first_loadable(libraries)
|
119
|
-
require 'rubygems'
|
120
|
-
libraries.each do |library|
|
121
|
-
begin
|
122
|
-
require library[0]
|
123
|
-
return library[1]
|
124
|
-
rescue LoadError => ignore
|
125
|
-
end
|
157
|
+
def detect_default_framework
|
158
|
+
@default_framework = first_loadable([['spec', :rspec], ['test/unit', :testunit]])
|
159
|
+
raise "I don't know what test framework you want. Use --rspec or --testunit, or gem install rspec or test-unit." unless @default_framework
|
160
|
+
@default_framework
|
126
161
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
@default_driver = first_loadable([['capybara', :capybara], ['webrat', :webrat ]])
|
136
|
-
raise "I don't know which driver you want. Use --capybara or --webrat, or gem install capybara or webrat." unless @default_driver
|
137
|
-
@default_driver
|
138
|
-
end
|
139
|
-
|
140
|
-
def detect_current_framework
|
141
|
-
detect_in_env([['spec', :rspec], ['test/unit', :testunit]])
|
142
|
-
end
|
143
|
-
|
144
|
-
def detect_default_framework
|
145
|
-
@default_framework = first_loadable([['spec', :rspec], ['test/unit', :testunit]])
|
146
|
-
raise "I don't know what test framework you want. Use --rspec or --testunit, or gem install rspec or test-unit." unless @default_framework
|
147
|
-
@default_framework
|
148
|
-
end
|
149
|
-
|
150
|
-
def detect_in_env(choices)
|
151
|
-
env = File.file?("features/support/env.rb") ? IO.read("features/support/env.rb") : ''
|
152
|
-
choices.each do |choice|
|
153
|
-
detected = choice[1] if env =~ /#{choice[0]}/n
|
154
|
-
return detected if detected
|
162
|
+
|
163
|
+
def detect_in_env(choices)
|
164
|
+
env = File.file?("features/support/env.rb") ? IO.read("features/support/env.rb") : ''
|
165
|
+
choices.each do |choice|
|
166
|
+
detected = choice[1] if env =~ /#{choice[0]}/n
|
167
|
+
return detected if detected
|
168
|
+
end
|
169
|
+
return nil
|
155
170
|
end
|
156
|
-
return nil
|
157
171
|
end
|
158
172
|
end
|
159
173
|
end
|
160
174
|
|
161
|
-
module Cucumber
|
162
|
-
module Helper
|
163
|
-
class << self
|
164
|
-
attr_accessor :framework
|
165
|
-
end
|
166
|
-
|
167
|
-
def self.embed_file(source, indent='')
|
168
|
-
IO.read(File.join(File.dirname(__FILE__), 'templates', source)).gsub(/^/, indent)
|
169
|
-
end
|
170
|
-
|
171
|
-
def self.embed_template(source, indent='')
|
172
|
-
template = File.join(File.dirname(__FILE__), 'templates', source)
|
173
|
-
ERB.new(IO.read(template), nil, '-').result(binding).gsub(/^/, indent)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
175
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
<%=
|
4
|
-
<%=
|
5
|
-
<%= Cucumber::Helper.embed_file('support/_rails_each_run.rb') %>
|
1
|
+
<%= embed_file('support/edit_warning.txt') %>
|
2
|
+
<%= embed_template('support/_rails_prefork.rb.erb') %>
|
3
|
+
<%= embed_file("support/#{driver}.rb") %>
|
4
|
+
<%= embed_file('support/_rails_each_run.rb') %>
|
@@ -1,13 +1,13 @@
|
|
1
|
-
<%=
|
1
|
+
<%= embed_file('support/edit_warning.txt') %>
|
2
2
|
require 'rubygems'
|
3
3
|
require 'spork'
|
4
4
|
|
5
5
|
Spork.prefork do
|
6
|
-
<%=
|
6
|
+
<%= embed_template('support/_rails_prefork.rb.erb', ' ') %>
|
7
7
|
|
8
|
-
<%=
|
8
|
+
<%= embed_file("support/#{driver}.rb", ' ') %>
|
9
9
|
end
|
10
10
|
|
11
11
|
Spork.each_run do
|
12
|
-
<%=
|
12
|
+
<%= embed_file('support/_rails_each_run.rb', ' ') %>
|
13
13
|
end
|