mig-rspec_abandoner 0.2 → 0.3
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/History.txt +4 -0
- data/Manifest.txt +2 -0
- data/lib/camelize.rb +7 -0
- data/lib/rspec_abandoner.rb +26 -7
- data/test/test_camelize.rb +10 -0
- data/test/test_rspec_abandoner.rb +12 -0
- metadata +4 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/lib/camelize.rb
ADDED
data/lib/rspec_abandoner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
class RspecAbandoner
|
4
|
-
VERSION = '0.
|
4
|
+
VERSION = '0.3'
|
5
5
|
|
6
6
|
def self.start
|
7
7
|
abandoner = RspecAbandoner.new
|
@@ -20,7 +20,7 @@ class RspecAbandoner
|
|
20
20
|
output = ""
|
21
21
|
File.open(file) do |io|
|
22
22
|
io.each_line do |line|
|
23
|
-
output << go(line)
|
23
|
+
output << go(line, file)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,8 +30,16 @@ class RspecAbandoner
|
|
30
30
|
File.delete(file)
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
/describe\s(.*)\s.*do/
|
33
|
+
def describe_string_block
|
34
|
+
/describe\s"(.*)"\s.*do/
|
35
|
+
end
|
36
|
+
|
37
|
+
def describe_class_block
|
38
|
+
/describe\s([A-Za-z]*)\s.*do/
|
39
|
+
end
|
40
|
+
|
41
|
+
def describe_class_and_string_block
|
42
|
+
/describe\s*([A-Za-z]*),\s*"(.*)"\s*do/
|
35
43
|
end
|
36
44
|
|
37
45
|
def it_block
|
@@ -66,11 +74,22 @@ class RspecAbandoner
|
|
66
74
|
/(.*).should\s*be_(.*)/
|
67
75
|
end
|
68
76
|
|
69
|
-
def go(input)
|
77
|
+
def go(input, file = nil)
|
78
|
+
|
79
|
+
if input.match(describe_string_block)
|
80
|
+
file_name = File.basename(file).gsub(/\.rb/, "").gsub(/_spec/, "")
|
81
|
+
input.gsub!(describe_string_block) do
|
82
|
+
"class #{file_name.camelize}Test < Test::Unit::TestCase"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
input.gsub!(describe_class_block) do
|
87
|
+
"class #{$1}Test < Test::Unit::TestCase"
|
88
|
+
end if input.match(describe_class_block)
|
70
89
|
|
71
|
-
input.gsub!(
|
90
|
+
input.gsub!(describe_class_and_string_block) do
|
72
91
|
"class #{$1}Test < Test::Unit::TestCase"
|
73
|
-
end if input.match(
|
92
|
+
end if input.match(describe_class_and_string_block)
|
74
93
|
|
75
94
|
input.gsub!(it_block) do
|
76
95
|
"def test_#{$2.split(' ').join('_')}"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'mocha'
|
4
|
+
require File.dirname(__FILE__) + "/../lib/camelize"
|
4
5
|
require File.dirname(__FILE__) + "/../lib/rspec_abandoner"
|
5
6
|
|
6
7
|
class TestRspecAbandoner < Test::Unit::TestCase
|
@@ -14,6 +15,17 @@ class TestRspecAbandoner < Test::Unit::TestCase
|
|
14
15
|
@abandon.go(%[describe CrabShack do])
|
15
16
|
end
|
16
17
|
|
18
|
+
def test_should_use_camelized_filename_if_describe_is_a_string
|
19
|
+
file = "crab_shack_spec.rb"
|
20
|
+
assert_equal %[class CrabShackTest < Test::Unit::TestCase],
|
21
|
+
@abandon.go(%[describe "class methods" do], file)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_use_class_name_over_string_if_describe_has_both
|
25
|
+
assert_equal %[class CrabShackTest < Test::Unit::TestCase],
|
26
|
+
@abandon.go(%[describe CrabShack, "with no crabs" do])
|
27
|
+
end
|
28
|
+
|
17
29
|
def test_should_replace_it_blocks_with_a_test_method
|
18
30
|
assert_equal %[def test_should_know_things_are_weird],
|
19
31
|
@abandon.go(%[it "should know things are weird" do])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mig-rspec_abandoner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mig Swasey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-06-
|
12
|
+
date: 2008-06-27 00:00:00 -07:00
|
13
13
|
default_executable: rspec_abandoner
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -30,7 +30,9 @@ files:
|
|
30
30
|
- README.txt
|
31
31
|
- Rakefile
|
32
32
|
- bin/rspec_abandoner
|
33
|
+
- lib/camelize.rb
|
33
34
|
- lib/rspec_abandoner.rb
|
35
|
+
- test/test_camelize.rb
|
34
36
|
- test/test_rspec_abandoner.rb
|
35
37
|
has_rdoc: true
|
36
38
|
homepage: http://pggbee.com
|