rspec 0.5.11 → 0.5.12

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.
Files changed (80) hide show
  1. data/CHANGES +12 -0
  2. data/README +4 -2
  3. data/Rakefile +14 -4
  4. data/bin/spec +7 -7
  5. data/bin/test2spec +13 -8
  6. data/lib/spec/api/helper/diff.rb +53 -0
  7. data/lib/spec/api/helper/instance_helper.rb +11 -11
  8. data/lib/spec/api/helper/instance_negator.rb +11 -11
  9. data/lib/spec/api/helper/kind_helper.rb +11 -11
  10. data/lib/spec/api/helper/kind_negator.rb +11 -11
  11. data/lib/spec/api/helper/respond_helper.rb +11 -11
  12. data/lib/spec/api/helper/respond_negator.rb +11 -11
  13. data/lib/spec/api/helper/should_base.rb +6 -6
  14. data/lib/spec/api/helper/should_helper.rb +35 -35
  15. data/lib/spec/api/helper/should_negator.rb +20 -20
  16. data/lib/spec/rake/spectask.rb +15 -6
  17. data/lib/spec/runner.rb +1 -0
  18. data/lib/spec/runner/backtrace_tweaker.rb +2 -0
  19. data/lib/spec/runner/base_text_formatter.rb +3 -1
  20. data/lib/spec/runner/html_formatter.rb +153 -0
  21. data/lib/spec/runner/option_parser.rb +9 -2
  22. data/lib/spec/runner/progress_bar_formatter.rb +4 -0
  23. data/lib/spec/runner/rdoc_formatter.rb +3 -0
  24. data/lib/spec/runner/reporter.rb +5 -5
  25. data/lib/spec/runner/specdoc_formatter.rb +3 -0
  26. data/lib/spec/test_to_spec/sexp_transformer.rb +1 -0
  27. data/lib/spec/test_to_spec/translation_test_runner.rb +10 -2
  28. data/lib/spec/version.rb +1 -1
  29. data/test/spec/api/helper/arbitrary_predicate_test.rb +49 -73
  30. data/test/spec/api/helper/diff_test.rb +60 -0
  31. data/test/spec/api/helper/equality_test.rb +14 -0
  32. data/test/spec/api/helper/should_have_test.rb +0 -29
  33. data/test/spec/api/helper/typing_test.rb +87 -87
  34. data/test/spec/api/sugar_test.rb +0 -6
  35. data/test/spec/runner/backtrace_tweaker_test.rb +8 -2
  36. data/test/spec/runner/html_formatter_test.rb +47 -0
  37. data/test/spec/runner/option_parser_test.rb +0 -5
  38. data/test/test_classes.rb +73 -0
  39. data/test/test_helper.rb +3 -0
  40. metadata +8 -49
  41. data/doc/README +0 -3
  42. data/doc/config.yaml +0 -2
  43. data/doc/plugin/syntax.rb +0 -60
  44. data/doc/plugin/version.rb +0 -19
  45. data/doc/src/core_team.page +0 -31
  46. data/doc/src/default.css +0 -199
  47. data/doc/src/default.template +0 -31
  48. data/doc/src/documentation/index.page +0 -188
  49. data/doc/src/documentation/meta.info +0 -22
  50. data/doc/src/documentation/mocks.page +0 -287
  51. data/doc/src/documentation/underscores.page +0 -21
  52. data/doc/src/examples.page +0 -9
  53. data/doc/src/images/David_and_Aslak.jpg +0 -0
  54. data/doc/src/images/Whats_That_Dude.jpg +0 -0
  55. data/doc/src/images/ducks1.png +0 -0
  56. data/doc/src/images/ul.gif +0 -0
  57. data/doc/src/index.page +0 -74
  58. data/doc/src/meta.info +0 -33
  59. data/doc/src/tools/index.page +0 -49
  60. data/doc/src/tools/meta.info +0 -18
  61. data/doc/src/tools/rails.page +0 -132
  62. data/doc/src/tools/rake.page +0 -21
  63. data/doc/src/tools/rcov.page +0 -28
  64. data/doc/src/tools/spec.page +0 -129
  65. data/doc/src/tools/test2spec.page +0 -103
  66. data/doc/src/tutorials/index.page +0 -52
  67. data/doc/src/tutorials/meta.info +0 -36
  68. data/doc/src/tutorials/notes.txt +0 -263
  69. data/doc/src/tutorials/stack.rb +0 -11
  70. data/doc/src/tutorials/stack_01.page +0 -226
  71. data/doc/src/tutorials/stack_02.page +0 -182
  72. data/doc/src/tutorials/stack_03.page +0 -283
  73. data/doc/src/tutorials/stack_04.page +0 -164
  74. data/doc/src/tutorials/stack_04.page.orig +0 -123
  75. data/doc/src/tutorials/stack_05.page +0 -90
  76. data/doc/src/tutorials/stack_05.page.orig +0 -124
  77. data/doc/src/tutorials/stack_06.page +0 -359
  78. data/doc/src/tutorials/stack_06.page.orig +0 -359
  79. data/doc/src/tutorials/stack_spec.rb +0 -25
  80. data/doc/src/ul.gif +0 -0
