rspec-kickstarter 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rspec-kickstarter +2 -2
- data/lib/rspec_kickstarter/generator.rb +14 -14
- data/lib/rspec_kickstarter/version.rb +1 -1
- data/lib/rspec_kickstarter.rb +0 -1
- metadata +2 -2
data/bin/rspec-kickstarter
CHANGED
@@ -11,8 +11,8 @@ dry_run = false
|
|
11
11
|
spec_dir = './spec'
|
12
12
|
|
13
13
|
opt = OptionParser.new
|
14
|
-
opt.on('-f', '
|
15
|
-
opt.on('-n', 'Dry run') { |_| dry_run = true }
|
14
|
+
opt.on('-f', 'Create if absent or append to the existing spec') { |_| force_write = true }
|
15
|
+
opt.on('-n', 'Dry run mode') { |_| dry_run = true }
|
16
16
|
opt.on('-o VAL', 'Output directory') { |dir| spec_dir = dir }
|
17
17
|
|
18
18
|
args = opt.parse(ARGV)
|
@@ -62,7 +62,7 @@ module RSpecKickstarter
|
|
62
62
|
"\n #{instance_name(c)} = #{get_complete_class_name(c)}.new"
|
63
63
|
else
|
64
64
|
get_params_initialization_code(constructor) +
|
65
|
-
"\n #{instance_name(c)} = #{get_complete_class_name(c)}.new#{constructor.params}"
|
65
|
+
"\n #{instance_name(c)} = #{get_complete_class_name(c)}.new(#{to_param_names_array(constructor.params).join(', ')})"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -104,11 +104,11 @@ module RSpecKickstarter
|
|
104
104
|
end
|
105
105
|
|
106
106
|
parser = RDoc::Parser::Ruby.new(
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
top_level,
|
108
|
+
file_path,
|
109
|
+
body,
|
110
|
+
RDoc::Options.new,
|
111
|
+
stats
|
112
112
|
)
|
113
113
|
top_level = parser.scan
|
114
114
|
c = get_target(top_level)
|
@@ -127,7 +127,7 @@ module RSpecKickstarter
|
|
127
127
|
else
|
128
128
|
additional_spec = <<SPEC
|
129
129
|
#{racking_methods.map { |method|
|
130
|
-
|
130
|
+
<<EACH_SPEC
|
131
131
|
# TODO auto-generated
|
132
132
|
describe '#{method.name}' do
|
133
133
|
it 'should work' do#{get_instantiation_code(c, method)}#{get_params_initialization_code(method)}
|
@@ -141,7 +141,7 @@ SPEC
|
|
141
141
|
last_end_not_found = true
|
142
142
|
code = existing_spec.split("\n").reverse.reject { |line|
|
143
143
|
if last_end_not_found
|
144
|
-
last_end_not_found = line.
|
144
|
+
last_end_not_found = line.gsub(/#.+$/, '').strip != "end"
|
145
145
|
true
|
146
146
|
else
|
147
147
|
false
|
@@ -166,7 +166,7 @@ require '#{self_path}'
|
|
166
166
|
describe #{get_complete_class_name(c)} do
|
167
167
|
|
168
168
|
#{c.method_list.select { |m| m.visibility == :public }.map { |method|
|
169
|
-
|
169
|
+
<<EACH_SPEC
|
170
170
|
# TODO auto-generated
|
171
171
|
describe '#{method.name}' do
|
172
172
|
it 'should work' do#{get_instantiation_code(c, method)}#{get_params_initialization_code(method)}
|
@@ -179,12 +179,12 @@ EACH_SPEC
|
|
179
179
|
end
|
180
180
|
SPEC
|
181
181
|
|
182
|
-
if
|
183
|
-
puts "#{spec_path}
|
182
|
+
if dry_run
|
183
|
+
puts "----- #{spec_path} -----"
|
184
|
+
puts code
|
184
185
|
else
|
185
|
-
if
|
186
|
-
puts "
|
187
|
-
puts code
|
186
|
+
if File.exist?(spec_path)
|
187
|
+
puts "#{spec_path} already exists."
|
188
188
|
else
|
189
189
|
FileUtils.mkdir_p(File.dirname(spec_path))
|
190
190
|
File.open(spec_path, 'w') { |f| f.write(code) }
|
data/lib/rspec_kickstarter.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project:
|
49
|
-
rubygems_version: 1.8.
|
49
|
+
rubygems_version: 1.8.24
|
50
50
|
signing_key:
|
51
51
|
specification_version: 3
|
52
52
|
summary: RSpec kickstarter generates spec files for existing code.
|