spec-converter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -21,7 +21,48 @@ Assuming your project is at ~/work/project/:
21
21
  * svn trunk: https://opensource.thinkrelevance.com/svn/spec_converter/trunk
22
22
  * rdoc: http://spec-converter.rubyforge.org/rdoc
23
23
 
24
- == LICENSE:
24
+ = Spec report
25
+
26
+ == converting from test/spec old style to new style names
27
+ * replaces spec context with describe
28
+ * ignores unrelated uses of 'context'
29
+ * replaces spec specify with it
30
+ * ignores unrelated uses of 'specify'
31
+
32
+ == converting dust style to test/spec style
33
+ * changes test...do to it...do
34
+ * ignores unrelated lines
35
+
36
+ == converting ActionController::IntegrationTest style to describe blocks
37
+ * replaces class FooTest < ActionController::IntegrationTest with describe foo do
38
+
39
+ == converting Test::Unit style to describe blocks
40
+ * replaces class FooTest < Test::Unit::TestCase with describe foo do
41
+ * replaces class FooTest < Test::Unit::TestCase with silly whitespacing with describe foo do
42
+ * converts namespaced test unit classes
43
+ * ignores unrelated classes
44
+
45
+ == converting Test::Unit methods to it blocks
46
+ * replaces def setup with before do
47
+ * ignores method definitions that only start with setup
48
+ * replaces class def test_something? with it something? do
49
+ * replaces class def test_something? with it something? do
50
+ * replaces class def test_something with it something do
51
+ * replaces class def test_something with it something do when it has leading whitespace
52
+ * ignores unrelated lines
53
+ * ignores unrelated lines with leading whitespace
54
+
55
+ == converting assertions
56
+ * replaces assert !foo to foo.should == false
57
+ * replaces assert_equal y, x, bar to x.should == y
58
+ * replaces assert foo to foo.should == true
59
+ * replaces assert_nil foo to foo.should == nil
60
+ * replaces assert_true foo to foo.should == true
61
+ * replaces assert_false foo to foo.should == false
62
+ * replaces assert_not_nil foo to foo.should.not == nil
63
+ * replaces assert foo > 20 to foo.should > 20
64
+
65
+ = LICENSE:
25
66
 
26
67
  (The MIT License)
27
68
 
data/Rakefile CHANGED
@@ -7,12 +7,14 @@ require 'rcov/rcovtask'
7
7
 
8
8
  Hoe.new('SpecConverter', SpecConverter::VERSION) do |p|
9
9
  p.rubyforge_name = "spec-converter"
10
+ p.description = "Convert your tests to test/spec specs. See http://opensource.thinkrelevance.com/wiki/spec-converter for details."
11
+ p.changes = "Added assertions conversions"
10
12
  p.name = 'spec-converter'
11
13
  p.remote_rdoc_dir = 'rdoc'
12
14
  p.summary = "Convert your tests to test/spec specs"
13
15
  p.author = "Relevance"
14
16
  p.email = "opensource@thinkrelevance.com"
15
- p.url = "http://opensource.thinkrelevance.com"
17
+ p.url = "http://opensource.thinkrelevance.com/wiki/spec-converter"
16
18
  end
17
19
 
18
20
  desc 'Default: run unit tests.'
@@ -1,7 +1,7 @@
1
1
  # Simple converter to go to test/spec style
2
2
  # This will change all files in place, so make sure you are properly backed up and/or committed to SVN!
3
3
  class SpecConverter
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
 
6
6
  def self.start
7
7
  spec_converter = SpecConverter.new
@@ -36,6 +36,7 @@ class SpecConverter
36
36
  convert_test_unit_class_name(line)
37
37
  convert_test_unit_methods(line)
38
38
  convert_def_setup(line)
39
+ convert_assert(line)
39
40
  line
40
41
  end
41
42
 
@@ -62,4 +63,12 @@ class SpecConverter
62
63
  def convert_dust_style(line)
63
64
  line.gsub!(/(^\s*)test(\s.*do)/, '\1it\2')
64
65
  end
66
+
67
+ def convert_assert(line)
68
+ line.gsub!(/(^\s*)assert\s+([^\s]*)\s*([<=>~]+)\s*(.*)$/, '\1\2.should \3 \4' )
69
+ line.gsub!(/(^\s*)assert\s+\!(.*)$/, '\1\2.should.not == true' )
70
+ line.gsub!(/(^\s*)assert(_not_nil){0,1}\s+(.*)$/, '\1\3.should.not == nil' )
71
+ line.gsub!(/(^\s*)assert_(nil|true|false)\s+(.*)$/, '\1\3.should == \2' )
72
+ line.gsub!(/(^\s*)assert_equal\s+("[^"]+"|[^,]+),\s*("[^"]+"|[^,\n]+)$/, '\1\3.should == \2' )
73
+ end
65
74
  end
@@ -140,6 +140,43 @@ describe "converting Test::Unit methods to it blocks" do
140
140
 
141
141
  end
142
142
 
143
+ describe "converting assertions" do
144
+ before do
145
+ @converter = SpecConverter.new
146
+ end
147
+
148
+ it "replaces assert !foo to foo.should == false" do
149
+ @converter.convert_line(%[ assert !foo]).should == %[ foo.should.not == true]
150
+ end
151
+
152
+ it "replaces assert_equal y, x, bar to x.should == y" do
153
+ @converter.convert_line(%[ assert_equal "$1,490.00", x["price"]\n]).should == %[ x["price"].should == "$1,490.00"\n]
154
+ end
155
+
156
+ it "replaces assert foo to foo.should == true" do
157
+ @converter.convert_line(%[ assert foo]).should == %[ foo.should.not == nil]
158
+ end
159
+
160
+ it "replaces assert_nil foo to foo.should == nil" do
161
+ @converter.convert_line(%[ assert_nil foo]).should == %[ foo.should == nil]
162
+ end
163
+
164
+ it "replaces assert_true foo to foo.should == true" do
165
+ @converter.convert_line(%[ assert_true foo]).should == %[ foo.should == true]
166
+ end
167
+
168
+ it "replaces assert_false foo to foo.should == false" do
169
+ @converter.convert_line(%[ assert_false foo]).should == %[ foo.should == false]
170
+ end
171
+
172
+ it "replaces assert_not_nil foo to foo.should.not == nil" do
173
+ @converter.convert_line(%[ assert_not_nil foo]).should == %[ foo.should.not == nil]
174
+ end
175
+ it "replaces assert foo > 20 to foo.should > 20" do
176
+ @converter.convert_line(%[ assert foo > 20]).should == %[ foo.should > 20]
177
+ end
178
+ end
179
+
143
180
  describe "converting things in batch" do
144
181
  before do
145
182
  @converter = SpecConverter.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spec-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Relevance
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-10 00:00:00 -05:00
12
+ date: 2008-01-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.4.0
23
23
  version:
24
- description: The author was too lazy to write a description
24
+ description: Convert your tests to test/spec specs. See http://opensource.thinkrelevance.com/wiki/spec-converter for details.
25
25
  email: opensource@thinkrelevance.com
26
26
  executables:
27
27
  - spec_converter
@@ -38,7 +38,7 @@ files:
38
38
  - lib/spec_converter.rb
39
39
  - test/spec_converter_test.rb
40
40
  has_rdoc: true
41
- homepage: http://opensource.thinkrelevance.com
41
+ homepage: http://opensource.thinkrelevance.com/wiki/spec-converter
42
42
  post_install_message:
43
43
  rdoc_options:
44
44
  - --main