@@ -3,7 +3,7 @@ module Spec
3
3
  unless defined? MAJOR
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 11
6
+ TINY = 12
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  TAG = "REL_" + [MAJOR, MINOR, TINY].join('_')
@@ -3,131 +3,107 @@ require File.dirname(__FILE__) + '/../../../test_helper'
3
3
  module Spec
4
4
  module Api
5
5
  module Helper
6
-
7
- class XxxMock
8
- def initialize(return_val)
9
- @return_val = return_val
10
- @xxx_called = false
11
- end
12
-
13
- def xxx?
14
- @xxx_called = true
15
- @return_val
16
- end
17
-
18
- def yyy?(a, b, c)
19
- a.should.be 1
20
- b.should.be 2
21
- c.should.be 3
22
- @xxx_called = true
23
- @return_val
24
- end
25
-
26
- def __verify
27
- @xxx_called.should.be true
28
- end
29
- end
30
-
6
+
31
7
  class ArbitraryPredicateTest < Test::Unit::TestCase
32
8
 
33
9
  # should.be.xxx
34
10
 
35
- def test_should_be_xxx_should_raise_when_target_doesnt_understand_xxx
36
- assert_raise(NoMethodError) do
11
+ def test_should_be_xxx_should_raise_when_target_doesnt_understand_xxx
12
+ assert_raise(NoMethodError) do
37
13
  5.should.be.xxx
38
14
  end
39
- end
15
+ end
40
16
 
41
- def test_should_be_xxx_should_raise_when_sending_xxx_to_target_returns_false
42
- mock = XxxMock.new(false)
43
- assert_raise(ExpectationNotMetError) do
17
+ def test_should_be_xxx_should_raise_when_sending_xxx_to_target_returns_false
18
+ mock = XxxMock.new(false)
19
+ assert_raise(ExpectationNotMetError) do
44
20
  mock.should.be.xxx
45
21
  end
46
- mock.__verify
22
+ mock.__verify
47
23
  end
48
24
 
49
- def test_should_be_xxx_should_raise_when_sending_xxx_to_target_returns_nil
50
- mock = XxxMock.new(nil)
51
- assert_raise(ExpectationNotMetError) do
25
+ def test_should_be_xxx_should_raise_when_sending_xxx_to_target_returns_nil
26
+ mock = XxxMock.new(nil)
27
+ assert_raise(ExpectationNotMetError) do
52
28
  mock.should.be.xxx
53
29
  end
54
- mock.__verify
30
+ mock.__verify
55
31
  end
56
32
 
57
- def test_should_be_xxx_should_not_raise_when_sending_xxx_to_target_returns_true
58
- mock = XxxMock.new(true)
59
- assert_nothing_raised do
33
+ def test_should_be_xxx_should_not_raise_when_sending_xxx_to_target_returns_true
34
+ mock = XxxMock.new(true)
35
+ assert_nothing_raised do
60
36
  mock.should.be.xxx
61
37
  end
62
- mock.__verify
38
+ mock.__verify
63
39
  end
64
40
 
65
- def test_should_be_xxx_should_not_raise_when_sending_xxx_to_target_returns_something_other_than_true_false_or_nil
66
- mock = XxxMock.new(5)
67
- assert_nothing_raised do
41
+ def test_should_be_xxx_should_not_raise_when_sending_xxx_to_target_returns_something_other_than_true_false_or_nil
42
+ mock = XxxMock.new(5)
43
+ assert_nothing_raised do
68
44
  mock.should.be.xxx
69
45
  end
70
- mock.__verify
46
+ mock.__verify
71
47
  end
72
48
 
73
- # should.be.xxx(args)
74
-
49
+ # should.be.xxx(args)
50
+
75
51
  def test_should_be_xxx_with_args_passes_args_properly
76
- mock = XxxMock.new(true)
77
- assert_nothing_raised do
52
+ mock = XxxMock.new(true)
53
+ assert_nothing_raised do
78
54
  mock.should.be.yyy(1, 2, 3)
79
55
  end
80
- mock.__verify
56
+ mock.__verify
81
57
  end
