zoo-generators 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,8 +21,16 @@ Feature: Zoo Scaffold Generator
21
21
  And I run "rake db:migrate"
22
22
  And I should successfully run "rails g zoo:scaffold Project -f"
23
23
  And I run "bundle install"
24
- Then I should successfully run "rake test"
25
-
24
+ Then I should successfully run "rake test"
25
+
26
+ Scenario: Generate scaffold for existing resource
27
+ Given a new Rails app
28
+ When I run "rails g model Project some:string"
29
+ And I run "rake db:migrate"
30
+ And I run "rails g zoo:scaffold Project"
31
+ Then I should see "input :some" in file "app/views/projects/_form.html.haml"
32
+
33
+
26
34
  Scenario: Generate scaffold with rspec tests
27
35
  Given a new Rails app
28
36
  When I run "rails g zoo:scaffold Project name:string --rspec"
@@ -43,7 +43,7 @@ module Zoo
43
43
  @controller_actions << 'update' if arg == 'edit'
44
44
  end
45
45
  end
46
-
46
+
47
47
  @controller_actions.uniq!
48
48
  @model_attributes.uniq!
49
49
 
@@ -58,10 +58,12 @@ module Zoo
58
58
  @model_attributes << Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
59
59
  end
60
60
  else
61
- klass = class_name.new
62
- klass.attributes.each do
61
+ unless class_name.nil?
62
+ class_name.constantize.columns.each do |column|
63
63
  @model_attributes << Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
64
+ end
64
65
  end
66
+ @model_attributes << Rails::Generators::GeneratedAttribute.new("name", "string") if @model_attributes.empty?
65
67
  end
66
68
  end
67
69
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: zoo-generators
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mikael Henriksson