rspec 0.6.4 → 0.7.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 +90 -1
- data/EXAMPLES.rd +28 -6
- data/MIT-LICENSE +20 -0
- data/README +18 -12
- data/Rakefile +60 -54
- data/examples/custom_formatter.rb +4 -4
- data/examples/helper_method_example.rb +11 -0
- data/examples/mocking_example.rb +19 -2
- data/examples/partial_mock_example.rb +28 -0
- data/examples/stack_spec.rb +8 -8
- data/examples/stubbing_example.rb +50 -9
- data/examples/test_case_spec.rb +6 -6
- data/lib/spec.rb +1 -2
- data/lib/spec/callback.rb +0 -0
- data/lib/spec/expectations.rb +3 -6
- data/lib/spec/expectations/diff.rb +23 -47
- data/lib/spec/expectations/differs/default.rb +62 -0
- data/lib/spec/expectations/{exceptions.rb → errors.rb} +0 -0
- data/lib/spec/expectations/extensions.rb +4 -0
- data/lib/spec/expectations/extensions/inspect_for_expectation_not_met_error.rb +14 -0
- data/lib/spec/expectations/extensions/numeric.rb +5 -0
- data/lib/spec/expectations/{expectations.rb → extensions/object.rb} +3 -6
- data/lib/spec/expectations/extensions/symbol.rb +5 -0
- data/lib/spec/expectations/should.rb +4 -0
- data/lib/spec/expectations/should/base.rb +42 -0
- data/lib/spec/expectations/should/have.rb +79 -0
- data/lib/spec/expectations/should/not.rb +72 -0
- data/lib/spec/expectations/should/should.rb +83 -0
- data/lib/spec/expectations/sugar.rb +6 -25
- data/lib/spec/mocks.rb +5 -1
- data/lib/spec/mocks/argument_expectation.rb +15 -1
- data/lib/spec/mocks/error_generator.rb +72 -0
- data/lib/spec/mocks/{exceptions.rb → errors.rb} +0 -0
- data/lib/spec/mocks/extensions/object.rb +3 -0
- data/lib/spec/mocks/message_expectation.rb +80 -73
- data/lib/spec/mocks/mock.rb +4 -69
- data/lib/spec/mocks/mock_handler.rb +158 -0
- data/lib/spec/mocks/mock_methods.rb +44 -0
- data/lib/spec/mocks/order_group.rb +10 -2
- data/lib/spec/rake/spectask.rb +20 -18
- data/lib/spec/rake/{rcov_verify.rb → verify_rcov.rb} +2 -2
- data/lib/spec/runner.rb +3 -1
- data/lib/spec/runner/backtrace_tweaker.rb +2 -1
- data/lib/spec/runner/context.rb +10 -16
- data/lib/spec/runner/context_eval.rb +40 -40
- data/lib/spec/runner/execution_context.rb +1 -12
- data/lib/spec/runner/{kernel_ext.rb → extensions/kernel.rb} +2 -2
- data/lib/spec/runner/{instance_exec.rb → extensions/object.rb} +0 -0
- data/lib/spec/runner/formatter/base_text_formatter.rb +25 -18
- data/lib/spec/runner/formatter/html_formatter.rb +81 -101
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +9 -9
- data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
- data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
- data/lib/spec/runner/option_parser.rb +41 -5
- data/lib/spec/runner/reporter.rb +3 -15
- data/lib/spec/runner/spec_should_raise_handler.rb +74 -0
- data/lib/spec/runner/specification.rb +33 -14
- data/lib/spec/version.rb +6 -3
- data/vendor/watir/README.txt +1 -1
- metadata +34 -68
- data/bin/test2spec +0 -112
- data/examples/helper_method_spec.rb +0 -12
- data/lib/spec/expectations/have_helper.rb +0 -41
- data/lib/spec/expectations/helper.rb +0 -4
- data/lib/spec/expectations/should_base.rb +0 -52
- data/lib/spec/expectations/should_helper.rb +0 -93
- data/lib/spec/expectations/should_negator.rb +0 -71
- data/lib/spec/test_to_spec/ruby2ruby.rb +0 -492
- data/lib/spec/test_to_spec/sexp_transformer.rb +0 -196
- data/lib/spec/test_to_spec/test_case_ext.rb +0 -22
- data/lib/spec/test_to_spec/translation_test_runner.rb +0 -147
- data/test/spec/expectations/arbitrary_operator_test.rb +0 -55
- data/test/spec/expectations/arbitrary_predicate_test.rb +0 -163
- data/test/spec/expectations/containment_test.rb +0 -129
- data/test/spec/expectations/diff_test.rb +0 -62
- data/test/spec/expectations/identity_test.rb +0 -75
- data/test/spec/expectations/object_equality_test.rb +0 -65
- data/test/spec/expectations/raising_test.rb +0 -106
- data/test/spec/expectations/regex_matching_test.rb +0 -36
- data/test/spec/expectations/should_have_test.rb +0 -169
- data/test/spec/expectations/should_satisfy_test.rb +0 -37
- data/test/spec/expectations/sugar_test.rb +0 -93
- data/test/spec/expectations/supported_symbols_test.rb +0 -33
- data/test/spec/expectations/throwing_test.rb +0 -55
- data/test/spec/expectations/true_false_special_case_test.rb +0 -85
- data/test/spec/expectations/typing_test.rb +0 -108
- data/test/spec/mocks/mock_arg_constraints_test.rb +0 -113
- data/test/spec/mocks/mock_counts_test.rb +0 -431
- data/test/spec/mocks/mock_ordering_test.rb +0 -109
- data/test/spec/mocks/mock_test.rb +0 -220
- data/test/spec/mocks/null_object_test.rb +0 -37
- data/test/spec/runner/backtrace_tweaker_test.rb +0 -90
- data/test/spec/runner/context_matching_test.rb +0 -35
- data/test/spec/runner/context_runner_test.rb +0 -62
- data/test/spec/runner/context_test.rb +0 -191
- data/test/spec/runner/execution_context_test.rb +0 -45
- data/test/spec/runner/formatter/failure_dump_test.rb +0 -94
- data/test/spec/runner/formatter/html_formatter_test.rb +0 -48
- data/test/spec/runner/formatter/progress_bar_formatter_test.rb +0 -56
- data/test/spec/runner/formatter/rdoc_formatter_test.rb +0 -51
- data/test/spec/runner/formatter/specdoc_formatter_test.rb +0 -57
- data/test/spec/runner/kernel_ext_test.rb +0 -13
- data/test/spec/runner/option_parser_test.rb +0 -141
- data/test/spec/runner/reporter_test.rb +0 -128
- data/test/spec/runner/spec_matcher_test.rb +0 -47
- data/test/spec/runner/specification_test.rb +0 -121
- data/test/spec/test_to_spec/ruby_to_ruby_test.rb +0 -79
- data/test/spec/test_to_spec/sexp_transformer_assertion_test.rb +0 -207
- data/test/spec/test_to_spec/sexp_transformer_test.rb +0 -303
- data/test/spec/test_to_spec/test_case_ext_test.rb +0 -25
- data/test/spec/test_to_spec/testfiles/test_unit_api_spec.rb +0 -75
- data/test/spec/test_to_spec/testfiles/test_unit_api_test.rb +0 -70
- data/test/test_classes.rb +0 -102
- data/test/test_helper.rb +0 -32
@@ -1,109 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Mocks
|
5
|
-
|
6
|
-
class MockTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@mock = Mock.new("test mock")
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_should_pass_two_calls_in_order
|
13
|
-
@mock.should_receive(:one).ordered
|
14
|
-
@mock.should_receive(:two).ordered
|
15
|
-
@mock.one
|
16
|
-
@mock.two
|
17
|
-
@mock.__verify
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_should_pass_three_calls_in_order
|
21
|
-
@mock.should_receive(:one).ordered
|
22
|
-
@mock.should_receive(:two).ordered
|
23
|
-
@mock.should_receive(:three).ordered
|
24
|
-
@mock.one
|
25
|
-
@mock.two
|
26
|
-
@mock.three
|
27
|
-
@mock.__verify
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_should_fail_if_second_call_comes_first
|
31
|
-
@mock.should_receive(:one).ordered
|
32
|
-
@mock.should_receive(:two).ordered
|
33
|
-
assert_raise(MockExpectationError) do
|
34
|
-
@mock.two
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_should_fail_if_third_call_comes_first
|
39
|
-
@mock.should_receive(:one).ordered
|
40
|
-
@mock.should_receive(:two).ordered
|
41
|
-
@mock.should_receive(:three).ordered
|
42
|
-
@mock.one
|
43
|
-
assert_raise(MockExpectationError) do
|
44
|
-
@mock.three
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_should_fail_if_third_call_comes_second
|
49
|
-
@mock.should_receive(:one).ordered
|
50
|
-
@mock.should_receive(:two).ordered
|
51
|
-
@mock.should_receive(:three).ordered
|
52
|
-
@mock.one
|
53
|
-
assert_raise(MockExpectationError) do
|
54
|
-
@mock.one
|
55
|
-
@mock.three
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_should_ignore_order_of_non_ordered_calls
|
60
|
-
@mock.should_receive(:ignored_0)
|
61
|
-
@mock.should_receive(:ordered_1).ordered
|
62
|
-
@mock.should_receive(:ignored_1)
|
63
|
-
@mock.should_receive(:ordered_2).ordered
|
64
|
-
@mock.should_receive(:ignored_2)
|
65
|
-
@mock.should_receive(:ignored_3)
|
66
|
-
@mock.should_receive(:ordered_3).ordered
|
67
|
-
@mock.should_receive(:ignored_4)
|
68
|
-
@mock.ignored_3
|
69
|
-
@mock.ordered_1
|
70
|
-
@mock.ignored_0
|
71
|
-
@mock.ordered_2
|
72
|
-
@mock.ignored_4
|
73
|
-
@mock.ignored_2
|
74
|
-
@mock.ordered_3
|
75
|
-
@mock.ignored_1
|
76
|
-
@mock.__verify
|
77
|
-
end
|
78
|
-
|
79
|
-
def FIXME_test_two_in_order_calls_with_block
|
80
|
-
@mock.should_receive(:doit).ordered do |a, b|
|
81
|
-
a.should_equal "a1"
|
82
|
-
a.should_equal "b1"
|
83
|
-
end
|
84
|
-
@mock.should_receive(:doit).ordered do |a, b|
|
85
|
-
a.should_equal "a2"
|
86
|
-
a.should_equal "b2"
|
87
|
-
end
|
88
|
-
@mock.doit "a1", "b1"
|
89
|
-
@mock.doit "b1", "b2"
|
90
|
-
@mock.__verify
|
91
|
-
end
|
92
|
-
|
93
|
-
def FIXME_test_two_out_of_order_calls_with_block
|
94
|
-
@mock.should_receive(:doit).ordered do |a, b|
|
95
|
-
a.should_equal "a1"
|
96
|
-
a.should_equal "b1"
|
97
|
-
end
|
98
|
-
@mock.should_receive(:doit).ordered do |a, b|
|
99
|
-
a.should_equal "a2"
|
100
|
-
a.should_equal "b2"
|
101
|
-
end
|
102
|
-
@mock.doit "b1", "b2"
|
103
|
-
@mock.doit "a1", "b1"
|
104
|
-
@mock.__verify
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,220 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Mocks
|
5
|
-
class MockTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@mock = Mock.new("test mock")
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_should_report_line_number_of_expectation_of_unreceived_message
|
12
|
-
@mock.should_receive(:wont_happen).with("x", 3)
|
13
|
-
#NOTE - this test is quite ticklish because it specifies that
|
14
|
-
#the above statement appears on line 12 of this file.
|
15
|
-
|
16
|
-
begin
|
17
|
-
@mock.__verify
|
18
|
-
rescue MockExpectationError => e
|
19
|
-
e.backtrace[0].should_match(/mock_test\.rb:12:in .test_should_report_line/)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_should_pass_when_not_receiving_message_specified_as_not_to_be_received
|
25
|
-
@mock.should_not_receive(:not_expected)
|
26
|
-
@mock.__verify
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_should_pass_when_receiving_message_specified_as_not_to_be_received_with_different_args
|
30
|
-
@mock.should_not_receive(:message).with("unwanted text")
|
31
|
-
@mock.should_receive(:message).with("other text")
|
32
|
-
@mock.message "other text"
|
33
|
-
@mock.__verify
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_should_fail_when_receiving_message_specified_as_not_to_be_received
|
37
|
-
@mock.should_not_receive(:not_expected)
|
38
|
-
@mock.not_expected
|
39
|
-
assert_raise(MockExpectationError) do
|
40
|
-
@mock.__verify
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_should_fail_when_receiving_message_specified_as_not_to_be_received_with_args
|
45
|
-
@mock.should_not_receive(:not_expected).with("unexpected text")
|
46
|
-
@mock.not_expected "unexpected text"
|
47
|
-
assert_raise(MockExpectationError) do
|
48
|
-
@mock.__verify
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_should_allow_block_to_calculate_return_values
|
53
|
-
@mock.should_receive(:random_call).with("a","b","c").and_return { |a,b,c| c+b+a }
|
54
|
-
assert_equal "cba", @mock.random_call("a","b","c")
|
55
|
-
@mock.__verify
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_should_allow_parameter_as_return_value
|
59
|
-
@mock.should_receive(:random_call).with("a","b","c").and_return("booh")
|
60
|
-
assert_equal "booh", @mock.random_call("a","b","c")
|
61
|
-
@mock.__verify
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_return_nil_if_no_return_value_set
|
65
|
-
@mock.should_receive(:random_call).with("a","b","c")
|
66
|
-
assert_nil @mock.random_call("a","b","c")
|
67
|
-
@mock.__verify
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_should_raise_exception_if_parameters_dont_match_when_method_called
|
71
|
-
@mock.should_receive(:random_call).with("a","b","c").and_return("booh")
|
72
|
-
assert_raise(MockExpectationError) {
|
73
|
-
@mock.random_call("a","d","c")
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_should_fail_if_unexpected_method_called
|
78
|
-
assert_raise(MockExpectationError) {
|
79
|
-
@mock.random_call("a","d","c")
|
80
|
-
}
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_should_use_block_for_expectation_if_provided
|
84
|
-
@mock.should_receive(:random_call) do | a, b |
|
85
|
-
a.should_equal "a"
|
86
|
-
b.should_equal "b"
|
87
|
-
"booh"
|
88
|
-
end
|
89
|
-
assert_equal("booh", @mock.random_call("a", "b"))
|
90
|
-
@mock.__verify
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_should_fail_if_expectation_block_fails
|
94
|
-
@mock.should_receive(:random_call).with(true)# {| a | a.should_be true}
|
95
|
-
assert_raise(MockExpectationError) do
|
96
|
-
@mock.random_call false
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_should_fail_when_method_defined_as_never_is_received
|
101
|
-
@mock.should_receive(:random_call).never
|
102
|
-
assert_raise(MockExpectationError) do
|
103
|
-
@mock.random_call
|
104
|
-
@mock.__verify
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_should_raise_when_told_to
|
109
|
-
@mock.should_receive(:random_call).and_raise(RuntimeError)
|
110
|
-
assert_raise(RuntimeError) do
|
111
|
-
@mock.random_call
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_should_not_raise_when_told_to_if_args_dont_match
|
116
|
-
@mock.should_receive(:random_call).with(2).and_raise(RuntimeError)
|
117
|
-
assert_raise(MockExpectationError) do
|
118
|
-
@mock.random_call 1
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_should_throw_when_told_to
|
123
|
-
@mock.should_receive(:random_call).and_throw(:blech)
|
124
|
-
assert_throws(:blech) do
|
125
|
-
@mock.random_call
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_should_raise_when_explicit_return_and_block_constrained
|
130
|
-
assert_raise(AmbiguousReturnError) {
|
131
|
-
@mock.should_receive(:fruit) {|colour|
|
132
|
-
:strawberry
|
133
|
-
}.and_return :apple
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
def TODO_test_should_use_past_tense
|
138
|
-
@mock.should_have_received(:hello)
|
139
|
-
end
|
140
|
-
|
141
|
-
def TODO_test_should_sent
|
142
|
-
cut.should_have_sent(:hello)
|
143
|
-
cut.should_have_sent(:hello).to(@mock)
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_should_ignore_args_on_any_args
|
147
|
-
@mock.should_receive(:random_call).at_least(:once).with(:any_args)
|
148
|
-
@mock.random_call
|
149
|
-
@mock.random_call 1
|
150
|
-
@mock.random_call "a", 2
|
151
|
-
@mock.random_call [], {}, "joe", 7
|
152
|
-
@mock.__verify
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_should_fail_on_no_args_if_any_args_received
|
156
|
-
@mock.should_receive(:random_call).with(:no_args)
|
157
|
-
assert_raise(MockExpectationError) do
|
158
|
-
@mock.random_call 1
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_should_yield_single_value
|
163
|
-
@mock.should_receive(:yield_back).with(:no_args).once.and_yield(99)
|
164
|
-
a = nil
|
165
|
-
@mock.yield_back {|a|}
|
166
|
-
a.should_equal 99
|
167
|
-
@mock.__verify
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_should_yield_two_values
|
171
|
-
@mock.should_receive(:yield_back).with(:no_args).once.and_yield('wha', 'zup')
|
172
|
-
a, b = nil
|
173
|
-
@mock.yield_back {|a,b|}
|
174
|
-
a.should_equal 'wha'
|
175
|
-
b.should_equal 'zup'
|
176
|
-
@mock.__verify
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_should_fail_when_calling_yielding_method_with_wrong_arity
|
180
|
-
@mock.should_receive(:yield_back).with(:no_args).once.and_yield('wha', 'zup')
|
181
|
-
assert_raise(MockExpectationError) do
|
182
|
-
@mock.yield_back {|a|}
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_should_fail_when_calling_yielding_method_without_block
|
187
|
-
@mock.should_receive(:yield_back).with(:no_args).once.and_yield('wha', 'zup')
|
188
|
-
assert_raise(MockExpectationError) do
|
189
|
-
@mock.yield_back
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_should_be_able_to_mock_send
|
194
|
-
@mock.should_receive(:send).with(:any_args)
|
195
|
-
@mock.send 'hi'
|
196
|
-
@mock.__verify
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_should_be_able_to_raise_from_method_calling_yielding_mock
|
200
|
-
@mock.should_receive(:yield_me).and_yield 44
|
201
|
-
|
202
|
-
lambda do
|
203
|
-
@mock.yield_me do |x|
|
204
|
-
raise "Bang"
|
205
|
-
end
|
206
|
-
end.should_raise(StandardError)
|
207
|
-
|
208
|
-
@mock.__verify
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_should_use_a_list_of_return_values_for_successive_calls
|
212
|
-
@mock.should_receive(:multi_call).twice.with(:no_args).and_return([8, 12])
|
213
|
-
assert_equal(8, @mock.multi_call)
|
214
|
-
assert_equal(12, @mock.multi_call)
|
215
|
-
@mock.__verify
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Mocks
|
5
|
-
|
6
|
-
class NullObjectMockTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@mock = Mock.new("null_object", :null_object=>true)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_should_ignore_unexpected_methods
|
13
|
-
@mock.random_call("a","d","c")
|
14
|
-
@mock.__verify
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_should_allow_explicit_expectation
|
18
|
-
@mock.should_receive(:something)
|
19
|
-
@mock.something
|
20
|
-
@mock.__verify
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_should_fail_verification_when_explicit_exception_not_met
|
24
|
-
assert_raises(MockExpectationError) do
|
25
|
-
@mock.should_receive(:something)
|
26
|
-
@mock.__verify
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_should_pass_when_receiving_message_specified_as_not_to_be_received_with_different_args
|
31
|
-
@mock.should_not_receive(:message).with("unwanted text")
|
32
|
-
@mock.message "other text"
|
33
|
-
@mock.__verify
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
module Spec
|
3
|
-
module Runner
|
4
|
-
class NoisyBacktraceTweakerTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@error = RuntimeError.new
|
7
|
-
@tweaker = NoisyBacktraceTweaker.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_should_not_barf_on_nil_backtrace
|
11
|
-
proc { @tweaker.tweak_backtrace @error, 'spec name' }.should_not_raise
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_should_replace___instance_exec_with_spec_name
|
15
|
-
@error.set_backtrace ["./examples/airport_spec.rb:28:in `__instance_exec_1014688_1661744'"]
|
16
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
17
|
-
@error.backtrace[0].should_equal "./examples/airport_spec.rb:28:in `spec name'"
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_should_leave_anything_in_spec_dir
|
21
|
-
@error.set_backtrace ["/lib/spec/expectations/anything.rb"]
|
22
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
23
|
-
@error.backtrace.should_not_be_empty
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_should_leave_anything_in_lib_spec_dir
|
27
|
-
['expectations', 'mocks', 'runner', 'stubs'].each do |child|
|
28
|
-
@error.set_backtrace ["/lib/spec/#{child}/anything.rb"]
|
29
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
30
|
-
@error.backtrace.should_not_be_empty
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_should_leave_bin_spec
|
35
|
-
@error.set_backtrace ["bin/spec:"]
|
36
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
37
|
-
@error.backtrace.should_not_be_empty
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
class QuietBacktraceTweakerTest < Test::Unit::TestCase
|
43
|
-
def setup
|
44
|
-
@error = RuntimeError.new
|
45
|
-
@tweaker = QuietBacktraceTweaker.new
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_should_not_barf_on_nil_backtrace
|
49
|
-
proc { @tweaker.tweak_backtrace @error, 'spec name' }.should_not_raise
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_should_replace___instance_exec_with_spec_name
|
53
|
-
@error.set_backtrace ["./examples/airport_spec.rb:28:in `__instance_exec_1014688_1661744'"]
|
54
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
55
|
-
@error.backtrace[0].should_equal "./examples/airport_spec.rb:28:in `spec name'"
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_should_remove_anything_in_lib_spec_dir
|
59
|
-
element = nil # Workaround to make test2spec work for our own tests
|
60
|
-
['expectations', 'mocks', 'runner', 'stubs'].each do |child|
|
61
|
-
element = "/lib/spec/#{child}/anything.rb"
|
62
|
-
@error.set_backtrace [element]
|
63
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
64
|
-
if !@error.backtrace.empty?
|
65
|
-
raise "Should have tweaked away '#{element}'"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_should_remove_bin_spec
|
71
|
-
@error.set_backtrace ["bin/spec:"]
|
72
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
73
|
-
@error.backtrace.should_be_empty
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_should_remove_anything_from_textmate_ruby_bundle
|
77
|
-
@error.set_backtrace ["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"]
|
78
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
79
|
-
@error.backtrace.should_be_empty
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_should_remove_anything_from_rspec_on_rails
|
83
|
-
@error.set_backtrace ["/usr/local/lib/ruby/gems/1.8/gems/rspec_generator-0.5.12/lib/rspec_on_rails.rb:33:in `run'"]
|
84
|
-
@tweaker.tweak_backtrace @error, 'spec name'
|
85
|
-
@error.backtrace.should_be_empty
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|