rspec 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +57 -32
- data/EXAMPLES.rd +0 -0
- data/Rakefile +22 -21
- data/bin/spec +9 -11
- data/doc/README +1 -3
- data/doc/plugin/syntax.rb +27 -5
- data/doc/src/core_team.page +22 -0
- data/doc/src/default.css +11 -11
- data/doc/src/default.template +0 -1
- data/doc/src/documentation/index.page +183 -8
- data/doc/src/documentation/meta.info +7 -7
- data/doc/src/documentation/mocks.page +168 -109
- data/doc/src/documentation/underscores.page +20 -0
- data/doc/src/examples.page +2 -1
- data/doc/src/images/David_and_Aslak.jpg +0 -0
- data/doc/src/images/Whats_That_Dude.jpg +0 -0
- data/doc/src/index.page +70 -3
- data/doc/src/meta.info +18 -11
- data/doc/src/tools/index.page +40 -134
- data/doc/src/tools/meta.info +9 -3
- data/doc/src/tools/rails.page +3 -1
- data/doc/src/tools/rake.page +20 -3
- data/doc/src/tools/rcov.page +19 -0
- data/doc/src/tools/spec.page +99 -0
- data/doc/src/tools/test2rspec.page +2 -4
- data/doc/src/tutorials/index.page +52 -0
- data/doc/src/tutorials/meta.info +31 -0
- data/doc/src/tutorials/notes.txt +252 -0
- data/doc/src/tutorials/stack.rb +11 -0
- data/doc/src/tutorials/stack_01.page +224 -0
- data/doc/src/tutorials/stack_02.page +180 -0
- data/doc/src/tutorials/stack_03.page +291 -0
- data/doc/src/tutorials/stack_04.page +203 -0
- data/doc/src/tutorials/stack_04.page.orig +123 -0
- data/doc/src/tutorials/stack_05.page +90 -0
- data/doc/src/tutorials/stack_05.page.orig +124 -0
- data/doc/src/tutorials/stack_06.page +359 -0
- data/doc/src/tutorials/stack_06.page.orig +359 -0
- data/doc/src/tutorials/stack_spec.rb +41 -0
- data/examples/airport_spec.rb +4 -4
- data/examples/{spec_framework_spec.rb → bdd_framework_spec.rb} +6 -7
- data/examples/mocking_spec.rb +0 -5
- data/examples/stack_spec.rb +6 -7
- data/examples/sugar_spec.rb +14 -0
- data/lib/spec/api.rb +5 -2
- data/lib/spec/api/helper/should_base.rb +17 -22
- data/lib/spec/api/helper/should_helper.rb +4 -3
- data/lib/spec/api/helper/should_negator.rb +3 -2
- data/lib/spec/api/mocks/argument_expectation.rb +104 -0
- data/lib/spec/api/{mock.rb → mocks/message_expectation.rb} +47 -96
- data/lib/spec/api/mocks/mock.rb +63 -0
- data/lib/spec/api/mocks/order_group.rb +21 -0
- data/lib/spec/api/sugar.rb +47 -0
- data/lib/spec/rake/rcov_verify.rb +45 -0
- data/lib/spec/rake/spectask.rb +41 -56
- data/lib/spec/runner.rb +4 -1
- data/lib/spec/runner/backtrace_tweaker.rb +24 -3
- data/lib/spec/runner/base_text_formatter.rb +28 -0
- data/lib/spec/runner/context.rb +21 -18
- data/lib/spec/runner/context_runner.rb +20 -31
- data/lib/spec/runner/execution_context.rb +3 -3
- data/lib/spec/runner/kernel_ext.rb +10 -1
- data/lib/spec/runner/option_parser.rb +32 -14
- data/lib/spec/runner/progress_bar_formatter.rb +21 -0
- data/lib/spec/runner/rdoc_formatter.rb +15 -5
- data/lib/spec/runner/reporter.rb +100 -0
- data/lib/spec/runner/specdoc_formatter.rb +20 -0
- data/lib/spec/runner/specification.rb +42 -22
- data/lib/spec/version.rb +1 -1
- data/test/rcov/rcov_testtask.rb +1 -0
- data/test/spec/api/duck_type_test.rb +4 -4
- data/test/spec/api/helper/raising_test.rb +37 -17
- data/test/spec/api/{mock_arg_constraints_test.rb → mocks/mock_arg_constraints_test.rb} +10 -4
- data/test/spec/api/mocks/mock_ordering_test.rb +62 -0
- data/test/spec/api/{mock_test.rb → mocks/mock_test.rb} +30 -7
- data/test/spec/api/mocks/null_object_test.rb +31 -0
- data/test/spec/api/sugar_test.rb +71 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +52 -4
- data/test/spec/runner/context_runner_test.rb +41 -21
- data/test/spec/runner/context_test.rb +60 -32
- data/test/spec/runner/execution_context_test.rb +4 -3
- data/test/spec/runner/failure_dump_test.rb +92 -0
- data/test/spec/runner/kernel_ext_test.rb +1 -2
- data/test/spec/runner/option_parser_test.rb +48 -28
- data/test/spec/runner/progress_bar_formatter_test.rb +48 -0
- data/test/spec/runner/rdoc_formatter_test.rb +31 -4
- data/test/spec/runner/reporter_test.rb +103 -0
- data/test/spec/runner/specdoc_formatter_test.rb +50 -0
- data/test/spec/runner/specification_test.rb +49 -11
- data/test/test_helper.rb +1 -4
- metadata +46 -15
- data/doc/src/community.page +0 -7
- data/doc/src/documentation/api.page +0 -185
- data/doc/src/why_rspec.page +0 -7
- data/examples/empty_stack_spec.rb +0 -22
- data/examples/team_spec.rb +0 -30
- data/lib/spec/api/duck_type.rb +0 -16
- data/lib/spec/runner/simple_text_reporter.rb +0 -88
- data/test/rcov/rcov_verify.rb +0 -28
- data/test/spec/runner/simple_text_reporter_test.rb +0 -123
data/test/rcov/rcov_testtask.rb
CHANGED
@@ -17,6 +17,7 @@ module RCov
|
|
17
17
|
end
|
18
18
|
@ruby_opts.unshift( "-I#{lib_path}" )
|
19
19
|
@ruby_opts.unshift( "--exclude test.*.rb")
|
20
|
+
@ruby_opts.unshift( "--exclude lib.spec.sorted_find.rb")
|
20
21
|
@ruby_opts.unshift( "-w" ) if @warning
|
21
22
|
rcov @ruby_opts.join(" ") +
|
22
23
|
" \"#{run_code}\" " +
|
@@ -5,13 +5,13 @@ module Spec
|
|
5
5
|
class DuckTypeTest < Test::Unit::TestCase
|
6
6
|
|
7
7
|
def test_should_talk_like_something_with_one_message_specified
|
8
|
-
duck_type =
|
9
|
-
assert
|
8
|
+
duck_type = DuckTypeArgConstraint.new(:length)
|
9
|
+
assert duck_type.matches?([])
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_should_talk_like_something_with_two_messages_specified
|
13
|
-
duck_type =
|
14
|
-
assert
|
13
|
+
duck_type = DuckTypeArgConstraint.new(:length, :empty?)
|
14
|
+
assert duck_type.matches?([])
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -3,39 +3,42 @@ require File.dirname(__FILE__) + '/../../../test_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Api
|
5
5
|
module Helper
|
6
|
-
class
|
6
|
+
class ShouldRaiseTest < Test::Unit::TestCase
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def test_should_raise_should_pass_when_proper_exception_is_raised
|
8
|
+
def test_should_raise_should_pass_when_exact_exception_is_raised
|
11
9
|
assert_nothing_raised do
|
12
|
-
proc { ''.
|
10
|
+
proc { ''.nonexistent_method }.should.raise NoMethodError
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
def
|
17
|
-
|
18
|
-
proc { ''.
|
14
|
+
def test_should_raise_should_pass_when_subclass_exception_is_raised
|
15
|
+
assert_nothing_raised do
|
16
|
+
proc { ''.nonexistent_method }.should.raise
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
|
-
def
|
23
|
-
|
24
|
-
proc {''.
|
20
|
+
def test_should_raise_should_fail_when_wrong_exception_is_raised
|
21
|
+
begin
|
22
|
+
proc { ''.nonexistent_method }.should.raise SyntaxError
|
23
|
+
rescue => e
|
25
24
|
end
|
25
|
+
assert_equal("<Proc> should raise <SyntaxError> but raised #<NoMethodError: undefined method `nonexistent_method' for \"\":String>", e.message)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
proc { ''.nonexistant_method }.should.not.raise NoMethodError
|
28
|
+
def test_should_raise_should_fail_when_no_exception_is_raised
|
29
|
+
begin
|
30
|
+
proc { }.should.raise SyntaxError
|
31
|
+
rescue => e
|
33
32
|
end
|
33
|
+
assert_equal("<Proc> should raise <SyntaxError> but raised nothing", e.message)
|
34
34
|
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class ShouldNotRaiseTest < Test::Unit::TestCase
|
35
38
|
|
36
39
|
def test_should_not_raise_should_pass_when_other_exception_is_raised
|
37
40
|
assert_nothing_raised do
|
38
|
-
proc { ''.
|
41
|
+
proc { ''.nonexistent_method }.should.not.raise SyntaxError
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
@@ -51,11 +54,28 @@ module Spec
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
57
|
+
def test_should_not_raise_should_fail_when_specific_exception_is_raised
|
58
|
+
begin
|
59
|
+
proc { ''.nonexistent_method }.should.not.raise NoMethodError
|
60
|
+
rescue => e
|
61
|
+
end
|
62
|
+
assert_equal("<Proc> should not raise <NoMethodError>", e.message)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_should_include_actual_error_in_failure_message
|
66
|
+
begin
|
67
|
+
proc { ''.nonexistent_method }.should.not.raise Exception
|
68
|
+
rescue => e
|
69
|
+
end
|
70
|
+
assert_equal("<Proc> should not raise <Exception> but raised #<NoMethodError: undefined method `nonexistent_method' for \"\":String>", e.message)
|
71
|
+
end
|
72
|
+
|
54
73
|
def TODOtest_should_understand_raised_with_message_matching
|
55
74
|
lambda do
|
56
75
|
raise 'Hello'
|
57
76
|
end.should.raise(StandardError).with.message.matching /ello/
|
58
77
|
end
|
78
|
+
|
59
79
|
end
|
60
80
|
end
|
61
81
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Api
|
@@ -44,14 +44,20 @@ module Spec
|
|
44
44
|
@mock.__verify
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_should_match_non_special_symbol
|
48
|
+
@mock.should.receive(:random_call).with(:some_symbol)
|
49
|
+
@mock.random_call(:some_symbol)
|
50
|
+
@mock.__verify
|
51
|
+
end
|
52
|
+
|
47
53
|
def test_should_process_duck_type_with_one_method
|
48
|
-
@mock.should.receive(:random_call).with(
|
54
|
+
@mock.should.receive(:random_call).with(DuckTypeArgConstraint.new(:length))
|
49
55
|
@mock.random_call([])
|
50
56
|
@mock.__verify
|
51
57
|
end
|
52
58
|
|
53
59
|
def test_should_process_duck_type_with_two_methods
|
54
|
-
@mock.should.receive(:random_call).with(
|
60
|
+
@mock.should.receive(:random_call).with(DuckTypeArgConstraint.new(:abs, :div))
|
55
61
|
@mock.random_call(1)
|
56
62
|
@mock.__verify
|
57
63
|
end
|
@@ -89,7 +95,7 @@ module Spec
|
|
89
95
|
end
|
90
96
|
|
91
97
|
def test_should_reject_goose_when_expecting_a_duck
|
92
|
-
@mock.should.receive(:random_call).with(
|
98
|
+
@mock.should.receive(:random_call).with(DuckTypeArgConstraint.new(:abs, :div))
|
93
99
|
assert_raise(MockExpectationError) do
|
94
100
|
@mock.random_call("I don't respond to :abs or :div")
|
95
101
|
@mock.__verify
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Api
|
5
|
+
|
6
|
+
class MockTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@mock = Mock.new("test mock")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_two_in_order_calls
|
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_two_out_of_order_calls
|
21
|
+
@mock.should.receive(:one).ordered
|
22
|
+
@mock.should.receive(:two).ordered
|
23
|
+
assert_raise(MockExpectationError) do
|
24
|
+
@mock.two
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_three_linear_calls
|
29
|
+
@mock.should.receive(:one).ordered
|
30
|
+
@mock.should.receive(:two).ordered
|
31
|
+
@mock.should.receive(:three).ordered
|
32
|
+
@mock.one
|
33
|
+
@mock.two
|
34
|
+
@mock.three
|
35
|
+
@mock.__verify
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_three_out_of_order_calls
|
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_two_ordered_calls_with_others_between
|
49
|
+
@mock.should.receive(:zero)
|
50
|
+
@mock.should.receive(:one).ordered
|
51
|
+
@mock.should.receive(:two).ordered
|
52
|
+
@mock.should.receive(:one_and_a_half)
|
53
|
+
@mock.one
|
54
|
+
@mock.one_and_a_half
|
55
|
+
@mock.zero
|
56
|
+
@mock.two
|
57
|
+
@mock.__verify
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Api
|
@@ -59,12 +59,6 @@ module Spec
|
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
62
|
-
def test_should_allow_unexpected_methods_if_ignore_missing_set
|
63
|
-
m = Mock.new("null_object", :null_object=>true)
|
64
|
-
m.random_call("a","d","c")
|
65
|
-
m.__verify
|
66
|
-
end
|
67
|
-
|
68
62
|
# TODO: rename to should_raise_exception_telling_what_message_was_not_received
|
69
63
|
def test_should_raise_exception_on_verify_if_call_counts_not_as_expected
|
70
64
|
@mock.should.receive(:random_call).twice.with("a","b","c").and.return("booh")
|
@@ -305,6 +299,35 @@ module Spec
|
|
305
299
|
end
|
306
300
|
end
|
307
301
|
|
302
|
+
def test_should_yield_values
|
303
|
+
@mock.should.receive(:yield_back).with(:no_args).once.and.yield('wha', 'zup')
|
304
|
+
a, b = nil
|
305
|
+
@mock.yield_back {|a,b|}
|
306
|
+
a.should.equal 'wha'
|
307
|
+
b.should.equal 'zup'
|
308
|
+
@mock.__verify
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_should_fail_when_calling_yielding_method_with_wrong_arity
|
312
|
+
@mock.should.receive(:yield_back).with(:no_args).once.and.yield('wha', 'zup')
|
313
|
+
assert_raise(MockExpectationError) do
|
314
|
+
@mock.yield_back {|a|}
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_should_fail_when_calling_yielding_method_without_block
|
319
|
+
@mock.should.receive(:yield_back).with(:no_args).once.and.yield('wha', 'zup')
|
320
|
+
assert_raise(MockExpectationError) do
|
321
|
+
@mock.yield_back
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_should_be_able_to_mock_object_methods_such_as_send
|
326
|
+
@mock.should.receive(:send).with(:any_args)
|
327
|
+
@mock.send 'hi'
|
328
|
+
@mock.__verify
|
329
|
+
end
|
330
|
+
|
308
331
|
end
|
309
332
|
end
|
310
333
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Api
|
5
|
+
|
6
|
+
class NullObjectTest < 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_handle_passing_expectation
|
18
|
+
@mock.should_receive(:something)
|
19
|
+
@mock.something
|
20
|
+
@mock.__verify
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_should_handle_failing_expectation
|
24
|
+
assert_raises(MockExpectationError) do
|
25
|
+
@mock.should_receive(:something)
|
26
|
+
@mock.__verify
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Api
|
5
|
+
class SugarTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_should_allow_underscored_shoulds_on_regular_objects
|
8
|
+
1.should_equal 1
|
9
|
+
lambda { 1.should_not_equal 1 }.should_raise
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_allow_underscored_shoulds_on_mocks
|
13
|
+
sweetener = Mock.new "sweetener"
|
14
|
+
sweetener.should_receive(:natural?)
|
15
|
+
sweetener.natural?
|
16
|
+
sweetener.__verify
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_should_allow_underscored_ats_on_mocks
|
20
|
+
sweetener = Mock.new "sweetener"
|
21
|
+
sweetener.should_receive(:natural?).at_least(:once)
|
22
|
+
sweetener.natural?
|
23
|
+
sweetener.__verify
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_allow_underscored_ands_on_mocks
|
27
|
+
sweetener = Mock.new "sweetener"
|
28
|
+
sweetener.should_receive(:natural?).at_least(:once).and_return(true)
|
29
|
+
natural = sweetener.natural?
|
30
|
+
natural.should_be true
|
31
|
+
sweetener.__verify
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_allow_underscored_anys_on_mocks
|
35
|
+
sweetener = Mock.new "sweetener"
|
36
|
+
sweetener.should_receive(:natural?).any_number_of_times
|
37
|
+
sweetener.natural?
|
38
|
+
sweetener.__verify
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_should_allow_underscored_anys_on_mocks
|
42
|
+
sweetener = Mock.new "sweetener"
|
43
|
+
sweetener.should_receive(:natural?).once_and_return(false)
|
44
|
+
natural = sweetener.natural?
|
45
|
+
natural.should_be false
|
46
|
+
sweetener.__verify
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_allow_multi_word_predicates_in_passing_specs
|
50
|
+
subject = ClassWithMultiWordPredicate.new
|
51
|
+
assert_nothing_raised do
|
52
|
+
subject.should_be_multi_word_predicate
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_should_allow_multi_word_predicates_in_failing_specs
|
57
|
+
subject = ClassWithMultiWordPredicate.new
|
58
|
+
assert_raises(ExpectationNotMetError) do
|
59
|
+
subject.should_not_be_multi_word_predicate
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
class ClassWithMultiWordPredicate
|
66
|
+
def multi_word_predicate?
|
67
|
+
true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -4,25 +4,73 @@ module Spec
|
|
4
4
|
class BacktraceTweakerTest < Test::Unit::TestCase
|
5
5
|
def setup
|
6
6
|
@error = RuntimeError.new
|
7
|
-
@tweaker =
|
7
|
+
@tweaker = NoisyBacktraceTweaker.new
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_should_not_barf_on_nil_backtrace
|
11
11
|
proc { @tweaker.tweak_backtrace @error, 'spec name' }.should.not.raise
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def test_should_replace___instance_exec_with_spec_name
|
15
15
|
@error.set_backtrace ["./examples/airport_spec.rb:28:in `__instance_exec_1014688_1661744'"]
|
16
16
|
@tweaker.tweak_backtrace @error, 'spec name'
|
17
17
|
@error.backtrace[0].should.equal "./examples/airport_spec.rb:28:in `spec name'"
|
18
18
|
end
|
19
|
+
|
20
|
+
def test_should_leave_anything_in_api_dir_in_full_backtrace_mode
|
21
|
+
@error.set_backtrace ["/lib/spec/api/anything.rb"]
|
22
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
23
|
+
@error.backtrace[0].should.equal "/lib/spec/api/anything.rb"
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_leave_anything_in_runner_dir_in_full_backtrace_mode
|
27
|
+
@error.set_backtrace ["/lib/spec/runner/anything.rb"]
|
28
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
29
|
+
@error.backtrace.should.not.be.empty
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_leave_bin_spec
|
33
|
+
@error.set_backtrace ["bin/spec:"]
|
34
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
35
|
+
@error.backtrace.should.not.be.empty
|
36
|
+
end
|
19
37
|
|
20
|
-
|
38
|
+
end
|
39
|
+
|
40
|
+
class QuietBacktraceTweakerTest < Test::Unit::TestCase
|
41
|
+
def setup
|
21
42
|
@error = RuntimeError.new
|
22
|
-
@
|
43
|
+
@tweaker = QuietBacktraceTweaker.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_should_not_barf_on_nil_backtrace
|
47
|
+
proc { @tweaker.tweak_backtrace @error, 'spec name' }.should.not.raise
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_should_replace___instance_exec_with_spec_name
|
51
|
+
@error.set_backtrace ["./examples/airport_spec.rb:28:in `__instance_exec_1014688_1661744'"]
|
52
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
53
|
+
@error.backtrace[0].should.equal "./examples/airport_spec.rb:28:in `spec name'"
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_should_remove_anything_in_api_dir
|
57
|
+
@error.set_backtrace ["/lib/spec/api/anything.rb"]
|
58
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
59
|
+
@error.backtrace.should.be.empty
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_should_remove_anything_in_runner_dir
|
63
|
+
@error.set_backtrace ["/lib/spec/runner/anything.rb"]
|
64
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
65
|
+
@error.backtrace.should.be.empty
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_should_remove_bin_spec
|
69
|
+
@error.set_backtrace ["bin/spec:"]
|
23
70
|
@tweaker.tweak_backtrace @error, 'spec name'
|
24
71
|
@error.backtrace.should.be.empty
|
25
72
|
end
|
73
|
+
|
26
74
|
end
|
27
75
|
end
|
28
76
|
end
|