jzajpt-blueberry_scaffold 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -6,9 +6,9 @@ Scaffold generator used by Blueberry Apps. Features I18n support, Shoulda and Fa
6
6
 
7
7
  Usage
8
8
  ======
9
-
9
+
10
10
  script/generate blueberry_scaffold [namespace]/[name] [controller actions] [model attributes]
11
-
11
+
12
12
  If you specify namespace, it will be used for controller not for model. Model attributes are
13
13
  in format name:type.
14
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{blueberry_scaffold}
5
- s.version = "0.3.2"
5
+ s.version = "0.3.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ji\305\231\303\255 Zajpt"]
9
- s.date = %q{2009-06-08}
9
+ s.date = %q{2009-06-11}
10
10
  s.description = %q{Scaffold generator featuring i18n, shoulda & factory girl tests.}
11
11
  s.email = %q{jzajpt@blueberryapps.com}
12
12
  s.extra_rdoc_files = [
@@ -1,6 +1,6 @@
1
1
  class BlueberryScaffoldGenerator < Rails::Generator::Base
2
2
  attr_accessor :attributes
3
-
3
+
4
4
  def initialize(runtime_args, runtime_options = {})
5
5
  super
6
6
  usage if @args.empty?
@@ -8,7 +8,7 @@ class BlueberryScaffoldGenerator < Rails::Generator::Base
8
8
  # First argument is our controller/model name
9
9
  @name = runtime_args.shift
10
10
  @namespace, @name = @name.split('/') if @name.include?('/')
11
-
11
+
12
12
  # Model attributes
13
13
  @attributes = []
14
14
  # Controller actions
@@ -44,16 +44,16 @@ class BlueberryScaffoldGenerator < Rails::Generator::Base
44
44
  unless options[:skip_migration]
45
45
  m.migration_template 'migration.rb', 'db/migrate', :migration_file_name => "create_#{plural_name}"
46
46
  end
47
-
47
+
48
48
  # Factory
49
49
  m.directory "test/factories"
50
50
  m.template "factory.rb", "test/factories/#{singular_name}_factory.rb"
51
-
51
+
52
52
  # Model test
53
53
  m.directory "test/unit"
54
54
  m.template "model_test.rb", "test/unit/#{singular_name}_test.rb"
55
55
  end
56
-
56
+
57
57
  unless options[:skip_controller]
58
58
  # Create controller
59
59
  m.directory controller_path
@@ -76,7 +76,7 @@ class BlueberryScaffoldGenerator < Rails::Generator::Base
76
76
 
77
77
  # Add resources route
78
78
  m.route_resources plural_name
79
-
79
+
80
80
  # Controller tst
81
81
  m.directory controller_test_path
82
82
  m.template "controller_test.rb", "#{controller_test_path}/#{plural_name}_controller_test.rb"
@@ -84,63 +84,63 @@ class BlueberryScaffoldGenerator < Rails::Generator::Base
84
84
 
85
85
  end
86
86
  end
87
-
87
+
88
88
  protected
89
-
89
+
90
90
  def all_actions
91
91
  %w(index show new edit create update destroy)
92
92
  end
93
-
93
+
94
94
  def action?(name)
95
95
  @actions.include? name.to_s
96
96
  end
97
-
97
+
98
98
  def singular_name
99
99
  @name.singularize.underscore
100
100
  end
101
-
101
+
102
102
  def class_name
103
103
  @name.singularize.camelize
104
104
  end
105
-
105
+
106
106
  def plural_name
107
107
  @name.underscore.pluralize
108
108
  end
109
-
109
+
110
110
  def plural_class_name
111
111
  plural_name.camelize
112
112
  end
113
-
113
+
114
114
  def controller_class_name
115
115
  @namespace ? "#{@namespace.camelize}::#{plural_name.camelize}Controller" :
116
116
  "#{plural_name.camelize}Controller"
117
117
  end
118
-
118
+
119
119
  def helper_class_name
120
120
  @namespace ? "#{@namespace.camelize}::#{plural_name.camelize}Helper" :
121
121
  "#{plural_name.camelize}Helper"
122
122
  end
123
-
123
+
124
124
  def controller_test_name
125
125
  "#{controller_class_name}Test"
126
126
  end
127
-
127
+
128
128
  def controller_path
129
129
  @namespace ? "app/controllers/#{@namespace}" : "app/controllers"
130
130
  end
131
-
131
+
132
132
  def helper_path
133
133
  @namespace ? "app/helpers/#{@namespace}" : "app/helpers"
134
134
  end
135
-
135
+
136
136
  def controller_test_path
137
137
  @namespace ? "test/functional/#{@namespace}" : "test/functional"
138
138
  end
139
-
139
+
140
140
  def view_path
141
141
  @namespace ? "app/views/#{@namespace}" : "app/views"
142
142
  end
143
-
143
+
144
144
  def url
145
145
  @namespace ? "#{@namespace}_#{plural_name}_url" : "#{plural_name}_url"
146
146
  end
@@ -148,7 +148,7 @@ class BlueberryScaffoldGenerator < Rails::Generator::Base
148
148
  def i18n_prefix
149
149
  @namespace ? "#{@namespace}.#{plural_name}" : plural_name
150
150
  end
151
-
151
+
152
152
  def items_path
153
153
  @namespace ? "#{@namespace}_#{plural_name}_path" : "#{plural_name}_path"
154
154
  end
@@ -156,19 +156,19 @@ class BlueberryScaffoldGenerator < Rails::Generator::Base
156
156
  def item_path
157
157
  @namespace ? "#{@namespace}_#{singular_name}_path" : "#{singular_name}_path"
158
158
  end
159
-
159
+
160
160
  def new_item_path
161
161
  @namespace ? "new_#{@namespace}_#{singular_name}_path" : "new_#{singular_name}_path"
162
162
  end
163
-
163
+
164
164
  def edit_item_path
165
165
  @namespace ? "edit_#{@namespace}_edit_#{singular_name}_path" : "edit_#{singular_name}_path"
166
166
  end
167
-
167
+
168
168
  def controller_route
169
169
  @namespace ? "/#{@namespace}/#{plural_name}" : "/#{plural_name}"
170
170
  end
171
-
171
+
172
172
  def add_options!(opt)
173
173
  opt.separator ''
174
174
  opt.separator 'Options:'
@@ -14,21 +14,21 @@ class <%= controller_class_name %> < ApplicationController
14
14
  def show
15
15
  @<%= singular_name %> = <%= class_name %>.find(params[:id])
16
16
  end
17
-
17
+
18
18
  <% end -%>
19
19
  <% if action? :new -%>
20
20
  # GET /<%= plural_name %>/new
21
21
  def new
22
22
  @<%= singular_name %> = <%= class_name %>.new
23
23
  end
24
-
24
+
25
25
  <% end -%>
26
26
  <% if action? :edit -%>
27
27
  # GET /<%= plural_name %>/:id/edit
28
28
  def edit
29
29
  @<%= singular_name %> = <%= class_name %>.find(params[:id])
30
30
  end
31
-
31
+
32
32
  <% end -%>
33
33
  <% if action? :create -%>
34
34
  # POST /<%= plural_name %>
@@ -52,7 +52,7 @@ class <%= controller_class_name %> < ApplicationController
52
52
  rescue ActiveRecord::RecordInvalid
53
53
  render 'edit'
54
54
  end
55
-
55
+
56
56
  <% end -%>
57
57
  <% if action? :destroy -%>
58
58
  # DELETE /<%= plural_name %>/:id
@@ -7,17 +7,18 @@ class <%= controller_test_name %> < ActionController::TestCase
7
7
  5.times { Factory :<%= singular_name %> }
8
8
  get :index
9
9
  end
10
-
10
+
11
11
  should_respond_with :success
12
12
  should_assign_to :<%= plural_name %>, :class => Array
13
13
  # should_paginate_collection :<%= plural_name %>
14
- should_render_template :index
15
14
  should_not_set_the_flash
16
-
15
+ should_render_with_layout
16
+ should_render_template :index
17
+
17
18
  should "return 5 items" do
18
19
  assert_equal 5, assigns(:<%= plural_name %>).size
19
20
  end
20
-
21
+
21
22
  should "display <%= plural_name %> table with 5 items" do
22
23
  assert_select "table.list > tbody > tr", 5
23
24
  end
@@ -33,8 +34,9 @@ class <%= controller_test_name %> < ActionController::TestCase
33
34
 
34
35
  should_respond_with :success
35
36
  should_assign_to(:<%= singular_name %>, :class => <%= class_name %>) { @<%= singular_name %> }
36
- should_render_template :show
37
- should_not_set_the_flash
37
+ should_not_set_the_flash
38
+ should_render_with_layout
39
+ should_render_template :show
38
40
  end
39
41
 
40
42
  <% end -%>
@@ -44,10 +46,11 @@ class <%= controller_test_name %> < ActionController::TestCase
44
46
 
45
47
  should_respond_with :success
46
48
  should_assign_to(:<%= singular_name %>, :class => <%= class_name %>)
49
+ should_not_set_the_flash
50
+ should_render_with_layout
47
51
  should_render_template :new
48
52
  should_render_a_form
49
- should_not_set_the_flash
50
-
53
+
51
54
  should "build new <%= class_name %>" do
52
55
  assert assigns(:<%= singular_name %>).new_record?
53
56
  end
@@ -63,9 +66,10 @@ class <%= controller_test_name %> < ActionController::TestCase
63
66
 
64
67
  should_respond_with :success
65
68
  should_assign_to(:<%= singular_name %>, :class => <%= class_name %>) { @<%= singular_name %> }
69
+ should_not_set_the_flash
70
+ should_render_with_layout
66
71
  should_render_template :edit
67
72
  should_render_a_form
68
- should_not_set_the_flash
69
73
  end
70
74
 
71
75
  <% end -%>
@@ -87,18 +91,19 @@ class <%= controller_test_name %> < ActionController::TestCase
87
91
  should_assign_to :<%= singular_name %>, :class => <%= class_name %>
88
92
  should_set_the_flash_to I18n.t('<%= i18n_prefix %>.create.success')
89
93
  end
90
-
94
+
91
95
  context "with invalid attributes" do
92
96
  setup do
93
97
  <%= class_name %>.any_instance.stubs(:valid?).returns(false)
94
98
  post :create
95
99
  end
96
-
100
+
97
101
  should_respond_with :success
98
102
  should_assign_to :<%= singular_name %>, :class => <%= class_name %>
103
+ should_render_with_layout
99
104
  should_render_template :new
100
- should_render_a_form
101
- should_not_set_the_flash
105
+ should_not_set_the_flash
106
+ should_render_a_form
102
107
 
103
108
  should "build new <%= class_name %>" do
104
109
  assert assigns(:<%= singular_name %>).new_record?
@@ -131,12 +136,13 @@ class <%= controller_test_name %> < ActionController::TestCase
131
136
  <%= class_name %>.any_instance.stubs(:valid?).returns(false)
132
137
  put :update, :id => @<%= singular_name %>.id
133
138
  end
134
-
139
+
135
140
  should_respond_with :success
136
141
  should_assign_to(:<%= singular_name %>, :class => <%= class_name %>) { @<%= singular_name %> }
142
+ should_not_set_the_flash
143
+ should_render_with_layout
137
144
  should_render_template :edit
138
145
  should_render_a_form
139
- should_not_set_the_flash
140
146
  end
141
147
  end
142
148
 
@@ -152,7 +158,7 @@ class <%= controller_test_name %> < ActionController::TestCase
152
158
  should_redirect_to('portfolio items listing') { <%= url %> }
153
159
  should_assign_to(:<%= singular_name %>, :class => <%= class_name %>) { @<%= singular_name %> }
154
160
  should_set_the_flash_to I18n.t('<%= i18n_prefix %>.destroy.success')
155
-
161
+
156
162
  should "delete item" do
157
163
  assert !<%= class_name %>.exists?(@<%= singular_name %>.id)
158
164
  end
@@ -165,7 +171,7 @@ class <%= controller_test_name %> < ActionController::TestCase
165
171
  <% if action? :show -%>
166
172
  should_route :get, '<%= controller_route %>/1', :action => 'show', :id => 1
167
173
  <% end -%>
168
- <% if action? :now -%>
174
+ <% if action? :new -%>
169
175
  should_route :get, '<%= controller_route %>/new', :action => 'new'
170
176
  <% end -%>
171
177
  <% if action? :edit -%>
@@ -9,7 +9,7 @@ class Create<%= plural_class_name %> < ActiveRecord::Migration
9
9
  <%- end -%>
10
10
  end
11
11
  end
12
-
12
+
13
13
  def self.down
14
14
  drop_table :<%= plural_name %>
15
15
  end
@@ -5,10 +5,10 @@ class <%= class_name %>Test < ActiveSupport::TestCase
5
5
  setup do
6
6
  @<%= singular_name %> = Factory :<%= singular_name %>
7
7
  end
8
-
8
+
9
9
  should_change "<%= class_name %>.count", :by => 1
10
10
  end
11
-
11
+
12
12
  # Mass assignment attributes
13
13
  should_allow_mass_assignment_of <%= attributes.map(&:name).map { |a| ':'+a }.join(', ') %>
14
14
  should_not_allow_mass_assignment_of :id<% unless options[:skip_timestamps] %>, :created_at, :modified_at<% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jzajpt-blueberry_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Ji\xC5\x99\xC3\xAD Zajpt"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-08 00:00:00 -07:00
12
+ date: 2009-06-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15