82
58
 
83
59
  # should.not.be.xxx
84
60
 
85
- def test_should_not_be_xxx_should_raise_when_target_doesnt_understand_xxx
86
- assert_raise(NoMethodError) do
61
+ def test_should_not_be_xxx_should_raise_when_target_doesnt_understand_xxx
62
+ assert_raise(NoMethodError) do
87
63
  5.should.not.be.xxx
88
64
  end
89
- end
65
+ end
90
66
 
91
- def test_should_not_be_xxx_should_raise_when_sending_xxx_to_target_returns_true
92
- mock = XxxMock.new(true)
93
- assert_raise(ExpectationNotMetError) do
67
+ def test_should_not_be_xxx_should_raise_when_sending_xxx_to_target_returns_true
68
+ mock = XxxMock.new(true)
69
+ assert_raise(ExpectationNotMetError) do
94
70
  mock.should.not.be.xxx
95
71
  end
96
- mock.__verify
72
+ mock.__verify
97
73
  end
98
74
 
99
- def test_should_not_be_xxx_shouldnt_raise_when_sending_xxx_to_target_returns_nil
100
- mock = XxxMock.new(nil)
101
- assert_nothing_raised do
75
+ def test_should_not_be_xxx_shouldnt_raise_when_sending_xxx_to_target_returns_nil
76
+ mock = XxxMock.new(nil)
77
+ assert_nothing_raised do
102
78
  mock.should.not.be.xxx
103
79
  end
104
- mock.__verify
80
+ mock.__verify
105
81
  end
106
82
 
107
- def test_should_not_be_xxx_shouldnt_raise_when_sending_xxx_to_target_returns_false
108
- mock = XxxMock.new(false)
109
- assert_nothing_raised do
83
+ def test_should_not_be_xxx_shouldnt_raise_when_sending_xxx_to_target_returns_false
84
+ mock = XxxMock.new(false)
85
+ assert_nothing_raised do
110
86
  mock.should.not.be.xxx
111
87
  end
112
- mock.__verify
88
+ mock.__verify
113
89
  end
114
90
 
115
- def test_should_not_be_xxx_should_raise_when_sending_xxx_to_target_returns_something_other_than_true_false_or_nil
116
- mock = XxxMock.new(5)
117
- assert_raise(ExpectationNotMetError) do
91
+ def test_should_not_be_xxx_should_raise_when_sending_xxx_to_target_returns_something_other_than_true_false_or_nil
92
+ mock = XxxMock.new(5)
93
+ assert_raise(ExpectationNotMetError) do
118
94
  mock.should.not.be.xxx
119
95
  end
120
- mock.__verify
96
+ mock.__verify
121
97
  end
122
98
 
123
- # should.be.xxx(args)
124
-
99
+ # should.be.xxx(args)
100
+
125
101
  def test_should_not_be_xxx_with_args_passes_args_properly
126
- mock = XxxMock.new(false)
127
- assert_nothing_raised do
102
+ mock = XxxMock.new(false)
103
+ assert_nothing_raised do
128
104
  mock.should.not.be.yyy(1, 2, 3)
129
105
  end
130
- mock.__verify
106
+ mock.__verify
131
107
  end
132
108
 
133
109
  end
@@ -0,0 +1,60 @@
1
+ require File.dirname(__FILE__) + '/../../../test_helper'
2
+
3
+ module Spec
4
+ class DiffTest < Test::Unit::TestCase
5
+ def test_should_output_unified_diff
6
+ expected = <<-EOF
7
+ foo
8
+ bar
9
+ zap
10
+ this
11
+ is
12
+ soo
13
+ very
14
+ very
15
+ equal
16
+ insert
17
+ a
18
+ line
19
+ EOF
20
+
21
+ actual = <<-EOF
22
+ foo
23
+ zap
24
+ bar
25
+ this
26
+ is
27
+ soo
28
+ very
29
+ very
30
+ equal
31
+ insert
32
+ a
33
+ another
34
+ line
35
+ EOF
36
+
37
+ expected_diff = <<-EOF
38
+
39
+
40
+ @@ -1,6 +1,6 @@
41
+ foo
42
+ -bar
43
+ zap
44
+ +bar
45
+ this
46
+ is
47
+ soo
48
+ @@ -9,5 +9,6 @@
49
+ equal
50
+ insert
51
+ a
52
+ +another
53
+ line
54
+ EOF
55
+
56
+ diff = ShouldBase.new.diff_as_string(expected, actual)
57
+ assert_equal expected_diff, diff
58
+ end
59
+ end
60
+ end
@@ -25,6 +25,14 @@ module Spec
25
25
  @dummy.should.equal @another_dummy
26
26
  end
27
27
  end
28
+
29
+ def test_should_raise_nice_message
30
+ begin
31
+ "foo\nbar\nzap".should_equal "foo\nzap\nbar"
32
+ rescue ExpectationNotMetError => e
33
+ assert_equal "\"foo\\nbar\\nzap\" should equal \"foo\\nzap\\nbar\"", e.message
34
+ end
35
+ end
28
36
 
29
37
  # should.not.equal
30
38
 
@@ -53,8 +61,14 @@ module Spec
53
61
  def test_should_be_close_failing_cases
54
62
  assert_raise(ExpectationNotMetError) do
55
63
  3.5.should.be.close 3.0, 0.5
64
+ end
65
+ assert_raise(ExpectationNotMetError) do
56
66
  3.5.should.be.close 2.0, 0.5
67
+ end
68
+ assert_raise(ExpectationNotMetError) do
57
69
  3.5.should.be.close 4.0, 0.5
70
+ end
71
+ assert_raise(ExpectationNotMetError) do
58
72
  3.5.should.be.close 5.0, 0.5
59
73
  end
60
74
  end
@@ -149,35 +149,6 @@ module Spec
149
149
 
150
150
  end
151
151
 
152
- class CollectionWithSizeMethod
153
- def initialize; @list = []; end
154
- def size; @list.size; end
155
- def push(item); @list.push(item); end
156
- end
157
-
158
- class CollectionWithLengthMethod
159
- def initialize; @list = []; end
160
- def length; @list.size; end
161
- def push(item); @list.push(item); end
162
- end
163
-
164
- class CollectionOwner
165
- attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method
166
-
167
- def initialize
168
- @items_in_collection_with_size_method = CollectionWithSizeMethod.new
169
- @items_in_collection_with_length_method = CollectionWithLengthMethod.new
170
- end
171
-
172
- def add_to_collection_with_size_method(item)
173
- @items_in_collection_with_size_method.push(item)
174
- end
175
-
176
- def add_to_collection_with_length_method(item)
177
- @items_in_collection_with_length_method.push(item)
178
- end
179
- end
180
-
181
152
  end
182
153
  end
183
154
  end
@@ -5,101 +5,101 @@ module Spec
5
5
  module Helper
6
6
  class TypeTest < Test::Unit::TestCase
7
7
 
8
- # should.be.an.instance.of <class>
9
-
10
- def test_should_be_an_instance_of_should_pass_when_target_is_specified_class
11
- assert_nothing_raised do
12
- 5.should.be.an.instance.of Fixnum
13
- end
14
- end
15
-
16
- def test_should_be_an_instance_of_should_fail_when_target_is_not_specified_class
17
- assert_raise(ExpectationNotMetError) do
18
- 5.should.be.an.instance.of Integer
19
- end
20
- end
21
-
22
- # should.be.a.kind.of <class>
23
-
24
- def test_should_be_a_kind_of_should_pass_when_target_is_of_specified_class
25
- assert_nothing_raised do
26
- 5.should.be.a.kind.of Fixnum
27
- end
28
- end
8
+ # should.be.an.instance.of <class>
9
+
10
+ def test_should_be_an_instance_of_should_pass_when_target_is_specified_class
11
+ assert_nothing_raised do
12
+ 5.should.be.an.instance.of Fixnum
13
+ end
14
+ end
15
+
16
+ def test_should_be_an_instance_of_should_fail_when_target_is_not_specified_class
17
+ assert_raise(ExpectationNotMetError) do
18
+ 5.should.be.an.instance.of Integer
19
+ end
20
+ end
21
+
22
+ # should.be.a.kind.of <class>
23
+
24
+ def test_should_be_a_kind_of_should_pass_when_target_is_of_specified_class
25
+ assert_nothing_raised do
26
+ 5.should.be.a.kind.of Fixnum
27
+ end
28
+ end
29
29
 
30
- def test_should_be_a_kind_of_should_pass_when_target_is_of_subclass_of_specified_class
31
- assert_nothing_raised do
32
- 5.should.be.a.kind.of Integer
33
- end
34
- end
30
+ def test_should_be_a_kind_of_should_pass_when_target_is_of_subclass_of_specified_class
31
+ assert_nothing_raised do
32
+ 5.should.be.a.kind.of Integer
33
+ end
34
+ end
35
35
 
