rspec 0.4.0 → 0.5.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 +7 -12
- data/Rakefile +17 -12
- data/TUTORIAL +1 -1
- data/WHY_RSPEC +115 -0
- data/bin/spec +17 -4
- data/bin/test2rspec +35 -0
- data/examples/airport_spec.rb +35 -0
- data/examples/mocking_spec.rb +16 -0
- data/examples/spec_framework_spec.rb +28 -0
- data/examples/stack.rb +36 -0
- data/examples/stack_spec.rb +112 -0
- data/lib/spec.rb +5 -18
- data/lib/spec/api.rb +4 -0
- data/lib/spec/{exceptions.rb → api/exceptions.rb} +1 -1
- data/lib/spec/{expectations.rb → api/expectations.rb} +5 -4
- data/lib/spec/api/helper.rb +10 -0
- data/lib/spec/{have_helper.rb → api/helper/have_helper.rb} +1 -1
- data/lib/spec/{instance_helper.rb → api/helper/instance_helper.rb} +0 -0
- data/lib/spec/{instance_negator.rb → api/helper/instance_negator.rb} +0 -0
- data/lib/spec/{kind_helper.rb → api/helper/kind_helper.rb} +0 -0
- data/lib/spec/{kind_negator.rb → api/helper/kind_negator.rb} +0 -0
- data/lib/spec/{respond_helper.rb → api/helper/respond_helper.rb} +0 -0
- data/lib/spec/{respond_negator.rb → api/helper/respond_negator.rb} +0 -0
- data/lib/spec/{should_base.rb → api/helper/should_base.rb} +6 -4
- data/lib/spec/{should_helper.rb → api/helper/should_helper.rb} +12 -0
- data/lib/spec/{should_negator.rb → api/helper/should_negator.rb} +11 -0
- data/lib/spec/api/mock.rb +184 -0
- data/lib/spec/rake/spectask.rb +153 -0
- data/lib/spec/runner.rb +9 -0
- data/lib/spec/runner/backtrace_tweaker.rb +17 -0
- data/lib/spec/runner/context.rb +47 -0
- data/lib/spec/runner/context_runner.rb +52 -0
- data/lib/spec/runner/execution_context.rb +15 -0
- data/lib/spec/runner/instance_exec.rb +15 -0
- data/lib/spec/runner/kernel_ext.rb +6 -0
- data/lib/spec/runner/option_parser.rb +41 -0
- data/lib/spec/runner/rdoc_formatter.rb +17 -0
- data/lib/spec/runner/simple_text_reporter.rb +92 -0
- data/lib/spec/runner/specification.rb +42 -0
- data/lib/spec/tool/command_line.rb +39 -0
- data/lib/spec/tool/test_unit_translator.rb +112 -0
- data/lib/spec/version.rb +13 -0
- data/test/spec/api/helper/arbitrary_predicate_test.rb +121 -0
- data/test/spec/api/helper/containment_test.rb +117 -0
- data/test/spec/api/helper/equality_test.rb +46 -0
- data/test/spec/api/helper/identity_test.rb +68 -0
- data/test/spec/api/helper/raising_test.rb +50 -0
- data/test/spec/api/helper/regex_matching_test.rb +38 -0
- data/test/spec/api/helper/should_satisfy_test.rb +37 -0
- data/test/spec/api/helper/throwing_test.rb +56 -0
- data/test/spec/api/helper/true_false_special_case_test.rb +87 -0
- data/test/spec/api/helper/typing_test.rb +107 -0
- data/test/spec/api/mock_test.rb +161 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +20 -0
- data/test/spec/runner/context_runner_test.rb +19 -0
- data/test/spec/runner/context_test.rb +29 -0
- data/test/spec/runner/execution_context_test.rb +13 -0
- data/test/spec/runner/option_parser_test.rb +50 -0
- data/test/spec/runner/rdoc_formatter_test.rb +23 -0
- data/test/spec/runner/simple_text_reporter_test.rb +128 -0
- data/test/spec/runner/specification_test.rb +70 -0
- data/test/spec/tool/command_line_test.rb +22 -0
- data/test/spec/tool/test_unit_api_spec.rb +61 -0
- data/test/spec/tool/test_unit_api_test.rb +61 -0
- data/test/spec/tool/test_unit_translator_test.rb +29 -0
- data/test/test_helper.rb +8 -0
- metadata +89 -67
- data/examples/add_specification_spec.rb +0 -15
- data/examples/craps.rb +0 -15
- data/examples/craps_spec.rb +0 -105
- data/examples/dsl_spec.rb +0 -8
- data/examples/movie.rb +0 -7
- data/examples/movie_list.rb +0 -19
- data/examples/movie_spec.rb +0 -37
- data/lib/spec/collector.rb +0 -17
- data/lib/spec/context.rb +0 -89
- data/lib/spec/dsl.rb +0 -23
- data/lib/spec/gui_runner.rb +0 -59
- data/lib/spec/mock.rb +0 -183
- data/lib/spec/text_runner.rb +0 -75
- data/test/collection_owner.rb +0 -48
- data/test/context_fixtures_test.rb +0 -71
- data/test/context_run_test.rb +0 -174
- data/test/dsl_test.rb +0 -48
- data/test/error_reporting_test.rb +0 -225
- data/test/expectations_for_should_have_test.rb +0 -144
- data/test/expectations_test.rb +0 -592
- data/test/get_classes.rb +0 -6
- data/test/gui_runner_test.rb +0 -162
- data/test/mock_test.rb +0 -157
- data/test/spec_collection_test.rb +0 -39
- data/test/specification_addition_test.rb +0 -29
- data/test/specification_identification_test.rb +0 -71
- data/test/text_runner_test.rb +0 -146
@@ -1,144 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'collection_owner'
|
4
|
-
require 'spec'
|
5
|
-
|
6
|
-
class ExpectationsForShouldHaveTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@owner = CollectionOwner.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def set_length(number)
|
13
|
-
(1..number).each do |n|
|
14
|
-
@owner.add_to_collection_with_length_method(n.to_s)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_size(number)
|
19
|
-
(1..number).each do |n|
|
20
|
-
@owner.add_to_collection_with_size_method(n.to_s)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_should_have_should_pass_if_responds_to_length_and_has_correct_number
|
25
|
-
assert_nothing_raised do
|
26
|
-
set_length 3
|
27
|
-
@owner.should.have(3).items_in_collection_with_length_method
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_should_have_should_pass_if_responds_to_size_and_has_correct_number
|
32
|
-
assert_nothing_raised do
|
33
|
-
set_size 7
|
34
|
-
@owner.should.have(7).items_in_collection_with_size_method
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_should_have_should_fail_if_responds_to_length_and_has_wrong_number
|
39
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
40
|
-
set_length 12
|
41
|
-
@owner.should.have(17).items_in_collection_with_length_method
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_should_have_should_fail_if_responds_to_size_and_has_wrong_number
|
46
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
47
|
-
set_size 6
|
48
|
-
@owner.should.have(2).items_in_collection_with_size_method
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# at.least w/ length
|
53
|
-
|
54
|
-
def test_should_have_at_least_should_pass_if_responds_to_length_and_has_exact_number
|
55
|
-
assert_nothing_raised do
|
56
|
-
set_length 1
|
57
|
-
@owner.should.have.at.least(1).items_in_collection_with_length_method
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_should_have_at_least_should_pass_if_responds_to_length_and_has_higher_number
|
62
|
-
assert_nothing_raised do
|
63
|
-
set_length 2
|
64
|
-
@owner.should.have.at.least(1).items_in_collection_with_length_method
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_should_have_at_least_should_fail_if_responds_to_length_and_has_lower_number
|
69
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
70
|
-
set_length 1
|
71
|
-
@owner.should.have.at.least(2).items_in_collection_with_length_method
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# at.least w/ size
|
76
|
-
|
77
|
-
def test_should_have_at_least_should_pass_if_responds_to_size_and_has_exact_number
|
78
|
-
assert_nothing_raised do
|
79
|
-
set_size 1
|
80
|
-
@owner.should.have.at.least(1).items_in_collection_with_size_method
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_should_have_at_least_should_pass_if_responds_to_size_and_has_higher_number
|
85
|
-
assert_nothing_raised do
|
86
|
-
set_size 2
|
87
|
-
@owner.should.have.at.least(1).items_in_collection_with_size_method
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_should_have_at_least_should_fail_if_responds_to_size_and_has_lower_number
|
92
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
93
|
-
set_size 1
|
94
|
-
@owner.should.have.at.least(2).items_in_collection_with_size_method
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# at.most w/ length
|
99
|
-
|
100
|
-
def test_should_have_at_most_should_pass_if_responds_to_length_and_has_exact_number
|
101
|
-
assert_nothing_raised do
|
102
|
-
set_length 1
|
103
|
-
@owner.should.have.at.most(1).items_in_collection_with_length_method
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_should_have_at_most_should_pass_if_responds_to_length_and_has_lower_number
|
108
|
-
assert_nothing_raised do
|
109
|
-
set_length 1
|
110
|
-
@owner.should.have.at.most(2).items_in_collection_with_length_method
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_should_have_at_most_should_fail_if_responds_to_length_and_has_higher_number
|
115
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
116
|
-
set_length 2
|
117
|
-
@owner.should.have.at.most(1).items_in_collection_with_length_method
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# at.most w/ size
|
122
|
-
|
123
|
-
def test_should_have_at_most_should_pass_if_responds_to_size_and_has_exact_number
|
124
|
-
assert_nothing_raised do
|
125
|
-
set_size 1
|
126
|
-
@owner.should.have.at.most(1).items_in_collection_with_size_method
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_should_have_at_most_should_pass_if_responds_to_size_and_has_lower_number
|
131
|
-
assert_nothing_raised do
|
132
|
-
set_size 1
|
133
|
-
@owner.should.have.at.most(2).items_in_collection_with_size_method
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_should_have_at_most_should_fail_if_responds_to_size_and_has_higher_number
|
138
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
139
|
-
set_size 2
|
140
|
-
@owner.should.have.at.most(1).items_in_collection_with_size_method
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
data/test/expectations_test.rb
DELETED
@@ -1,592 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
require 'spec'
|
4
|
-
|
5
|
-
|
6
|
-
class DummyObject
|
7
|
-
|
8
|
-
def initialize(foo)
|
9
|
-
@foo = foo
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
class ExpectationsTest < Test::Unit::TestCase
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@dummy = 'dummy'
|
19
|
-
@equal_dummy = 'dummy'
|
20
|
-
@another_dummy = 'another_dummy'
|
21
|
-
@nil_var = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
# should.satisfy
|
25
|
-
|
26
|
-
def test_should_raise_exception_when_block_yields_false
|
27
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
28
|
-
5.should.satisfy { false }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_should_not_raise_exception_when_block_yields_true
|
33
|
-
assert_nothing_raised do
|
34
|
-
5.should.satisfy { true }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# should.not.satisfy
|
39
|
-
|
40
|
-
def test_should_raise_exception_when_block_yields_false
|
41
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
42
|
-
5.should.not.satisfy { true }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_should_not_raise_exception_when_block_yields_true
|
47
|
-
assert_nothing_raised do
|
48
|
-
5.should.not.satisfy { false }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# should.equal
|
53
|
-
|
54
|
-
def test_should_equal_should_not_raise_when_objects_are_equal
|
55
|
-
assert_nothing_raised do
|
56
|
-
@dummy.should.equal @equal_dummy
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_should_equal_should_raise_when_objects_are_not_equal
|
61
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
62
|
-
@dummy.should.equal @another_dummy
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# should.not.equal
|
67
|
-
|
68
|
-
def test_should_not_equal_should_not_raise_when_objects_are_not_equal
|
69
|
-
assert_nothing_raised do
|
70
|
-
@dummy.should.not.equal @another_dummy
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_should_not_equal_should_raise_when_objects_are_not_equal
|
75
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
76
|
-
@dummy.should.not.equal @equal_dummy
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# should.be
|
81
|
-
|
82
|
-
def test_should_be_same_as_should_not_raise_when_objects_are_same
|
83
|
-
assert_nothing_raised do
|
84
|
-
@dummy.should.be @dummy
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_should_be_same_as_should_raise_when_objects_are_not_same
|
89
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
90
|
-
@dummy.should.be @equal_dummy
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_should_be_nil_should_not_raise_when_object_is_nil
|
95
|
-
assert_nothing_raised do
|
96
|
-
@nil_var.should.be nil
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_should_be_nil_should_raise_when_object_is_not_nil
|
101
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
102
|
-
@dummy.should.be nil
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# should.not.be
|
107
|
-
|
108
|
-
def test_should_not_be_same_as_should_not_raise_when_objects_are_not_same
|
109
|
-
assert_nothing_raised do
|
110
|
-
@dummy.should.not.be @equal_dummy
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_should_not_be_same_as_should_raise_when_objects_are_not_same
|
115
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
116
|
-
@dummy.should.not.be @dummy
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_should_not_be_nil_should_not_raise_when_object_is_not_nil
|
121
|
-
assert_nothing_raised do
|
122
|
-
@dummy.should.not.be nil
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_should_not_be_nil_should_raise_when_object_is_nil
|
127
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
128
|
-
@nil_var.should.not.be nil
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
# should.match
|
133
|
-
|
134
|
-
def test_should_match_should_not_raise_when_objects_match
|
135
|
-
assert_nothing_raised do
|
136
|
-
"hi aslak".should.match /aslak/
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_should_equal_should_raise_when_objects_do_not_match
|
141
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
142
|
-
"hi aslak".should.match /steve/
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# should.not.match
|
147
|
-
|
148
|
-
def test_should_not_match_should_not_raise_when_objects_do_not_match
|
149
|
-
assert_nothing_raised do
|
150
|
-
"hi aslak".should.not.match /steve/
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_should_not_match_should_raise_when_objects_match
|
155
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
156
|
-
"hi aslak".should.not.match /aslak/
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# should.be.xxx
|
161
|
-
|
162
|
-
def test_should_be_xxx_should_raise_when_target_doesnt_understand_xxx
|
163
|
-
assert_raise(NoMethodError) do
|
164
|
-
5.should.be.xxx
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_should_be_xxx_should_raise_when_sending_xxx_to_target_returns_false
|
169
|
-
mock = Mock.new("xxx? returns false")
|
170
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(false)
|
171
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
172
|
-
mock.should.be.xxx
|
173
|
-
end
|
174
|
-
mock.__verify
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_should_be_xxx_should_raise_when_sending_xxx_to_target_returns_nil
|
178
|
-
mock = Mock.new("xxx? returns nil")
|
179
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(nil)
|
180
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
181
|
-
mock.should.be.xxx
|
182
|
-
end
|
183
|
-
mock.__verify
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_should_be_xxx_should_not_raise_when_sending_xxx_to_target_returns_true
|
187
|
-
mock = Mock.new("xxx? returns true")
|
188
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(true)
|
189
|
-
assert_nothing_raised do
|
190
|
-
mock.should.be.xxx
|
191
|
-
end
|
192
|
-
mock.__verify
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_should_be_xxx_should_not_raise_when_sending_xxx_to_target_returns_something_other_than_true_false_or_nil
|
196
|
-
mock = Mock.new("xxx? returns 5")
|
197
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(5)
|
198
|
-
assert_nothing_raised do
|
199
|
-
mock.should.be.xxx
|
200
|
-
end
|
201
|
-
mock.__verify
|
202
|
-
end
|
203
|
-
|
204
|
-
# should.be.xxx(args)
|
205
|
-
|
206
|
-
def test_should_be_xxx_with_args_passes_args_properly
|
207
|
-
mock = Mock.new("xxx?(1 2 3) returns true")
|
208
|
-
mock.should_receive(:xxx?).once.with(1, 2, 3).and_return(true)
|
209
|
-
assert_nothing_raised do
|
210
|
-
mock.should.be.xxx(1, 2, 3)
|
211
|
-
end
|
212
|
-
mock.__verify
|
213
|
-
end
|
214
|
-
|
215
|
-
# should.not.be.xxx
|
216
|
-
|
217
|
-
def test_should_not_be_xxx_should_raise_when_target_doesnt_understand_xxx
|
218
|
-
assert_raise(NoMethodError) do
|
219
|
-
5.should.not.be.xxx
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_should_not_be_xxx_should_raise_when_sending_xxx_to_target_returns_true
|
224
|
-
mock = Mock.new("xxx? returns true")
|
225
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(true)
|
226
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
227
|
-
mock.should.not.be.xxx
|
228
|
-
end
|
229
|
-
mock.__verify
|
230
|
-
end
|
231
|
-
|
232
|
-
def test_should_not_be_xxx_shouldnt_raise_when_sending_xxx_to_target_returns_nil
|
233
|
-
mock = Mock.new("xxx? returns nil")
|
234
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(nil)
|
235
|
-
assert_nothing_raised do
|
236
|
-
mock.should.not.be.xxx
|
237
|
-
end
|
238
|
-
mock.__verify
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_should_not_be_xxx_shouldnt_raise_when_sending_xxx_to_target_returns_false
|
242
|
-
mock = Mock.new("xxx? returns false")
|
243
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(false)
|
244
|
-
assert_nothing_raised do
|
245
|
-
mock.should.not.be.xxx
|
246
|
-
end
|
247
|
-
mock.__verify
|
248
|
-
end
|
249
|
-
|
250
|
-
def test_should_not_be_xxx_should_raise_when_sending_xxx_to_target_returns_something_other_than_true_false_or_nil
|
251
|
-
mock = Mock.new("xxx? returns 5")
|
252
|
-
mock.should_receive(:xxx?).once.with_no_args.and_return(5)
|
253
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
254
|
-
mock.should.not.be.xxx
|
255
|
-
end
|
256
|
-
mock.__verify
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
# should.be.xxx(args)
|
261
|
-
|
262
|
-
def test_should_not_be_xxx_with_args_passes_args_properly
|
263
|
-
mock = Mock.new("xxx?(1 2 3) returns false")
|
264
|
-
mock.should_receive(:xxx?).once.with(1, 2, 3).and_return(false)
|
265
|
-
assert_nothing_raised do
|
266
|
-
mock.should.not.be.xxx(1, 2, 3)
|
267
|
-
end
|
268
|
-
mock.__verify
|
269
|
-
end
|
270
|
-
|
271
|
-
# should_include
|
272
|
-
|
273
|
-
def test_should_include_shouldnt_raise_when_string_inclusion_is_present
|
274
|
-
assert_nothing_raised do
|
275
|
-
@dummy.should.include "mm"
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_should_include_should_raise_when_string_inclusion_is_missing
|
280
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
281
|
-
@dummy.should.include "abc"
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_should_include_shouldnt_raise_when_array_inclusion_is_present
|
286
|
-
assert_nothing_raised do
|
287
|
-
[1, 2, 3].should.include 2
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_should_include_should_raise_when_array_inclusion_is_missing
|
292
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
293
|
-
[1, 2, 3].should.include 5
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_should_include_shouldnt_raise_when_hash_inclusion_is_present
|
298
|
-
assert_nothing_raised do
|
299
|
-
{"a"=>1}.should.include "a"
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def test_should_include_should_raise_when_hash_inclusion_is_missing
|
304
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
305
|
-
{"a"=>1}.should.include "b"
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
def test_should_include_shouldnt_raise_when_enumerable_inclusion_is_present
|
310
|
-
assert_nothing_raised do
|
311
|
-
IO.constants.should.include "SEEK_SET"
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
def test_should_include_should_raise_when_enumerable_inclusion_is_missing
|
316
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
317
|
-
IO.constants.should.include "BLAH"
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
# should_not_include
|
322
|
-
|
323
|
-
def test_should_not_include_shouldnt_raise_when_string_inclusion_is_missing
|
324
|
-
assert_nothing_raised do
|
325
|
-
@dummy.should.not.include "abc"
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def test_should_not_include_should_raise_when_string_inclusion_is_present
|
330
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
331
|
-
@dummy.should.not.include "mm"
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
def test_should_not_include_shouldnt_raise_when_array_inclusion_is_missing
|
336
|
-
assert_nothing_raised do
|
337
|
-
[1, 2, 3].should.not.include 5
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
def test_should_not_include_should_raise_when_array_inclusion_is_present
|
342
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
343
|
-
[1, 2, 3].should.not.include 2
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
def test_should_not_include_shouldnt_raise_when_hash_inclusion_is_missing
|
348
|
-
assert_nothing_raised do
|
349
|
-
{"a"=>1}.should.not.include "b"
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
def test_should_not_include_should_raise_when_hash_inclusion_is_present
|
354
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
355
|
-
{"a"=>1}.should.not.include "a"
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
def test_should_not_include_shouldnt_raise_when_enumerable_inclusion_is_present
|
360
|
-
assert_nothing_raised do
|
361
|
-
IO.constants.should.not.include "BLAH"
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
def test_should_not_include_should_raise_when_enumerable_inclusion_is_missing
|
366
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
367
|
-
IO.constants.should.not.include "SEEK_SET"
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
# violated
|
372
|
-
|
373
|
-
def test_violated_should_raise
|
374
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
375
|
-
c = Spec::Context.new
|
376
|
-
c.violated "boo"
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
# should.be true
|
381
|
-
|
382
|
-
def test_should_be_true_should_raise_when_object_is_nil
|
383
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
384
|
-
nil.should.be true
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
def test_should_be_true_should_raise_when_object_is_false
|
389
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
390
|
-
false.should.be true
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
def test_should_be_true_shouldnt_raise_when_object_is_true
|
395
|
-
assert_nothing_raised do
|
396
|
-
true.should.be true
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
def test_should_be_true_shouldnt_raise_when_object_is_a_number
|
401
|
-
assert_nothing_raised do
|
402
|
-
5.should.be true
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
def test_should_be_true_shouldnt_raise_when_object_is_a_string
|
407
|
-
assert_nothing_raised do
|
408
|
-
"hello".should.be true
|
409
|
-
end
|
410
|
-
end
|
411
|
-
|
412
|
-
def test_should_be_true_shouldnt_raise_when_object_is_a_some_random_object
|
413
|
-
assert_nothing_raised do
|
414
|
-
self.should.be true
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
# should.be false
|
419
|
-
|
420
|
-
def test_should_be_false_shouldnt_raise_when_object_is_nil
|
421
|
-
assert_nothing_raised do
|
422
|
-
nil.should.be false
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
def test_should_be_true_shouldnt_raise_when_object_is_false
|
427
|
-
assert_nothing_raised do
|
428
|
-
false.should.be false
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|
432
|
-
def test_should_be_true_should_raise_when_object_is_true
|
433
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
434
|
-
true.should.be false
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
def test_should_be_true_shouldnt_raise_when_object_is_a_number
|
439
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
440
|
-
5.should.be false
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
def test_should_be_true_shouldnt_raise_when_object_is_a_string
|
445
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
446
|
-
"hello".should.be false
|
447
|
-
end
|
448
|
-
end
|
449
|
-
|
450
|
-
def test_should_be_true_shouldnt_raise_when_object_is_a_some_random_object
|
451
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
452
|
-
self.should.be false
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
# should.raise
|
457
|
-
|
458
|
-
def test_should_raise_should_pass_when_proper_exception_is_raised
|
459
|
-
assert_nothing_raised do
|
460
|
-
proc { ''.nonexistant_method }.should.raise NoMethodError
|
461
|
-
end
|
462
|
-
end
|
463
|
-
|
464
|
-
def test_should_raise_should_fail_when_wrong_exception_is_raised
|
465
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
466
|
-
proc { ''.nonexistant_method }.should.raise SyntaxError
|
467
|
-
end
|
468
|
-
end
|
469
|
-
|
470
|
-
def test_should_raise_should_fail_when_no_exception_is_raised
|
471
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
472
|
-
proc {''.to_s}.should.raise NoMethodError
|
473
|
-
end
|
474
|
-
end
|
475
|
-
|
476
|
-
# should.not.raise
|
477
|
-
|
478
|
-
def test_should_not_raise_should_fail_when_specific_exception_is_raised
|
479
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
480
|
-
proc { ''.nonexistant_method }.should.not.raise NoMethodError
|
481
|
-
end
|
482
|
-
end
|
483
|
-
|
484
|
-
def test_should_not_raise_should_pass_when_other_exception_is_raised
|
485
|
-
assert_nothing_raised do
|
486
|
-
proc { ''.nonexistant_method }.should.not.raise SyntaxError
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
def test_should_not_raise_should_pass_when_no_exception_is_raised
|
491
|
-
assert_nothing_raised do
|
492
|
-
proc { ''.to_s }.should.not.raise NoMethodError
|
493
|
-
end
|
494
|
-
end
|
495
|
-
|
496
|
-
# should.be.an.instance.of <class>
|
497
|
-
|
498
|
-
def test_should_be_an_instance_of_should_pass_when_target_is_specified_class
|
499
|
-
assert_nothing_raised do
|
500
|
-
5.should.be.an.instance.of Fixnum
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
def test_should_be_an_instance_of_should_fail_when_target_is_not_specified_class
|
505
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
506
|
-
5.should.be.an.instance.of Integer
|
507
|
-
end
|
508
|
-
end
|
509
|
-
|
510
|
-
# should.be.a.kind.of <class>
|
511
|
-
|
512
|
-
def test_should_be_a_kind_of_should_pass_when_target_is_of_specified_class
|
513
|
-
assert_nothing_raised do
|
514
|
-
5.should.be.a.kind.of Fixnum
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
def test_should_be_a_kind_of_should_pass_when_target_is_of_subclass_of_specified_class
|
519
|
-
assert_nothing_raised do
|
520
|
-
5.should.be.a.kind.of Integer
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
def test_should_be_an_instance_of_should_fail_when_target_is_not_specified_class
|
525
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
526
|
-
5.should.be.a.kind.of String
|
527
|
-
end
|
528
|
-
end
|
529
|
-
|
530
|
-
# should.not.be.an.instance_of <class>
|
531
|
-
|
532
|
-
def test_should_not_be_an_instance_of_should_fail_when_target_is_of_specified_class
|
533
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
534
|
-
'hello'.should.not.be.an.instance.of String
|
535
|
-
end
|
536
|
-
end
|
537
|
-
|
538
|
-
def test_should_be_an_instance_of_should_pass_when_target_is_not_of_specified_class
|
539
|
-
assert_nothing_raised do
|
540
|
-
[].should.not.be.an.instance.of String
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
# should.be.a.kind.of <class>
|
545
|
-
|
546
|
-
def test_should_not_be_a_kind_of_should_fail_when_target_is_of_specified_class
|
547
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
548
|
-
5.should.not.be.a.kind.of Fixnum
|
549
|
-
end
|
550
|
-
end
|
551
|
-
|
552
|
-
def test_should_not_be_a_kind_of_should_fail_when_target_is_of_subclass_of_specified_class
|
553
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
554
|
-
5.should.not.be.a.kind.of Integer
|
555
|
-
end
|
556
|
-
end
|
557
|
-
|
558
|
-
def test_should_not_be_an_instance_of_should_pass_when_target_is_not_specified_class
|
559
|
-
assert_nothing_raised do
|
560
|
-
5.should.not.be.a.kind.of String
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
564
|
-
# should.respond.to <message>
|
565
|
-
|
566
|
-
def test_should_respond_to_should_pass_when_target_does
|
567
|
-
assert_nothing_raised do
|
568
|
-
"".should.respond.to :length
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
def test_should_respond_to_should_fail_when_target_doesnt
|
573
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
574
|
-
"".should.respond.to :connect
|
575
|
-
end
|
576
|
-
end
|
577
|
-
|
578
|
-
# should.not.respond.to <message>
|
579
|
-
|
580
|
-
def test_not_should_respond_to_should_fail_when_target_does
|
581
|
-
assert_raise(Spec::Exceptions::ExpectationNotMetError) do
|
582
|
-
"".should.not.respond.to :length
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
def test_not_should_respond_to_should_pass_when_target_doesnt
|
587
|
-
assert_nothing_raised do
|
588
|
-
"".should.not.respond.to :connect
|
589
|
-
end
|
590
|
-
end
|
591
|
-
|
592
|
-
end
|