rspec-kickstarter 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -197,6 +197,16 @@ class RSpecKickstarter::Generator
197
197
  params.split(',').map { |p| p.gsub(/[\(\)\s]/, '').gsub(/=.+$/, '') }.reject { |p| p.nil? || p.empty? }
198
198
  end
199
199
 
200
+ #
201
+ # Returns params part
202
+ # e.g. ["a","b"] -> "(a, b)"
203
+ # e.g. [] -> ""
204
+ #
205
+ def to_params_part(params)
206
+ param_csv = to_param_names_array(params).join(', ')
207
+ param_csv.empty? ? "" : "(#{param_csv})"
208
+ end
209
+
200
210
  #
201
211
  # Code generation
202
212
  #
@@ -216,7 +226,7 @@ class RSpecKickstarter::Generator
216
226
  " #{instance_name(c)} = #{get_complete_class_name(c)}.new\n"
217
227
  else
218
228
  get_params_initialization_code(constructor) +
219
- " #{instance_name(c)} = #{get_complete_class_name(c)}.new(#{to_param_names_array(constructor.params).join(', ')})\n"
229
+ " #{instance_name(c)} = #{get_complete_class_name(c)}.new#{to_params_part(constructor.params)}\n"
220
230
  end
221
231
  end
222
232
  end
@@ -236,14 +246,14 @@ class RSpecKickstarter::Generator
236
246
  #
237
247
  def get_method_invocation_code(c, method)
238
248
  target = method.singleton ? get_complete_class_name(c) : instance_name(c)
239
- "#{target}.#{method.name}(#{to_param_names_array(method.params).join(', ')})#{get_block_code(method)}"
249
+ "#{target}.#{method.name}#{to_params_part(method.params)}#{get_block_code(method)}"
240
250
  end
241
251
 
242
252
  #
243
253
  # e.g. do_something(a, b) { |c| }
244
254
  #
245
255
  def get_rails_helper_method_invocation_code(method)
246
- "#{method.name}(#{to_param_names_array(method.params).join(', ')})#{get_block_code(method)}"
256
+ "#{method.name}#{to_params_part(method.params)}#{get_block_code(method)}"
247
257
  end
248
258
 
249
259
  #
@@ -265,7 +275,7 @@ class RSpecKickstarter::Generator
265
275
  BASIC_METHODS_PART_TEMPLATE = <<SPEC
266
276
  <%- methods_to_generate.map { |method| %>
267
277
  # TODO auto-generated
268
- describe '<%= method.name %>' do
278
+ describe '#<%= method.name %>' do
269
279
  it 'works' do
270
280
  <%- unless get_instantiation_code(c, method).nil? -%><%= get_instantiation_code(c, method) %><%- end -%>
271
281
  <%- unless get_params_initialization_code(method).nil? -%><%= get_params_initialization_code(method) %><%- end -%>
@@ -301,8 +311,8 @@ SPEC
301
311
  RAILS_CONTROLLER_METHODS_PART_TEMPLATE = <<SPEC
302
312
  <%- methods_to_generate.map { |method| %>
303
313
  # TODO auto-generated
304
- describe '<%= method.name %>' do
305
- it 'returns OK' do
314
+ describe '<%= get_rails_http_method(method.name).upcase %> <%= method.name %>' do
315
+ it 'works' do
306
316
  <%= get_rails_http_method(method.name) %> :<%= method.name %>, {}, {}
307
317
  expect(response.status).to eq(200)
308
318
  end
@@ -323,7 +333,7 @@ SPEC
323
333
  RAILS_HELPER_METHODS_PART_TEMPLATE = <<SPEC
324
334
  <%- methods_to_generate.map { |method| %>
325
335
  # TODO auto-generated
326
- describe '<%= method.name %>' do
336
+ describe '#<%= method.name %>' do
327
337
  it 'works' do
328
338
  result = <%= get_rails_helper_method_invocation_code(method) %>
329
339
  expect(result).not_to be_nil
@@ -1,3 +1,3 @@
1
1
  module RSpecKickstarter
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-kickstarter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-06-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: rspec-kickstarter supports you writing tests for existing code.
15
15
  email:
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubyforge_project:
47
- rubygems_version: 1.8.23
47
+ rubygems_version: 1.8.24
48
48
  signing_key:
49
49
  specification_version: 3
50
50
  summary: rspec-kickstarter supports you writing tests for existing code.