cucumber_scaffold 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
data/Manifest
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('cucumber_scaffold', '0.1.
|
5
|
+
Echoe.new('cucumber_scaffold', '0.1.2') do |p|
|
6
6
|
p.description = "Generate scaffolding for Cucumber features and steps definitions"
|
7
7
|
p.url = "http://github.com/andyw8/cucumber_scaffold"
|
8
8
|
p.author = "Andy Waite"
|
data/TODO
CHANGED
@@ -8,4 +8,5 @@
|
|
8
8
|
* Add support for belongs_to associations
|
9
9
|
* Test for model names containing more than one word (e.g. DocumentCategory)
|
10
10
|
* Add automated test suite
|
11
|
-
* Prevent excess whitespace in generated files
|
11
|
+
* Prevent excess whitespace in generated files
|
12
|
+
* Better interaction with Pickle
|
data/cucumber_scaffold.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cucumber_scaffold}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Andy Waite"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = %q{Generate scaffolding for Cucumber features and steps definitions}
|
11
11
|
s.email = %q{andy@andywaite.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "TODO", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/shared/web_steps_additional.rb"]
|
13
|
-
s.files = ["Manifest", "README.rdoc", "Rakefile", "TODO", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/shared/web_steps_additional.rb"
|
13
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "TODO", "cucumber_scaffold.gemspec", "lib/generators/cucumber_scaffold/feature/USAGE", "lib/generators/cucumber_scaffold/feature/feature_generator.rb", "lib/generators/cucumber_scaffold/feature/templates/feature.feature", "lib/generators/cucumber_scaffold/feature/templates/steps.rb", "lib/generators/cucumber_scaffold/install/USAGE", "lib/generators/cucumber_scaffold/install/install_generator.rb", "lib/generators/cucumber_scaffold/install/templates/shared/web_steps_additional.rb"]
|
14
14
|
s.homepage = %q{http://github.com/andyw8/cucumber_scaffold}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cucumber_scaffold", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -10,14 +10,11 @@ module CucumberScaffold
|
|
10
10
|
source_root File.expand_path('../templates', __FILE__)
|
11
11
|
|
12
12
|
def initialize(args, *options)
|
13
|
-
# copied setup from
|
14
|
-
# http://apidock.com/rails/Rails/Generators/NamedBase/new/class
|
15
|
-
args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen?
|
16
13
|
super
|
17
|
-
assign_names!(self.name)
|
18
|
-
parse!
|
19
14
|
args.shift
|
20
15
|
@args = args
|
16
|
+
# seems to be a conflict if I call this @options
|
17
|
+
@x_options = options
|
21
18
|
end
|
22
19
|
|
23
20
|
def do_it
|
@@ -54,141 +51,142 @@ EOF
|
|
54
51
|
|
55
52
|
private
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
def generated_by
|
55
|
+
'# Generated by cucumber_scaffold - http://github.com/andyw8/cucumber_scaffold'
|
56
|
+
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
def nifty?
|
59
|
+
# there's probably a better way to do this
|
60
|
+
@x_options.include?(["--nifty"])
|
61
|
+
end
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
def singular
|
64
|
+
name.underscore.downcase
|
65
|
+
end
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
def plural
|
68
|
+
singular.pluralize
|
69
|
+
end
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
def singular_title
|
72
|
+
singular.titleize
|
73
|
+
end
|
76
74
|
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
def plural_title
|
76
|
+
plural.titleize
|
77
|
+
end
|
80
78
|
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
def activerecord_table_header_row
|
80
|
+
make_row(attribute_names)
|
81
|
+
end
|
84
82
|
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
def html_table_header_row
|
84
|
+
make_row(attribute_names.map(&:titleize))
|
85
|
+
end
|
88
86
|
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
def attribute_names
|
88
|
+
@attributes.collect {|a| a.first[0]}
|
89
|
+
end
|
92
90
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
91
|
+
def html_single_resource(updated=nil, commented=nil)
|
92
|
+
lines = []
|
93
|
+
@attributes.each do |pair|
|
94
|
+
attribute_name = pair.first[0]
|
95
|
+
attribute_value = pair.first[1]
|
96
|
+
lines << "| #{attribute_name.titleize}: | #{default_value(attribute_name, attribute_value, updated)} |"
|
97
|
+
end
|
98
|
+
lines.join(commented ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
99
99
|
end
|
100
|
-
lines.join(commented ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
101
|
-
end
|
102
100
|
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
def form_single_resource_commented
|
102
|
+
form_single_resource(false, true)
|
103
|
+
end
|
106
104
|
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
def html_single_resource_commented
|
106
|
+
html_single_resource(false, true)
|
107
|
+
end
|
110
108
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
109
|
+
def form_single_resource(updated=nil, commented=nil)
|
110
|
+
lines = []
|
111
|
+
@attributes.each do |pair|
|
112
|
+
attribute_name = pair.first[0]
|
113
|
+
attribute_value = pair.first[1]
|
114
|
+
lines << "| #{attribute_name.titleize} | #{default_value(attribute_name, attribute_value, updated)} |"
|
115
|
+
end
|
116
|
+
result = lines.join(commented ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
117
117
|
end
|
118
|
-
result = lines.join(commented ? LINE_BREAK_WITH_INDENT_COMMENTED : LINE_BREAK_WITH_INDENT)
|
119
|
-
end
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
119
|
+
def activerecord_single_resource(updated=nil)
|
120
|
+
lines = []
|
121
|
+
@attributes.each do |pair|
|
122
|
+
attribute_name = pair.first[0]
|
123
|
+
attribute_value = pair.first[1]
|
124
|
+
lines << "| #{attribute_name} | #{default_value(attribute_name, attribute_value, updated)} |"
|
125
|
+
end
|
126
|
+
lines.join(LINE_BREAK_WITH_INDENT)
|
127
127
|
end
|
128
|
-
lines.join(LINE_BREAK_WITH_INDENT)
|
129
|
-
end
|
130
128
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
def html_resources
|
130
|
+
[html_table_header_row,
|
131
|
+
html_table_row(1),
|
132
|
+
html_table_row(2),
|
133
|
+
html_table_row(3)].join(LINE_BREAK_WITH_INDENT)
|
134
|
+
end
|
137
135
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
def activerecord_resources
|
137
|
+
[activerecord_table_header_row,
|
138
|
+
activerecord_table_row(1),
|
139
|
+
activerecord_table_row(2),
|
140
|
+
activerecord_table_row(3)].join(LINE_BREAK_WITH_INDENT)
|
141
|
+
end
|
144
142
|
|
145
|
-
|
146
|
-
|
147
|
-
|
143
|
+
def activerecord_single_resource_updated
|
144
|
+
activerecord_single_resource(true)
|
145
|
+
end
|
148
146
|
|
149
|
-
|
150
|
-
|
151
|
-
|
147
|
+
def form_single_resource_updated
|
148
|
+
form_single_resource(true)
|
149
|
+
end
|
152
150
|
|
153
|
-
|
154
|
-
|
155
|
-
|
151
|
+
def html_single_resource_updated
|
152
|
+
html_single_resource(true)
|
153
|
+
end
|
156
154
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
155
|
+
def default_value(attribute_name, attribute_type, updated=false, index=1)
|
156
|
+
# TODO use an options hash instead of all these arguments
|
157
|
+
if ['string', 'text'].include?(attribute_type)
|
158
|
+
result = "#{attribute_name} #{index}"
|
159
|
+
result += ' updated' if updated
|
160
|
+
elsif attribute_type == 'integer'
|
161
|
+
result = 10 + index
|
162
|
+
result = -result if updated
|
163
|
+
else
|
164
|
+
raise "Cannot create default value for attribute type '#{attribute_type}'"
|
165
|
+
end
|
166
|
+
result
|
167
|
+
end
|
170
168
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
169
|
+
def activerecord_table_row(n)
|
170
|
+
data = []
|
171
|
+
@attributes.each do |attribute|
|
172
|
+
attribute_name = attribute.first[0]
|
173
|
+
attribute_type = attribute.first[1]
|
174
|
+
data << default_value(attribute_name, attribute_type, false, n)
|
175
|
+
end
|
176
|
+
make_row(data)
|
177
177
|
end
|
178
|
-
make_row(data)
|
179
|
-
end
|
180
178
|
|
181
|
-
|
182
|
-
|
183
|
-
|
179
|
+
def html_table_row(n)
|
180
|
+
activerecord_table_row(n)
|
181
|
+
end
|
184
182
|
|
185
|
-
|
186
|
-
|
187
|
-
|
183
|
+
def tags(tags)
|
184
|
+
tags
|
185
|
+
end
|
188
186
|
|
189
|
-
|
190
|
-
|
191
|
-
|
187
|
+
def make_row(data)
|
188
|
+
"| #{data.join(' | ')} |"
|
189
|
+
end
|
192
190
|
|
193
191
|
end
|
194
192
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Waite
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- README.rdoc
|
41
41
|
- Rakefile
|
42
42
|
- TODO
|
43
|
+
- cucumber_scaffold.gemspec
|
43
44
|
- lib/generators/cucumber_scaffold/feature/USAGE
|
44
45
|
- lib/generators/cucumber_scaffold/feature/feature_generator.rb
|
45
46
|
- lib/generators/cucumber_scaffold/feature/templates/feature.feature
|
@@ -47,7 +48,6 @@ files:
|
|
47
48
|
- lib/generators/cucumber_scaffold/install/USAGE
|
48
49
|
- lib/generators/cucumber_scaffold/install/install_generator.rb
|
49
50
|
- lib/generators/cucumber_scaffold/install/templates/shared/web_steps_additional.rb
|
50
|
-
- cucumber_scaffold.gemspec
|
51
51
|
has_rdoc: true
|
52
52
|
homepage: http://github.com/andyw8/cucumber_scaffold
|
53
53
|
licenses: []
|