cucumber_scaffold 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,12 @@ Then run the cucumber_scaffold generator with the same parameters:
20
20
 
21
21
  * By default the generated features are targeted at the Rails scaffold generator
22
22
  * Only tested with Rails 3 and Capybara (not webrat)
23
- * Only supports string, text, integer and boolean fields at present
23
+ * Only supports string, text, integer, decimal and boolean fields at present
24
+ * References (belongs_to) are partly supported
25
+
26
+ == Contributors
27
+
28
+ zuf[https://github.com/zuf]
24
29
 
25
30
  == Sample Output
26
31
 
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.3') do |p|
5
+ Echoe.new('cucumber_scaffold', '0.1.4') 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"
@@ -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.3"
5
+ s.version = "0.1.4"
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"]
@@ -26,7 +26,7 @@ module CucumberScaffold
26
26
 
27
27
  template('feature.feature', "features/manage_#{plural}.feature")
28
28
  template('steps.rb', "features/step_definitions/#{singular}_steps.rb")
29
-
29
+
30
30
  extra_paths = <<EOF
31
31
  when /edit page for that #{singular.humanize.downcase}/
32
32
  edit_#{singular}_path(@#{singular})
@@ -46,7 +46,7 @@ EOF
46
46
  gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
47
47
  "#{match}\n" + extra_paths
48
48
  end
49
-
49
+
50
50
  end
51
51
 
52
52
  private
@@ -154,24 +154,31 @@ EOF
154
154
  html_single_resource(:updated => true)
155
155
  end
156
156
 
157
- def default_value(options={}) # attribute_name, attribute_type, updated=false, index=1
158
- # TODO use an options hash instead of all these arguments
159
-
157
+ def default_value(options={})
160
158
  options[:index] ||= 10
161
159
 
160
+ updated = options[:updated]
161
+
162
162
  if ['string', 'text'].include?(options[:attribute_type])
163
163
  result = "#{options[:attribute_name].humanize.downcase} #{options[:index]}"
164
- result += ' updated' if options[:updated]
164
+ result += ' updated' if updated
165
165
  elsif options[:attribute_type] == 'integer'
166
166
  result = 10 + options[:index]
167
- result = -result if options[:updated]
167
+ result = -result if updated
168
+ elsif options[:attribute_type] == 'decimal'
169
+ result = 10.2 + options[:index]
170
+ result = -result if updated
171
+ elsif options[:attribute_type] == 'references'
172
+ model = options[:attribute_name].camelize.constantize
173
+ result = model.first
174
+ result = model.last if updated
168
175
  elsif options[:attribute_type] == 'boolean'
169
176
  if options[:form]
170
177
  result = '[x]'
171
- result = '[ ]' if options[:updated]
178
+ result = '[ ]' if updated
172
179
  else
173
180
  result = true
174
- result = false if options[:updated]
181
+ result = false if updated
175
182
  end
176
183
  else
177
184
  raise "Cannot create default value for attribute type '#{options[:attribute_type]}'"
@@ -196,10 +203,11 @@ EOF
196
203
  def tags(tags)
197
204
  tags
198
205
  end
199
-
206
+
200
207
  def make_row(data)
201
208
  "| #{data.join(' | ')} |"
202
209
  end
203
-
210
+
204
211
  end
205
- end
212
+ end
213
+
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: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Waite