rspec_rails_scaffold_templates 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85957f17443a8174b3a6faba670875a3f0bd8933
4
- data.tar.gz: f8b312b8ff673c5374b3ac63bb93b9c2782abbf1
3
+ metadata.gz: 27d682e6616341bca9023ca6554f24827740eff4
4
+ data.tar.gz: 8e881d9500cc5195042a2fa28787b82417b60c90
5
5
  SHA512:
6
- metadata.gz: 53bbc2b51cfa6308d34f52f9328df500a779c59a756447a5680f328ab1c06a94a21d82017f9b8544de52b83d42f10ff08b7378bddb75e9740c1a96a752fa00dd
7
- data.tar.gz: 55e25cc99b607c25b0d1cf228ef5d538a45a887b89f8ce1129260ea1d0caae88229463ece924ddbebe65ff75a6f6b1fa0a1961d1ae101f46030408ec6e5bf3c3
6
+ metadata.gz: 878283db4d53d8ac0b68c868eea9cdd30dce52ecd2ae5c0913769ac43bd4d735caa58eac2375ba7060a06753c9d7fc4dbeb8fe2673d0ce3e1cd91af9fbf45c8a
7
+ data.tar.gz: cc41e0891511edf76ee8d065f0a83c8190b9d3f413875906dc5a7a76a1cdd1c10bef49d127d72bcfee0f9334aa317b620439fc5989f8d578e434f80313a2dcc3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -15,10 +15,12 @@ describe <%= controller_class_name %>Controller, :type => :controller do
15
15
  # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
16
16
  # adjust the attributes here as well. The list could not be empty.
17
17
  <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
18
+ <% factory_girl = true -%>
18
19
  <% attribute = attributes.detect{|a| attributes.detect{|a| a.name == 'name'} || attributes.detect{|a| a.name == 'title'} || attributes.first} -%>
19
20
  <% attribute_name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
20
21
  let(:valid_attributes) {FactoryGirl.build(:<%=file_name%>).attributes.slice *%w[<%= attribute_name %>]}
21
22
  <% else -%>
23
+ <% factory_girl = false -%>
22
24
  let(:valid_attributes) {
23
25
  skip("Add a hash of attributes valid for your model")
24
26
  }
@@ -36,7 +38,11 @@ describe <%= controller_class_name %>Controller, :type => :controller do
36
38
  <% unless options[:singleton] -%>
37
39
  describe "GET index" do
38
40
  it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
41
+ <% if factory_girl -%>
42
+ <%= file_name %> = create :<%= file_name %>
43
+ <% else -%>
39
44
  <%= file_name %> = <%= class_name %>.create! valid_attributes
45
+ <% end -%>
40
46
  get :index, {}, valid_session
41
47
  expect(assigns(:<%= table_name %>)).to be_kind_of(ActiveRecord::Relation)
42
48
  expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
@@ -46,7 +52,11 @@ describe <%= controller_class_name %>Controller, :type => :controller do
46
52
  <% end -%>
47
53
  describe "GET show" do
48
54
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
55
+ <% if factory_girl -%>
56
+ <%= file_name %> = create :<%= file_name %>
57
+ <% else -%>
49
58
  <%= file_name %> = <%= class_name %>.create! valid_attributes
59
+ <% end -%>
50
60
  get :show, {:id => <%= file_name %>.to_param}, valid_session
51
61
  expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
52
62
  end
@@ -61,7 +71,11 @@ describe <%= controller_class_name %>Controller, :type => :controller do
61
71
 
62
72
  describe "GET edit" do
63
73
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
74
+ <% if factory_girl -%>
75
+ <%= file_name %> = create :<%= file_name %>
76
+ <% else -%>
64
77
  <%= file_name %> = <%= class_name %>.create! valid_attributes
78
+ <% end -%>
65
79
  get :edit, {:id => <%= file_name %>.to_param}, valid_session
66
80
  expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
67
81
  end
@@ -105,30 +119,37 @@ describe <%= controller_class_name %>Controller, :type => :controller do
105
119
 
106
120
  describe "PUT update" do
107
121
  describe "with valid params" do
108
- let(:new_attributes) {
109
- <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
110
- FactoryGirl.build(:<%=file_name%>).attributes.slice *%w[<%= attribute_name %>]
111
- <% else -%>
112
- skip("Add a hash of attributes valid for your model")
113
- <% end -%>
114
- }
122
+ let(:new_attributes) { {<%= attribute_name %>: 'New value'} }
115
123
 
116
124
  it "updates the requested <%= ns_file_name %>" do
125
+ <% if factory_girl -%>
126
+ <%= file_name %> = create :<%= file_name %>
127
+ <% else -%>
117
128
  <%= file_name %> = <%= class_name %>.create! valid_attributes
129
+ <% end -%>
118
130
  # expect_any_instance_of(<%= class_name %>).to receive(:update).with(new_attributes.inject({}){|_, (k, v)| _[k] = v.to_s; _})
119
131
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
120
132
  <%= file_name %>.reload
121
- skip("Add assertions for updated state")
133
+ # skip("Add assertions for updated state")
134
+ expect(<%= file_name %>.<%= attribute_name %>).to eq 'New value'
122
135
  end
123
136
 
124
137
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
138
+ <% if factory_girl -%>
139
+ <%= file_name %> = create :<%= file_name %>
140
+ <% else -%>
125
141
  <%= file_name %> = <%= class_name %>.create! valid_attributes
142
+ <% end -%>
126
143
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
127
144
  expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
128
145
  end
129
146
 
130
147
  it "redirects to the <%= ns_file_name %>" do