36
- def test_should_be_an_instance_of_should_fail_when_target_is_not_specified_class
37
- assert_raise(ExpectationNotMetError) do
38
- 5.should.be.a.kind.of String
39
- end
40
- end
41
-
42
- # should.not.be.an.instance_of <class>
43
-
44
- def test_should_not_be_an_instance_of_should_fail_when_target_is_of_specified_class
45
- assert_raise(ExpectationNotMetError) do
46
- 'hello'.should.not.be.an.instance.of String
47
- end
48
- end
49
-
50
- def test_should_be_an_instance_of_should_pass_when_target_is_not_of_specified_class
51
- assert_nothing_raised do
52
- [].should.not.be.an.instance.of String
53
- end
54
- end
36
+ def test_should_be_an_instance_of_should_fail_when_target_is_not_specified_class
37
+ assert_raise(ExpectationNotMetError) do
38
+ 5.should.be.a.kind.of String
39
+ end
40
+ end
41
+
42
+ # should.not.be.an.instance_of <class>
43
+
44
+ def test_should_not_be_an_instance_of_should_fail_when_target_is_of_specified_class
45
+ assert_raise(ExpectationNotMetError) do
46
+ 'hello'.should.not.be.an.instance.of String
47
+ end
48
+ end
49
+
50
+ def test_should_be_an_instance_of_should_pass_when_target_is_not_of_specified_class
51
+ assert_nothing_raised do
52
+ [].should.not.be.an.instance.of String
53
+ end
54
+ end
55
55
 
56
- # should.be.a.kind.of <class>
57
-
58
- def test_should_not_be_a_kind_of_should_fail_when_target_is_of_specified_class
59
- assert_raise(ExpectationNotMetError) do
60
- 5.should.not.be.a.kind.of Fixnum
61
- end
62
- end
56
+ # should.be.a.kind.of <class>
57
+
58
+ def test_should_not_be_a_kind_of_should_fail_when_target_is_of_specified_class
59
+ assert_raise(ExpectationNotMetError) do
60
+ 5.should.not.be.a.kind.of Fixnum
61
+ end
62
+ end
63
63
 
64
- def test_should_not_be_a_kind_of_should_fail_when_target_is_of_subclass_of_specified_class
65
- assert_raise(ExpectationNotMetError) do
66
- 5.should.not.be.a.kind.of Integer
67
- end
68
- end
64
+ def test_should_not_be_a_kind_of_should_fail_when_target_is_of_subclass_of_specified_class
65
+ assert_raise(ExpectationNotMetError) do
66
+ 5.should.not.be.a.kind.of Integer
67
+ end
68
+ end
69
69
 
70
- def test_should_not_be_an_instance_of_should_pass_when_target_is_not_specified_class
71
- assert_nothing_raised do
72
- 5.should.not.be.a.kind.of String
73
- end
74
- end
75
-
76
- # should.respond.to <message>
77
-
78
- def test_should_respond_to_should_pass_when_target_does
79
- assert_nothing_raised do
80
- "".should.respond.to :length
81
- end
82
- end
70
+ def test_should_not_be_an_instance_of_should_pass_when_target_is_not_specified_class
71
+ assert_nothing_raised do
72
+ 5.should.not.be.a.kind.of String
73
+ end
74
+ end
75
+
76
+ # should.respond.to <message>
77
+
78
+ def test_should_respond_to_should_pass_when_target_does
79
+ assert_nothing_raised do
80
+ "".should.respond.to :length
81
+ end
82
+ end
83
83
 
84
- def test_should_respond_to_should_fail_when_target_doesnt
85
- assert_raise(ExpectationNotMetError) do
86
- "".should.respond.to :connect
87
- end
88
- end
84
+ def test_should_respond_to_should_fail_when_target_doesnt
85
+ assert_raise(ExpectationNotMetError) do
86
+ "".should.respond.to :connect
87
+ end
88
+ end
89
89
 
90
- # should.not.respond.to <message>
91
-
92
- def test_not_should_respond_to_should_fail_when_target_does
93
- assert_raise(ExpectationNotMetError) do
94
- "".should.not.respond.to :length
95
- end
96
- end
90
+ # should.not.respond.to <message>
91
+
92
+ def test_not_should_respond_to_should_fail_when_target_does
93
+ assert_raise(ExpectationNotMetError) do
94
+ "".should.not.respond.to :length
95
+ end
96
+ end
97
97
 
98
- def test_not_should_respond_to_should_pass_when_target_doesnt
99
- assert_nothing_raised do
100
- "".should.not.respond.to :connect
101
- end
102
- end
98
+ def test_not_should_respond_to_should_pass_when_target_doesnt
99
+ assert_nothing_raised do
100
+ "".should.not.respond.to :connect
101
+ end
102
+ end
103
103
 
104
104
  end
105
105
  end