rspec-kickstarter 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rspec_kickstarter/generator.rb +38 -24
- data/lib/rspec_kickstarter/version.rb +1 -1
- metadata +3 -3
@@ -40,18 +40,9 @@ class RSpecKickstarter::Generator
|
|
40
40
|
if lacking_methods.empty?
|
41
41
|
puts "#{spec_path} skipped."
|
42
42
|
else
|
43
|
+
# Since 'methods_to_generate' is used in ERB template, don't delete.
|
43
44
|
methods_to_generate = lacking_methods
|
44
|
-
|
45
|
-
if ! @delta_template.nil?
|
46
|
-
additional_spec = ERB.new(@delta_template, nil, '-', '_additional_spec_code').result(binding)
|
47
|
-
elsif rails_mode && spec_path.match(/controllers/)
|
48
|
-
additional_spec = ERB.new(RAILS_CONTROLLER_METHODS_PART_TEMPLATE, nil, '-', '_additional_spec_code').result(binding)
|
49
|
-
elsif rails_mode && spec_path.match(/helpers/)
|
50
|
-
additional_spec = ERB.new(RAILS_HELPER_METHODS_PART_TEMPLATE, nil, '-', '_additional_spec_code').result(binding)
|
51
|
-
else
|
52
|
-
additional_spec = ERB.new(BASIC_METHODS_PART_TEMPLATE, nil, '-', '_additional_spec_code').result(binding)
|
53
|
-
end
|
54
|
-
|
45
|
+
additional_spec = create_erb_instance_for_appending(rails_mode, spec_path).result(binding)
|
55
46
|
last_end_not_found = true
|
56
47
|
code = existing_spec.split("\n").reverse.reject { |line|
|
57
48
|
if last_end_not_found
|
@@ -72,18 +63,11 @@ class RSpecKickstarter::Generator
|
|
72
63
|
|
73
64
|
else
|
74
65
|
# Create a new spec
|
75
|
-
self_path = to_string_value_to_require(file_path)
|
76
|
-
methods_to_generate = c.method_list.select { |m| m.visibility == :public }
|
77
66
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
elsif rails_mode && self_path.match(/helpers/)
|
83
|
-
code = ERB.new(RAILS_HELPER_NEW_SPEC_TEMPLATE, nil, '-', '_new_spec_code').result(binding)
|
84
|
-
else
|
85
|
-
code = ERB.new(BASIC_NEW_SPEC_TEMPLATE, nil, '-', '_new_spec_code').result(binding)
|
86
|
-
end
|
67
|
+
# Since 'methods_to_generate' is used in ERB template, don't delete.
|
68
|
+
methods_to_generate = c.method_list.select { |m| m.visibility == :public }
|
69
|
+
self_path = to_string_value_to_require(file_path)
|
70
|
+
code = create_erb_instance_for_new_spec(rails_mode, self_path).result(binding)
|
87
71
|
|
88
72
|
if dry_run
|
89
73
|
puts "----- #{spec_path} -----"
|
@@ -113,8 +97,8 @@ class RSpecKickstarter::Generator
|
|
113
97
|
end
|
114
98
|
|
115
99
|
# RDoc::Stats initialization
|
116
|
-
if
|
117
|
-
#
|
100
|
+
if defined?(RDoc::Store)
|
101
|
+
# RDoc 4.0.0 requires RDoc::Store internally.
|
118
102
|
store = RDoc::Store.new
|
119
103
|
top_level.store = store
|
120
104
|
stats = RDoc::Stats.new(store, 1)
|
@@ -207,6 +191,36 @@ class RSpecKickstarter::Generator
|
|
207
191
|
param_csv.empty? ? "" : "(#{param_csv})"
|
208
192
|
end
|
209
193
|
|
194
|
+
#
|
195
|
+
# Returns ERB instance for creating new spec
|
196
|
+
#
|
197
|
+
def create_erb_instance_for_new_spec(rails_mode, target_path)
|
198
|
+
if ! @full_template.nil?
|
199
|
+
ERB.new(@full_template, nil, '-', '_new_spec_code')
|
200
|
+
elsif rails_mode && target_path.match(/controllers/)
|
201
|
+
ERB.new(RAILS_CONTROLLER_NEW_SPEC_TEMPLATE, nil, '-', '_new_spec_code')
|
202
|
+
elsif rails_mode && target_path.match(/helpers/)
|
203
|
+
ERB.new(RAILS_HELPER_NEW_SPEC_TEMPLATE, nil, '-', '_new_spec_code')
|
204
|
+
else
|
205
|
+
ERB.new(BASIC_NEW_SPEC_TEMPLATE, nil, '-', '_new_spec_code')
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
#
|
210
|
+
# Returns ERB instance for appeding lacking tests
|
211
|
+
#
|
212
|
+
def create_erb_instance_for_appending(rails_mode, target_path)
|
213
|
+
if ! @delta_template.nil?
|
214
|
+
ERB.new(@delta_template, nil, '-', '_additional_spec_code')
|
215
|
+
elsif rails_mode && target_path.match(/controllers/)
|
216
|
+
ERB.new(RAILS_CONTROLLER_METHODS_PART_TEMPLATE, nil, '-', '_additional_spec_code')
|
217
|
+
elsif rails_mode && target_path.match(/helpers/)
|
218
|
+
ERB.new(RAILS_HELPER_METHODS_PART_TEMPLATE, nil, '-', '_additional_spec_code')
|
219
|
+
else
|
220
|
+
ERB.new(BASIC_METHODS_PART_TEMPLATE, nil, '-', '_additional_spec_code')
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
210
224
|
#
|
211
225
|
# Code generation
|
212
226
|
#
|
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.
|
4
|
+
version: 0.2.6
|
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-
|
12
|
+
date: 2013-07-12 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.
|
47
|
+
rubygems_version: 1.8.23
|
48
48
|
signing_key:
|
49
49
|
specification_version: 3
|
50
50
|
summary: rspec-kickstarter supports you writing tests for existing code.
|