148
+ <% if factory_girl -%>
149
+ <%= file_name %> = create :<%= file_name %>
150
+ <% else -%>
131
151
  <%= file_name %> = <%= class_name %>.create! valid_attributes
152
+ <% end -%>
132
153
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
133
154
  expect(response).to redirect_to(<%= file_name %>)
134
155
  end
@@ -136,14 +157,22 @@ describe <%= controller_class_name %>Controller, :type => :controller do
136
157
 
137
158
  describe "with invalid params" do
138
159
  it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
160
+ <% if factory_girl -%>
161
+ <%= file_name %> = create :<%= file_name %>
162
+ <% else -%>
139
163
  <%= file_name %> = <%= class_name %>.create! valid_attributes
164
+ <% end -%>
140
165
  # allow_any_instance_of(<%= class_name %>).to receive(:update).and_return(false)
141
166
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
142
167
  expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
143
168
  end
144
169
 
145
170
  it "re-renders the 'edit' template" do
171
+ <% if factory_girl -%>
172
+ <%= file_name %> = create :<%= file_name %>
173
+ <% else -%>
146
174
  <%= file_name %> = <%= class_name %>.create! valid_attributes
175
+ <% end -%>
147
176
  # allow_any_instance_of(<%= class_name %>).to receive(:update).and_return(false)
148
177
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
149
178
  expect(response).to render_template("edit")
@@ -153,14 +182,22 @@ describe <%= controller_class_name %>Controller, :type => :controller do
153
182
 
154
183
  describe "DELETE destroy" do
155
184
  it "destroys the requested <%= ns_file_name %>" do
185
+ <% if factory_girl -%>
186
+ <%= file_name %> = create :<%= file_name %>
187
+ <% else -%>
156
188
  <%= file_name %> = <%= class_name %>.create! valid_attributes
189
+ <% end -%>
157
190
  expect {
158
191
  delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
159
192
  }.to change(<%= class_name %>, :count).by(-1)
160
193
  end
161
194
 
162
195
  it "redirects to the <%= table_name %> list" do
196
+ <% if factory_girl -%>
197
+ <%= file_name %> = create :<%= file_name %>
198
+ <% else -%>
163
199
  <%= file_name %> = <%= class_name %>.create! valid_attributes
200
+ <% end -%>
164
201
  delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
165
202
  expect(response).to redirect_to(<%= index_helper %>_url)
166
203
  end
@@ -24,8 +24,8 @@ describe "<%= ns_table_name %>/edit", :type => :view do
24
24
 
25
25
  assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do
26
26
  <% for attribute in output_attributes -%>
27
- <% name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
28
- <% input_type = attribute.reference? ? 'select' : attribute.input_type -%>
27
+ <% name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
28
+ <% input_type = attribute.reference? ? 'select' : attribute.input_type -%>
29
29
  assert_select '<%= input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]', '<%= ns_file_name %>[<%= name %>]'
30
30
  <% end -%>
31
31
  end
@@ -36,12 +36,30 @@ describe "<%= ns_table_name %>/index", :type => :view do
36
36
  <% end -%>
37
37
  ])
38
38
  <% end -%>
39
+ end
40
+
41
+ it "renders a list of <%= table_name %>" do
39
42
  <% if defined? Wice::WiceGrid -%>
40
- assign(:grid, Wice::WiceGrid.new(<%= class_name %>, controller))
43
+ assign :<%= table_name %>, [@<%= ns_file_name %>]
44
+ <% end -%>
45
+ render
46
+
47
+ <% for attribute in output_attributes -%>
48
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_girl -%>
49
+ <% if attribute.reference? -%>
50
+ assert_select 'tr>td', text: @<%= ns_file_name %>.<%= attribute.name %>.name, count: <%= size %>
51
+ <% else -%>
52
+ assert_select 'tr>td', text: @<%= ns_file_name %>.<%= attribute.name %>.to_s, count: <%= size %>
53
+ <% end -%>
54
+ <% else -%>
55
+ assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => <%= size %>
56
+ <% end -%>
41
57
  <% end -%>
42
58
  end
43
59
 
44
- it "renders a list of <%= table_name %>" do
60
+ <% if defined? Wice::WiceGrid -%>
61
+ it "renders a list of <%= table_name %> in WiceGrid" do
62
+ assign :grid, Wice::WiceGrid.new(<%= class_name %>, controller)
45
63
  render
46
64
 
47
65
  <% for attribute in output_attributes -%>
@@ -56,4 +74,5 @@ describe "<%= ns_table_name %>/index", :type => :view do
56
74
  <% end -%>
57
75
  <% end -%>
58
76
  end
77
+ <% end -%>
59
78
  end
@@ -24,8 +24,8 @@ describe "<%= ns_table_name %>/new", :type => :view do
24
24
 
25
25
  assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
26
26
  <% for attribute in output_attributes -%>
27
- <% name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
28
- <% input_type = attribute.reference? ? 'select' : attribute.input_type -%>
27
+ <% name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
28
+ <% input_type = attribute.reference? ? 'select' : attribute.input_type -%>
29
29
  assert_select '<%= input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]', '<%= ns_file_name %>[<%= name %>]'
30
30
  <% end -%>
31
31
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rspec_rails_scaffold_templates 1.0.1 ruby lib
5
+ # stub: rspec_rails_scaffold_templates 1.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rspec_rails_scaffold_templates"
9
- s.version = "1.0.1"
9
+ s.version = "1.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Dmitri Koulikoff"]
14
- s.date = "2014-09-17"
14
+ s.date = "2014-09-18"
15
15
  s.description = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid"
16
16
  s.email = "dima@koulikoff.ru"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_rails_scaffold_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitri Koulikoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec