rspec 0.6.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,129 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Expectations
|
5
|
-
module Helper
|
6
|
-
class ContainmentTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@dummy = 'dummy'
|
10
|
-
@equal_dummy = 'dummy'
|
11
|
-
@another_dummy = 'another_dummy'
|
12
|
-
@nil_var = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
# should_include
|
16
|
-
|
17
|
-
def test_should_include_shouldnt_raise_when_string_inclusion_is_present
|
18
|
-
assert_nothing_raised do
|
19
|
-
@dummy.should_include "mm"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_should_include_should_raise_when_string_inclusion_is_missing
|
24
|
-
assert_raise(ExpectationNotMetError) do
|
25
|
-
@dummy.should_include "abc"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_should_include_shouldnt_raise_when_array_inclusion_is_present
|
30
|
-
assert_nothing_raised do
|
31
|
-
[1, 2, 3].should_include 2
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_should_include_should_raise_when_array_inclusion_is_missing
|
36
|
-
assert_raise(ExpectationNotMetError) do
|
37
|
-
[1, 2, 3].should_include 5
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_should_include_shouldnt_raise_when_hash_inclusion_is_present
|
42
|
-
assert_nothing_raised do
|
43
|
-
{"a"=>1}.should_include "a"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def FIXME_test_should_has_key_shouldnt_raise_when_hash_inclusion_is_present
|
48
|
-
assert_nothing_raised do
|
49
|
-
{"a"=>1}.should_has_key "a"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def FIXME_test_should_have_key_shouldnt_raise_when_hash_inclusion_is_present
|
54
|
-
assert_nothing_raised do
|
55
|
-
{"a"=>1}.should_have_key "a"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_should_include_should_raise_when_hash_inclusion_is_missing
|
60
|
-
assert_raise(ExpectationNotMetError) do
|
61
|
-
{"a"=>1}.should_include "b"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_should_include_shouldnt_raise_when_enumerable_inclusion_is_present
|
66
|
-
assert_nothing_raised do
|
67
|
-
IO.constants.should_include "SEEK_SET"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_should_include_should_raise_when_enumerable_inclusion_is_missing
|
72
|
-
assert_raise(ExpectationNotMetError) do
|
73
|
-
IO.constants.should_include "BLAH"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# should_not_include
|
78
|
-
|
79
|
-
def test_should_not_include_shouldnt_raise_when_string_inclusion_is_missing
|
80
|
-
assert_nothing_raised do
|
81
|
-
@dummy.should_not_include "abc"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_should_not_include_should_raise_when_string_inclusion_is_present
|
86
|
-
assert_raise(ExpectationNotMetError) do
|
87
|
-
@dummy.should_not_include "mm"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_should_not_include_shouldnt_raise_when_array_inclusion_is_missing
|
92
|
-
assert_nothing_raised do
|
93
|
-
[1, 2, 3].should_not_include 5
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_should_not_include_should_raise_when_array_inclusion_is_present
|
98
|
-
assert_raise(ExpectationNotMetError) do
|
99
|
-
[1, 2, 3].should_not_include 2
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_should_not_include_shouldnt_raise_when_hash_inclusion_is_missing
|
104
|
-
assert_nothing_raised do
|
105
|
-
{"a"=>1}.should_not_include "b"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_should_not_include_should_raise_when_hash_inclusion_is_present
|
110
|
-
assert_raise(ExpectationNotMetError) do
|
111
|
-
{"a"=>1}.should_not_include "a"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_should_not_include_shouldnt_raise_when_enumerable_inclusion_is_present
|
116
|
-
assert_nothing_raised do
|
117
|
-
IO.constants.should_not_include "BLAH"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_should_not_include_should_raise_when_enumerable_inclusion_is_missing
|
122
|
-
assert_raise(ExpectationNotMetError) do
|
123
|
-
IO.constants.should_not_include "SEEK_SET"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Expectations
|
5
|
-
class DiffTest < Test::Unit::TestCase
|
6
|
-
def test_should_output_unified_diff_of_two_strings
|
7
|
-
expected = <<-EOF
|
8
|
-
foo
|
9
|
-
bar
|
10
|
-
zap
|
11
|
-
this
|
12
|
-
is
|
13
|
-
soo
|
14
|
-
very
|
15
|
-
very
|
16
|
-
equal
|
17
|
-
insert
|
18
|
-
a
|
19
|
-
line
|
20
|
-
EOF
|
21
|
-
|
22
|
-
actual = <<-EOF
|
23
|
-
foo
|
24
|
-
zap
|
25
|
-
bar
|
26
|
-
this
|
27
|
-
is
|
28
|
-
soo
|
29
|
-
very
|
30
|
-
very
|
31
|
-
equal
|
32
|
-
insert
|
33
|
-
a
|
34
|
-
another
|
35
|
-
line
|
36
|
-
EOF
|
37
|
-
|
38
|
-
expected_diff = <<-EOF
|
39
|
-
|
40
|
-
|
41
|
-
@@ -1,6 +1,6 @@
|
42
|
-
foo
|
43
|
-
-bar
|
44
|
-
zap
|
45
|
-
+bar
|
46
|
-
this
|
47
|
-
is
|
48
|
-
soo
|
49
|
-
@@ -9,5 +9,6 @@
|
50
|
-
equal
|
51
|
-
insert
|
52
|
-
a
|
53
|
-
+another
|
54
|
-
line
|
55
|
-
EOF
|
56
|
-
|
57
|
-
diff = ShouldBase.new.diff_as_string(expected, actual)
|
58
|
-
assert_equal expected_diff, diff
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Expectations
|
5
|
-
module Helper
|
6
|
-
class ShouldBeTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@dummy = 'dummy'
|
10
|
-
@equal_dummy = 'dummy'
|
11
|
-
@another_dummy = 'another_dummy'
|
12
|
-
@nil_var = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_should_not_raise_when_objects_are_same
|
16
|
-
assert_nothing_raised do
|
17
|
-
@dummy.should_be @dummy
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_should_raise_when_objects_are_not_same
|
22
|
-
assert_raise(ExpectationNotMetError) do
|
23
|
-
@dummy.should_be @equal_dummy
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_should_not_raise_when_both_objects_are_nil
|
28
|
-
assert_nothing_raised do
|
29
|
-
@nil_var.should_be nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_should_raise_when_object_is_not_nil
|
34
|
-
assert_raise(ExpectationNotMetError) do
|
35
|
-
@dummy.should_be nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class ShouldNotBeTest < Test::Unit::TestCase
|
41
|
-
def setup
|
42
|
-
@dummy = 'dummy'
|
43
|
-
@equal_dummy = 'dummy'
|
44
|
-
@another_dummy = 'another_dummy'
|
45
|
-
@nil_var = nil
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_should_not_raise_when_objects_are_not_same
|
49
|
-
assert_nothing_raised do
|
50
|
-
@dummy.should_not_be @equal_dummy
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_should_raise_when_objects_are_same
|
55
|
-
assert_raise(ExpectationNotMetError) do
|
56
|
-
@dummy.should_not_be @dummy
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_should_not_raise_when_left_is_not_nil_and_right_is_nil
|
61
|
-
assert_nothing_raised do
|
62
|
-
@dummy.should_not_be nil
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_should_raise_when_both_objects_are_nil
|
67
|
-
assert_raise(ExpectationNotMetError) do
|
68
|
-
@nil_var.should_not_be nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Expectations
|
5
|
-
module Helper
|
6
|
-
class ShouldEqualTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_should_not_raise_when_objects_are_equal
|
9
|
-
assert_nothing_raised do
|
10
|
-
'apple'.should_equal 'apple'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_should_raise_when_objects_are_not_equal
|
15
|
-
assert_raise(ExpectationNotMetError) do
|
16
|
-
'apple'.should_equal 'orange'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class ShouldNotEqualTest < Test::Unit::TestCase
|
22
|
-
|
23
|
-
def test_should_not_raise_when_objects_are_not_equal
|
24
|
-
assert_nothing_raised do
|
25
|
-
'apple'.should_not_equal 'orange'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_should_not_equal_should_raise_when_objects_are_equal
|
30
|
-
assert_raise(ExpectationNotMetError) do
|
31
|
-
'apple'.should_not_equal 'apple'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class ShouldBeCloseTest < Test::Unit::TestCase
|
37
|
-
def test_should_not_raise_when_values_are_within_bounds
|
38
|
-
assert_nothing_raised do
|
39
|
-
3.5.should_be_close 3.5, 0.5
|
40
|
-
3.5.should_be_close 3.1, 0.5
|
41
|
-
3.5.should_be_close 3.01, 0.5
|
42
|
-
3.5.should_be_close 3.9, 0.5
|
43
|
-
3.5.should_be_close 3.99, 0.5
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_should_raise_when_values_are_outside_bounds
|
48
|
-
assert_raise(ExpectationNotMetError) do
|
49
|
-
3.5.should_be_close 3.0, 0.5
|
50
|
-
end
|
51
|
-
assert_raise(ExpectationNotMetError) do
|
52
|
-
3.5.should_be_close 2.0, 0.5
|
53
|
-
end
|
54
|
-
assert_raise(ExpectationNotMetError) do
|
55
|
-
3.5.should_be_close 4.0, 0.5
|
56
|
-
end
|
57
|
-
assert_raise(ExpectationNotMetError) do
|
58
|
-
3.5.should_be_close 5.0, 0.5
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Expectations
|
5
|
-
module Helper
|
6
|
-
class ShouldRaiseTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_should_pass_when_exact_exception_is_raised
|
9
|
-
assert_nothing_raised do
|
10
|
-
proc { ''.nonexistent_method }.should_raise NoMethodError
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_should_pass_when_exact_exception_is_raised_with_message
|
15
|
-
assert_nothing_raised do
|
16
|
-
lambda { raise StandardError.new("this is standard") }.should_raise StandardError, "this is standard"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_should_fail_when_exact_exception_is_raised_with_wrong_message
|
21
|
-
assert_raises(Spec::Expectations::ExpectationNotMetError) do
|
22
|
-
lambda { raise StandardError.new("chunky bacon") }.should_raise StandardError, "rotten tomatoes"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_should_pass_when_subclass_exception_is_raised
|
27
|
-
assert_nothing_raised do
|
28
|
-
proc { ''.nonexistent_method }.should_raise
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_should_fail_when_wrong_exception_is_raised
|
33
|
-
begin
|
34
|
-
proc { ''.nonexistent_method }.should_raise SyntaxError
|
35
|
-
rescue => e
|
36
|
-
end
|
37
|
-
assert_equal("<Proc> should raise <SyntaxError> but raised #<NoMethodError: undefined method `nonexistent_method' for \"\":String>", e.message)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_should_fail_when_no_exception_is_raised
|
41
|
-
begin
|
42
|
-
proc { }.should_raise SyntaxError
|
43
|
-
rescue => e
|
44
|
-
end
|
45
|
-
assert_equal("<Proc> should raise <SyntaxError> but raised nothing", e.message)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class ShouldNotRaiseTest < Test::Unit::TestCase
|
50
|
-
|
51
|
-
def test_should_pass_when_exact_exception_is_raised_with_wrong_message
|
52
|
-
assert_nothing_raised do
|
53
|
-
lambda { raise StandardError.new("abc") }.should_not_raise StandardError, "xyz"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_should_faile_when_exact_exception_is_raised_with_message
|
58
|
-
assert_raises(Spec::Expectations::ExpectationNotMetError) do
|
59
|
-
lambda { raise StandardError.new("abc") }.should_not_raise StandardError, "abc"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_should_pass_when_other_exception_is_raised
|
64
|
-
assert_nothing_raised do
|
65
|
-
proc { ''.nonexistent_method }.should_not_raise SyntaxError
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_should_pass_when_no_exception_is_raised
|
70
|
-
assert_nothing_raised do
|
71
|
-
proc { ''.to_s }.should_not_raise NoMethodError
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_without_exception_should_pass_when_no_exception_is_raised
|
76
|
-
assert_nothing_raised do
|
77
|
-
proc { ''.to_s }.should_not_raise
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_should_fail_when_specific_exception_is_raised
|
82
|
-
begin
|
83
|
-
proc { ''.nonexistent_method }.should_not_raise NoMethodError
|
84
|
-
rescue => e
|
85
|
-
end
|
86
|
-
assert_equal("<Proc> should not raise <NoMethodError>", e.message)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_should_include_actual_error_in_failure_message
|
90
|
-
begin
|
91
|
-
proc { ''.nonexistent_method }.should_not_raise Exception
|
92
|
-
rescue => e
|
93
|
-
end
|
94
|
-
assert_equal("<Proc> should not raise <Exception> but raised #<NoMethodError: undefined method `nonexistent_method' for \"\":String>", e.message)
|
95
|
-
end
|
96
|
-
|
97
|
-
def TODOtest_should_understand_raised_with_message_matching
|
98
|
-
lambda do
|
99
|
-
raise 'Hello'
|
100
|
-
end.should_raise(StandardError).with.message.matching(/ello/)
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Expectations
|
5
|
-
module Helper
|
6
|
-
class ShouldMatchTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_should_not_raise_when_objects_match
|
9
|
-
assert_nothing_raised do
|
10
|
-
"hi aslak".should_match(/aslak/)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_should_raise_when_objects_do_not_match
|
15
|
-
assert_raise(ExpectationNotMetError) do
|
16
|
-
"hi aslak".should_match(/steve/)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class ShouldNotMatchTest < Test::Unit::TestCase
|
22
|
-
def test_should_not_raise_when_objects_do_not_match
|
23
|
-
assert_nothing_raised do
|
24
|
-
"hi aslak".should_not_match(/steve/)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_should_raise_when_objects_match
|
29
|
-
assert_raise(ExpectationNotMetError) do
|
30
|
-
"hi aslak".should_not_match(/aslak/)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|