rspec 0.5.16 → 0.6.0
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/EXAMPLES.rd +2 -2
- data/examples/custom_method_spec.rb +2 -2
- data/examples/mocking_spec.rb +2 -2
- data/lib/spec/api/helper.rb +0 -6
- data/lib/spec/api/helper/diff.rb +1 -0
- data/lib/spec/api/helper/have_helper.rb +7 -23
- data/lib/spec/api/helper/should_helper.rb +23 -19
- data/lib/spec/api/helper/should_negator.rb +10 -18
- data/lib/spec/api/mocks/argument_expectation.rb +2 -2
- data/lib/spec/api/mocks/message_expectation.rb +28 -53
- data/lib/spec/api/mocks/mock.rb +4 -5
- data/lib/spec/api/sugar.rb +6 -23
- data/lib/spec/runner/instance_exec.rb +11 -5
- data/lib/spec/version.rb +2 -2
- data/test/spec/api/helper/arbitrary_predicate_test.rb +16 -16
- data/test/spec/api/helper/containment_test.rb +16 -16
- data/test/spec/api/helper/identity_test.rb +8 -8
- data/test/spec/api/helper/object_equality_test.rb +13 -13
- data/test/spec/api/helper/raising_test.rb +14 -14
- data/test/spec/api/helper/regex_matching_test.rb +4 -4
- data/test/spec/api/helper/should_have_test.rb +26 -20
- data/test/spec/api/helper/should_satisfy_test.rb +5 -5
- data/test/spec/api/helper/throwing_test.rb +7 -7
- data/test/spec/api/helper/true_false_special_case_test.rb +12 -12
- data/test/spec/api/helper/typing_test.rb +14 -14
- data/test/spec/api/mocks/mock_arg_constraints_test.rb +26 -20
- data/test/spec/api/mocks/mock_counts_test.rb +431 -0
- data/test/spec/api/mocks/mock_ordering_test.rb +61 -42
- data/test/spec/api/mocks/mock_test.rb +68 -230
- data/test/spec/api/sugar_test.rb +1 -1
- data/test/spec/runner/backtrace_tweaker_test.rb +2 -2
- data/test/spec/runner/context_runner_test.rb +4 -4
- data/test/spec/runner/context_test.rb +22 -22
- data/test/spec/runner/execution_context_test.rb +1 -1
- data/test/spec/runner/reporter_test.rb +6 -6
- data/test/spec/runner/specification_test.rb +30 -30
- data/test/test_classes.rb +13 -4
- metadata +6 -11
- data/lib/spec/api/helper/instance_helper.rb +0 -15
- data/lib/spec/api/helper/instance_negator.rb +0 -15
- data/lib/spec/api/helper/kind_helper.rb +0 -15
- data/lib/spec/api/helper/kind_negator.rb +0 -15
- data/lib/spec/api/helper/respond_helper.rb +0 -15
- data/lib/spec/api/helper/respond_negator.rb +0 -15
- data/test/spec/api/duck_type_test.rb +0 -19
@@ -7,13 +7,13 @@ module Spec
|
|
7
7
|
|
8
8
|
def test_should_not_raise_when_objects_match
|
9
9
|
assert_nothing_raised do
|
10
|
-
"hi aslak".
|
10
|
+
"hi aslak".should_match /aslak/
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_should_raise_when_objects_do_not_match
|
15
15
|
assert_raise(ExpectationNotMetError) do
|
16
|
-
"hi aslak".
|
16
|
+
"hi aslak".should_match /steve/
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -21,13 +21,13 @@ module Spec
|
|
21
21
|
class ShouldNotMatchTest < Test::Unit::TestCase
|
22
22
|
def test_should_not_raise_when_objects_do_not_match
|
23
23
|
assert_nothing_raised do
|
24
|
-
"hi aslak".
|
24
|
+
"hi aslak".should_not_match /steve/
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_raise_when_objects_match
|
29
29
|
assert_raise(ExpectationNotMetError) do
|
30
|
-
"hi aslak".
|
30
|
+
"hi aslak".should_not_match /aslak/
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -15,38 +15,45 @@ module Spec
|
|
15
15
|
|
16
16
|
def test_should_raise_when_expecting_less_than_actual_length
|
17
17
|
assert_raise(ExpectationNotMetError) do
|
18
|
-
@owner.
|
18
|
+
@owner.should_have(2).items_in_collection_with_length_method
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_raise_when_expecting_less_than_actual_length_with_exactly
|
23
|
+
assert_raise(ExpectationNotMetError) do
|
24
|
+
@owner.should_have_exactly(2).items_in_collection_with_length_method
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
22
28
|
def test_should_raise_when_expecting_more_than_actual_length
|
23
29
|
assert_raise(ExpectationNotMetError) do
|
24
|
-
@owner.
|
30
|
+
@owner.should_have(4).items_in_collection_with_length_method
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
34
|
def test_should_not_raise_when_expecting_actual_length
|
29
35
|
assert_nothing_raised do
|
30
|
-
@owner.
|
36
|
+
@owner.should_have(3).items_in_collection_with_length_method
|
37
|
+
@owner.should_have_exactly(3).items_in_collection_with_length_method
|
31
38
|
end
|
32
39
|
end
|
33
|
-
|
34
40
|
|
35
41
|
def test_should_raise_when_expecting_less_than_actual_size
|
36
42
|
assert_raise(ExpectationNotMetError) do
|
37
|
-
@owner.
|
43
|
+
@owner.should_have(2).items_in_collection_with_size_method
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
41
47
|
def test_should_raise_when_expecting_more_than_actual_size
|
42
48
|
assert_raise(ExpectationNotMetError) do
|
43
|
-
@owner.
|
49
|
+
@owner.should_have(4).items_in_collection_with_size_method
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
53
|
def test_should_not_raise_when_expecting_actual_size
|
48
54
|
assert_nothing_raised do
|
49
|
-
@owner.
|
55
|
+
@owner.should_have(3).items_in_collection_with_size_method
|
56
|
+
@owner.should_have_exactly(3).items_in_collection_with_size_method
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
@@ -63,38 +70,38 @@ module Spec
|
|
63
70
|
|
64
71
|
def test_should_not_raise_when_expecting_less_than_actual_length
|
65
72
|
assert_nothing_raised do
|
66
|
-
@owner.
|
73
|
+
@owner.should_have_at_least(2).items_in_collection_with_length_method
|
67
74
|
end
|
68
75
|
end
|
69
76
|
|
70
77
|
def test_should_raise_when_expecting_more_than_actual_length
|
71
78
|
assert_raise(ExpectationNotMetError) do
|
72
|
-
@owner.
|
79
|
+
@owner.should_have_at_least(4).items_in_collection_with_length_method
|
73
80
|
end
|
74
81
|
end
|
75
82
|
|
76
83
|
def test_should_not_raise_when_expecting_actual_length
|
77
84
|
assert_nothing_raised do
|
78
|
-
@owner.
|
85
|
+
@owner.should_have_at_least(3).items_in_collection_with_length_method
|
79
86
|
end
|
80
87
|
end
|
81
88
|
|
82
89
|
|
83
90
|
def test_should_not_raise_when_expecting_less_than_actual_size
|
84
91
|
assert_nothing_raised do
|
85
|
-
@owner.
|
92
|
+
@owner.should_have_at_least(2).items_in_collection_with_size_method
|
86
93
|
end
|
87
94
|
end
|
88
95
|
|
89
96
|
def test_should_raise_when_expecting_more_than_actual_size
|
90
97
|
assert_raise(ExpectationNotMetError) do
|
91
|
-
@owner.
|
98
|
+
@owner.should_have_at_least(4).items_in_collection_with_size_method
|
92
99
|
end
|
93
100
|
end
|
94
101
|
|
95
102
|
def test_should_not_raise_when_expecting_actual_size
|
96
103
|
assert_nothing_raised do
|
97
|
-
@owner.
|
104
|
+
@owner.should_have_at_least(3).items_in_collection_with_size_method
|
98
105
|
end
|
99
106
|
end
|
100
107
|
|
@@ -112,43 +119,42 @@ module Spec
|
|
112
119
|
|
113
120
|
def test_should_raise_when_expecting_less_than_actual_length
|
114
121
|
assert_raise(ExpectationNotMetError) do
|
115
|
-
@owner.
|
122
|
+
@owner.should_have_at_most(2).items_in_collection_with_length_method
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
119
126
|
def test_should_not_raise_when_expecting_more_than_actual_length
|
120
127
|
assert_nothing_raised do
|
121
|
-
@owner.
|
128
|
+
@owner.should_have_at_most(4).items_in_collection_with_length_method
|
122
129
|
end
|
123
130
|
end
|
124
131
|
|
125
132
|
def test_should_not_raise_when_expecting_actual_length
|
126
133
|
assert_nothing_raised do
|
127
|
-
@owner.
|
134
|
+
@owner.should_have_at_most(3).items_in_collection_with_length_method
|
128
135
|
end
|
129
136
|
end
|
130
137
|
|
131
138
|
|
132
139
|
def test_should_raise_when_expecting_less_than_actual_size
|
133
140
|
assert_raise(ExpectationNotMetError) do
|
134
|
-
@owner.
|
141
|
+
@owner.should_have_at_most(2).items_in_collection_with_size_method
|
135
142
|
end
|
136
143
|
end
|
137
144
|
|
138
145
|
def test_should_not_raise_when_expecting_more_than_actual_size
|
139
146
|
assert_nothing_raised do
|
140
|
-
@owner.
|
147
|
+
@owner.should_have_at_most(4).items_in_collection_with_size_method
|
141
148
|
end
|
142
149
|
end
|
143
150
|
|
144
151
|
def test_should_not_raise_when_expecting_actual_size
|
145
152
|
assert_nothing_raised do
|
146
|
-
@owner.
|
153
|
+
@owner.should_have_at_most(3).items_in_collection_with_size_method
|
147
154
|
end
|
148
155
|
end
|
149
156
|
|
150
157
|
end
|
151
|
-
|
152
158
|
end
|
153
159
|
end
|
154
160
|
end
|
@@ -9,27 +9,27 @@ module Spec
|
|
9
9
|
|
10
10
|
def test_should_raise_exception_when_block_yields_false
|
11
11
|
assert_raise(ExpectationNotMetError) do
|
12
|
-
5.
|
12
|
+
5.should_satisfy {|target| false }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_not_raise_exception_when_block_yields_true
|
17
17
|
assert_nothing_raised do
|
18
|
-
5.
|
18
|
+
5.should_satisfy {|target| true }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
#
|
22
|
+
# should_not_satisfy
|
23
23
|
|
24
24
|
def test_should_raise_exception_when_block_yields_false_again
|
25
25
|
assert_raise(ExpectationNotMetError) do
|
26
|
-
5.
|
26
|
+
5.should_not_satisfy {|target| true }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_should_not_raise_exception_when_block_yields_true_again
|
31
31
|
assert_nothing_raised do
|
32
|
-
5.
|
32
|
+
5.should_not_satisfy {|target| false }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -7,19 +7,19 @@ module Spec
|
|
7
7
|
|
8
8
|
def test_should_pass_when_proper_symbol_is_thrown
|
9
9
|
assert_nothing_raised do
|
10
|
-
lambda { throw :foo }.
|
10
|
+
lambda { throw :foo }.should_throw :foo
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_should_fail_when_wrong_symbol_is_thrown
|
15
15
|
assert_raise(ExpectationNotMetError) do
|
16
|
-
lambda { throw :bar }.
|
16
|
+
lambda { throw :bar }.should_throw :foo
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_should_fail_when_no_symbol_is_thrown
|
21
21
|
assert_raise(ExpectationNotMetError) do
|
22
|
-
lambda { ''.to_s }.
|
22
|
+
lambda { ''.to_s }.should_throw :foo
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -28,25 +28,25 @@ module Spec
|
|
28
28
|
|
29
29
|
def test_should_fail_when_expected_symbol_is_actually_thrown
|
30
30
|
assert_raise(ExpectationNotMetError) do
|
31
|
-
lambda { throw :foo }.
|
31
|
+
lambda { throw :foo }.should_not_throw :foo
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_should_pass_when_expected_symbol_is_thrown
|
36
36
|
assert_nothing_raised do
|
37
|
-
lambda { throw :bar }.
|
37
|
+
lambda { throw :bar }.should_not_throw :foo
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_should_pass_when_no_symbol_is_thrown
|
42
42
|
assert_nothing_raised do
|
43
|
-
lambda { ''.to_s }.
|
43
|
+
lambda { ''.to_s }.should_not_throw :foo
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_should_pass_when_no_symbol_is_thrown_and_none_is_specified
|
48
48
|
assert_nothing_raised do
|
49
|
-
lambda { ''.to_s }.
|
49
|
+
lambda { ''.to_s }.should_not_throw
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -7,37 +7,37 @@ module Spec
|
|
7
7
|
|
8
8
|
def test_should_raise_when_object_is_nil
|
9
9
|
assert_raise(ExpectationNotMetError) do
|
10
|
-
nil.
|
10
|
+
nil.should_be true
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_should_raise_when_object_is_false
|
15
15
|
assert_raise(ExpectationNotMetError) do
|
16
|
-
false.
|
16
|
+
false.should_be true
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_shouldnt_raise_when_object_is_true
|
21
21
|
assert_nothing_raised do
|
22
|
-
true.
|
22
|
+
true.should_be true
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_shouldnt_raise_when_object_is_a_number
|
27
27
|
assert_nothing_raised do
|
28
|
-
5.
|
28
|
+
5.should_be true
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_shouldnt_raise_when_object_is_a_string
|
33
33
|
assert_nothing_raised do
|
34
|
-
"hello".
|
34
|
+
"hello".should_be true
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_shouldnt_raise_when_object_is_a_some_random_object
|
39
39
|
assert_nothing_raised do
|
40
|
-
self.
|
40
|
+
self.should_be true
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -45,37 +45,37 @@ module Spec
|
|
45
45
|
class ShouldBeFalseTest < Test::Unit::TestCase
|
46
46
|
def test_shouldnt_raise_when_object_is_nil
|
47
47
|
assert_nothing_raised do
|
48
|
-
nil.
|
48
|
+
nil.should_be false
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_shouldnt_raise_when_object_is_false
|
53
53
|
assert_nothing_raised do
|
54
|
-
false.
|
54
|
+
false.should_be false
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_should_raise_when_object_is_true
|
59
59
|
assert_raise(ExpectationNotMetError) do
|
60
|
-
true.
|
60
|
+
true.should_be false
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_shouldnt_raise_when_object_is_a_number
|
65
65
|
assert_raise(ExpectationNotMetError) do
|
66
|
-
5.
|
66
|
+
5.should_be false
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_shouldnt_raise_when_object_is_a_string
|
71
71
|
assert_raise(ExpectationNotMetError) do
|
72
|
-
"hello".
|
72
|
+
"hello".should_be false
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_shouldnt_raise_when_object_is_a_some_random_object
|
77
77
|
assert_raise(ExpectationNotMetError) do
|
78
|
-
self.
|
78
|
+
self.should_be false
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -7,13 +7,13 @@ module Spec
|
|
7
7
|
|
8
8
|
def test_should_pass_when_target_is_specified_class
|
9
9
|
assert_nothing_raised do
|
10
|
-
5.
|
10
|
+
5.should_be_an_instance_of Fixnum
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_should_fail_when_target_is_not_specified_class
|
15
15
|
assert_raise(ExpectationNotMetError) do
|
16
|
-
5.
|
16
|
+
5.should_be_an_instance_of Integer
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -22,19 +22,19 @@ module Spec
|
|
22
22
|
|
23
23
|
def test_should_pass_when_target_is_of_specified_class
|
24
24
|
assert_nothing_raised do
|
25
|
-
5.
|
25
|
+
5.should_be_a_kind_of Fixnum
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_should_pass_when_target_is_of_subclass_of_specified_class
|
30
30
|
assert_nothing_raised do
|
31
|
-
5.
|
31
|
+
5.should_be_a_kind_of Integer
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_should_fail_when_target_is_not_specified_class
|
36
36
|
assert_raise(ExpectationNotMetError) do
|
37
|
-
5.
|
37
|
+
5.should_be_a_kind_of String
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -43,13 +43,13 @@ module Spec
|
|
43
43
|
|
44
44
|
def test_should_fail_when_target_is_of_specified_class
|
45
45
|
assert_raise(ExpectationNotMetError) do
|
46
|
-
'hello'.
|
46
|
+
'hello'.should_not_be_an_instance_of String
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_pass_when_target_is_not_of_specified_class
|
51
51
|
assert_nothing_raised do
|
52
|
-
[].
|
52
|
+
[].should_not_be_an_instance_of String
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -58,19 +58,19 @@ module Spec
|
|
58
58
|
|
59
59
|
def test_should_fail_when_target_is_of_specified_class
|
60
60
|
assert_raise(ExpectationNotMetError) do
|
61
|
-
5.
|
61
|
+
5.should_not_be_a_kind_of Fixnum
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_should_fail_when_target_is_of_subclass_of_specified_class
|
66
66
|
assert_raise(ExpectationNotMetError) do
|
67
|
-
5.
|
67
|
+
5.should_not_be_a_kind_of Integer
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_should_pass_when_target_is_not_specified_class
|
72
72
|
assert_nothing_raised do
|
73
|
-
5.
|
73
|
+
5.should_not_be_a_kind_of String
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -78,13 +78,13 @@ module Spec
|
|
78
78
|
class ShouldRespondToTest < Test::Unit::TestCase
|
79
79
|
def test_should_pass_when_target_responds_to
|
80
80
|
assert_nothing_raised do
|
81
|
-
"".
|
81
|
+
"".should_respond_to :length
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_should_fail_when_target_doesnt_respond_to
|
86
86
|
assert_raise(ExpectationNotMetError) do
|
87
|
-
"".
|
87
|
+
"".should_respond_to :connect
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -92,13 +92,13 @@ module Spec
|
|
92
92
|
class ShouldNotRespondToTest < Test::Unit::TestCase
|
93
93
|
def test_should_fail_when_target_responds_to
|
94
94
|
assert_raise(ExpectationNotMetError) do
|
95
|
-
"".
|
95
|
+
"".should_not_respond_to :length
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_should_pass_when_target_doesnt_respond_to
|
100
100
|
assert_nothing_raised do
|
101
|
-
"".
|
101
|
+
"".should_not_respond_to :connect
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|