rspec_piccolo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rspec_piccolo.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "rspec_piccolo/version"
2
2
  require "erb"
3
3
  require 'active_support/inflector'
4
+ require 'fileutils'
4
5
 
5
6
  module RSpecPiccolo
6
7
  #= RSpecPiccolo Core
@@ -100,7 +101,7 @@ EOS
100
101
 
101
102
  def create_spec_directory(class_path)
102
103
  return if Dir.exists? "./spec/#{File.dirname(class_path)}"
103
- Dir.mkdir("./spec/#{File.dirname(class_path)}")
104
+ FileUtils.mkdir_p("./spec/#{File.dirname(class_path)}")
104
105
  end
105
106
 
106
107
  def generate_class_template(class_name, class_path, methods_template)
@@ -1,3 +1,3 @@
1
1
  module RSpecPiccolo
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "spec_helper"
3
3
  require "rspec_piccolo"
4
+ require "fileutils"
4
5
 
5
6
  describe RSpecPiccolo::Core do
6
7
  context :generate do
@@ -193,6 +194,93 @@ EOS
193
194
  require "spec_helper"
194
195
  require "some_dir/hoge_core"
195
196
 
197
+ describe Hoge::Core do
198
+ context :method1 do
199
+ cases = [
200
+ {
201
+ case_no: 1,
202
+ case_title: "case_title",
203
+ expected: "expected"
204
+ },
205
+ ]
206
+
207
+ cases.each do |c|
208
+ it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
209
+ begin
210
+ case_before c
211
+
212
+ # -- given --
213
+ hoge_core = Hoge::Core.new
214
+
215
+ # -- when --
216
+ # TODO: implement execute code
217
+ # actual = hoge_core.method1
218
+
219
+ # -- then --
220
+ # TODO: implement assertion code
221
+ # expect(actual).to eq(c[:expected])
222
+ ensure
223
+ case_after c
224
+ end
225
+ end
226
+
227
+ def case_before(c)
228
+ # implement each case before
229
+ end
230
+
231
+ def case_after(c)
232
+ # implement each case after
233
+ end
234
+ end
235
+ end
236
+
237
+ context :method2 do
238
+ cases = [
239
+ {
240
+ case_no: 1,
241
+ case_title: "case_title",
242
+ expected: "expected"
243
+ },
244
+ ]
245
+
246
+ cases.each do |c|
247
+ it "|case_no=\#{c[:case_no]}|case_title=\#{c[:case_title]}" do
248
+ begin
249
+ case_before c
250
+
251
+ # -- given --
252
+ hoge_core = Hoge::Core.new
253
+
254
+ # -- when --
255
+ # TODO: implement execute code
256
+ # actual = hoge_core.method2
257
+
258
+ # -- then --
259
+ # TODO: implement assertion code
260
+ # expect(actual).to eq(c[:expected])
261
+ ensure
262
+ case_after c
263
+ end
264
+ end
265
+
266
+ def case_before(c)
267
+ # implement each case before
268
+ end
269
+
270
+ def case_after(c)
271
+ # implement each case after
272
+ end
273
+ end
274
+ end
275
+
276
+ end
277
+ EOS
278
+
279
+ CASE9_EXPECTED=<<-EOS
280
+ # encoding: utf-8
281
+ require "spec_helper"
282
+ require "some_dir/some_sub_dir/hoge_core"
283
+
196
284
  describe Hoge::Core do
197
285
  context :method1 do
198
286
  cases = [
@@ -311,6 +399,7 @@ EOS
311
399
  case_title: "with directory, classname(with module) and method_names",
312
400
  class_name: "Hoge::Core",
313
401
  class_path: "some_dir/hoge_core",
402
+ del_dir: "some_dir",
314
403
  method_names: ["method1", "method2"],
315
404
  expected_file_name: "./spec/some_dir/hoge_core_spec.rb",
316
405
  expected_file_exists: true,
@@ -348,6 +437,17 @@ EOS
348
437
  method_names: ["method1"],
349
438
  expect_error: true
350
439
  },
440
+ {
441
+ case_no: 9,
442
+ case_title: "with two directories, classname(with module) and method_names",
443
+ class_name: "Hoge::Core",
444
+ class_path: "some_dir/some_sub_dir/hoge_core",
445
+ del_dir: "some_dir",
446
+ method_names: ["method1", "method2"],
447
+ expected_file_name: "./spec/some_dir/some_sub_dir/hoge_core_spec.rb",
448
+ expected_file_exists: true,
449
+ expected_contents: CASE9_EXPECTED
450
+ },
351
451
  ]
352
452
 
353
453
  cases.each do |c|
@@ -383,6 +483,7 @@ EOS
383
483
  # implement each case after
384
484
  return if c[:expect_error]
385
485
  File.delete(c[:expected_file_name]) if File.exists?(c[:expected_file_name])
486
+ FileUtils.rm_rf("spec/some_dir")
386
487
  end
387
488
  end
388
489
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_piccolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-26 00:00:00.000000000 Z
12
+ date: 2013-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &27984528 !ruby/object:Gem::Requirement
16
+ requirement: &28816488 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *27984528
24
+ version_requirements: *28816488
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &27984228 !ruby/object:Gem::Requirement
27
+ requirement: &28815984 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.18.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *27984228
35
+ version_requirements: *28815984
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &27983952 !ruby/object:Gem::Requirement
38
+ requirement: &28815408 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *27983952
46
+ version_requirements: *28815408
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &27983724 !ruby/object:Gem::Requirement
49
+ requirement: &28814976 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *27983724
57
+ version_requirements: *28814976
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &27983400 !ruby/object:Gem::Requirement
60
+ requirement: &28814448 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.14.1
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *27983400
68
+ version_requirements: *28814448
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &27983100 !ruby/object:Gem::Requirement
71
+ requirement: &28813872 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.8.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *27983100
79
+ version_requirements: *28813872
80
80
  description: generate rspec spec_file with list_cases
81
81
  email:
82
82
  - tbpgr@tbpgr.jp