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.
- data/CHANGES +12 -0
- data/README +4 -2
- data/Rakefile +14 -4
- data/bin/spec +7 -7
- data/bin/test2spec +13 -8
- data/lib/spec/api/helper/diff.rb +53 -0
- data/lib/spec/api/helper/instance_helper.rb +11 -11
- data/lib/spec/api/helper/instance_negator.rb +11 -11
- data/lib/spec/api/helper/kind_helper.rb +11 -11
- data/lib/spec/api/helper/kind_negator.rb +11 -11
- data/lib/spec/api/helper/respond_helper.rb +11 -11
- data/lib/spec/api/helper/respond_negator.rb +11 -11
- data/lib/spec/api/helper/should_base.rb +6 -6
- data/lib/spec/api/helper/should_helper.rb +35 -35
- data/lib/spec/api/helper/should_negator.rb +20 -20
- data/lib/spec/rake/spectask.rb +15 -6
- data/lib/spec/runner.rb +1 -0
- data/lib/spec/runner/backtrace_tweaker.rb +2 -0
- data/lib/spec/runner/base_text_formatter.rb +3 -1
- data/lib/spec/runner/html_formatter.rb +153 -0
- data/lib/spec/runner/option_parser.rb +9 -2
- data/lib/spec/runner/progress_bar_formatter.rb +4 -0
- data/lib/spec/runner/rdoc_formatter.rb +3 -0
- data/lib/spec/runner/reporter.rb +5 -5
- data/lib/spec/runner/specdoc_formatter.rb +3 -0
- data/lib/spec/test_to_spec/sexp_transformer.rb +1 -0
- data/lib/spec/test_to_spec/translation_test_runner.rb +10 -2
- data/lib/spec/version.rb +1 -1
- data/test/spec/api/helper/arbitrary_predicate_test.rb +49 -73
- data/test/spec/api/helper/diff_test.rb +60 -0
- data/test/spec/api/helper/equality_test.rb +14 -0
- data/test/spec/api/helper/should_have_test.rb +0 -29
- data/test/spec/api/helper/typing_test.rb +87 -87
- data/test/spec/api/sugar_test.rb +0 -6
- data/test/spec/runner/backtrace_tweaker_test.rb +8 -2
- data/test/spec/runner/html_formatter_test.rb +47 -0
- data/test/spec/runner/option_parser_test.rb +0 -5
- data/test/test_classes.rb +73 -0
- data/test/test_helper.rb +3 -0
- metadata +8 -49
- data/doc/README +0 -3
- data/doc/config.yaml +0 -2
- data/doc/plugin/syntax.rb +0 -60
- data/doc/plugin/version.rb +0 -19
- data/doc/src/core_team.page +0 -31
- data/doc/src/default.css +0 -199
- data/doc/src/default.template +0 -31
- data/doc/src/documentation/index.page +0 -188
- data/doc/src/documentation/meta.info +0 -22
- data/doc/src/documentation/mocks.page +0 -287
- data/doc/src/documentation/underscores.page +0 -21
- data/doc/src/examples.page +0 -9
- data/doc/src/images/David_and_Aslak.jpg +0 -0
- data/doc/src/images/Whats_That_Dude.jpg +0 -0
- data/doc/src/images/ducks1.png +0 -0
- data/doc/src/images/ul.gif +0 -0
- data/doc/src/index.page +0 -74
- data/doc/src/meta.info +0 -33
- data/doc/src/tools/index.page +0 -49
- data/doc/src/tools/meta.info +0 -18
- data/doc/src/tools/rails.page +0 -132
- data/doc/src/tools/rake.page +0 -21
- data/doc/src/tools/rcov.page +0 -28
- data/doc/src/tools/spec.page +0 -129
- data/doc/src/tools/test2spec.page +0 -103
- data/doc/src/tutorials/index.page +0 -52
- data/doc/src/tutorials/meta.info +0 -36
- data/doc/src/tutorials/notes.txt +0 -263
- data/doc/src/tutorials/stack.rb +0 -11
- data/doc/src/tutorials/stack_01.page +0 -226
- data/doc/src/tutorials/stack_02.page +0 -182
- data/doc/src/tutorials/stack_03.page +0 -283
- data/doc/src/tutorials/stack_04.page +0 -164
- data/doc/src/tutorials/stack_04.page.orig +0 -123
- data/doc/src/tutorials/stack_05.page +0 -90
- data/doc/src/tutorials/stack_05.page.orig +0 -124
- data/doc/src/tutorials/stack_06.page +0 -359
- data/doc/src/tutorials/stack_06.page.orig +0 -359
- data/doc/src/tutorials/stack_spec.rb +0 -25
- data/doc/src/ul.gif +0 -0
data/lib/spec/version.rb
CHANGED
@@ -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
|
-
|
36
|
-
|
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
|
-
|
15
|
+
end
|
40
16
|
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
22
|
+
mock.__verify
|
47
23
|
end
|
48
24
|
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
30
|
+
mock.__verify
|
55
31
|
end
|
56
32
|
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
38
|
+
mock.__verify
|
63
39
|
end
|
64
40
|
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
46
|
+
mock.__verify
|
71
47
|
end
|
72
48
|
|
73
|
-
|
74
|
-
|
49
|
+
# should.be.xxx(args)
|
50
|
+
|
75
51
|
def test_should_be_xxx_with_args_passes_args_properly
|
76
|
-
|
77
|
-
|
52
|
+
mock = XxxMock.new(true)
|
53
|
+
assert_nothing_raised do
|
78
54
|
mock.should.be.yyy(1, 2, 3)
|
79
55
|
end
|
80
|
-
|
56
|
+
mock.__verify
|
81
57
|
end
|
82
58
|
|
83
59
|
# should.not.be.xxx
|
84
60
|
|
85
|
-
|
86
|
-
|
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
|
-
|
65
|
+
end
|
90
66
|
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
72
|
+
mock.__verify
|
97
73
|
end
|
98
74
|
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
80
|
+
mock.__verify
|
105
81
|
end
|
106
82
|
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
-
|
88
|
+
mock.__verify
|
113
89
|
end
|
114
90
|
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
96
|
+
mock.__verify
|
121
97
|
end
|
122
98
|
|
123
|
-
|
124
|
-
|
99
|
+
# should.be.xxx(args)
|
100
|
+
|
125
101
|
def test_should_not_be_xxx_with_args_passes_args_properly
|
126
|
-
|
127
|
-
|
102
|
+
mock = XxxMock.new(false)
|
103
|
+
assert_nothing_raised do
|
128
104
|
mock.should.not.be.yyy(1, 2, 3)
|
129
105
|
end
|
130
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|