spicycode-micronaut 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/examples/lib/micronaut/{behaviour_group_example.rb → behaviour_example.rb} +15 -13
- data/examples/lib/micronaut/configuration_example.rb +4 -4
- data/examples/lib/micronaut/example_example.rb +46 -0
- data/examples/lib/micronaut/expectations/extensions/object_example.rb +63 -76
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +4 -3
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +2 -2
- data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +8 -29
- data/examples/lib/micronaut/matchers/be_close_example.rb +48 -38
- data/examples/lib/micronaut/matchers/be_example.rb +287 -246
- data/examples/lib/micronaut/matchers/change_example.rb +306 -275
- data/examples/lib/micronaut/matchers/description_generation_example.rb +168 -160
- data/examples/lib/micronaut/matchers/eql_example.rb +30 -24
- data/examples/lib/micronaut/matchers/equal_example.rb +31 -25
- data/examples/lib/micronaut/matchers/handler_example.rb +36 -29
- data/examples/lib/micronaut/matchers/has_example.rb +57 -49
- data/examples/lib/micronaut/matchers/include_example.rb +89 -74
- data/examples/lib/micronaut/matchers/match_example.rb +33 -29
- data/examples/lib/micronaut/world_example.rb +4 -4
- data/lib/micronaut/{behaviour_group.rb → behaviour.rb} +8 -7
- data/lib/micronaut/configuration.rb +1 -1
- data/lib/micronaut/example.rb +5 -1
- data/lib/micronaut/formatters/base_formatter.rb +6 -6
- data/lib/micronaut/formatters/base_text_formatter.rb +8 -13
- data/lib/micronaut/formatters/documentation_formatter.rb +62 -0
- data/lib/micronaut/formatters/progress_formatter.rb +1 -0
- data/lib/micronaut/formatters.rb +1 -0
- data/lib/micronaut/kernel_extensions.rb +1 -1
- data/lib/micronaut/runner.rb +1 -4
- data/lib/micronaut/runner_options.rb +11 -4
- data/lib/micronaut.rb +2 -2
- metadata +7 -4
@@ -47,7 +47,9 @@ module ExampleExpectations
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe Micronaut::Expectations::ExpectationMatcherHandler do
|
50
|
+
|
50
51
|
describe "#handle_matcher" do
|
52
|
+
|
51
53
|
it "should ask the matcher if it matches" do
|
52
54
|
matcher = mock("matcher")
|
53
55
|
actual = Object.new
|
@@ -72,11 +74,15 @@ describe Micronaut::Expectations::ExpectationMatcherHandler do
|
|
72
74
|
matcher.expects(:matches?).with(actual).returns(:this_value)
|
73
75
|
Micronaut::Expectations::ExpectationMatcherHandler.handle_matcher(actual, matcher).should == :this_value
|
74
76
|
end
|
77
|
+
|
75
78
|
end
|
79
|
+
|
76
80
|
end
|
77
81
|
|
78
82
|
describe Micronaut::Expectations::NegativeExpectationMatcherHandler do
|
83
|
+
|
79
84
|
describe "#handle_matcher" do
|
85
|
+
|
80
86
|
it "should explain when matcher does not support should_not" do
|
81
87
|
matcher = mock("matcher")
|
82
88
|
matcher.stubs(:matches?)
|
@@ -113,34 +119,35 @@ describe Micronaut::Expectations::NegativeExpectationMatcherHandler do
|
|
113
119
|
matcher.stubs(:negative_failure_message).returns("ignore")
|
114
120
|
Micronaut::Expectations::NegativeExpectationMatcherHandler.handle_matcher(actual, matcher).should be_false
|
115
121
|
end
|
122
|
+
|
116
123
|
end
|
124
|
+
|
117
125
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
# end
|
126
|
+
|
127
|
+
describe Micronaut::Expectations::ExpectationMatcherHandler do
|
128
|
+
include ExampleExpectations
|
129
|
+
|
130
|
+
it "should handle submitted args" do
|
131
|
+
5.should arbitrary_matcher(:expected => 5)
|
132
|
+
5.should arbitrary_matcher(:expected => "wrong").with(5)
|
133
|
+
lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5")
|
134
|
+
lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5")
|
135
|
+
5.should_not arbitrary_matcher(:expected => 4)
|
136
|
+
5.should_not arbitrary_matcher(:expected => 5).with(4)
|
137
|
+
lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5")
|
138
|
+
lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should handle the submitted block" do
|
142
|
+
5.should arbitrary_matcher { 5 }
|
143
|
+
5.should arbitrary_matcher(:expected => 4) { 5 }
|
144
|
+
5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should explain when matcher does not support should_not" do
|
148
|
+
lambda {
|
149
|
+
5.should_not positive_only_matcher(:expected => 5)
|
150
|
+
}.should fail_with(/Matcher does not support should_not.\n/)
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
@@ -1,63 +1,71 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe
|
4
|
-
it "should pass if #has_sym?(*args) returns true" do
|
5
|
-
{:a => "A"}.should have_key(:a)
|
6
|
-
end
|
3
|
+
describe Micronaut::Matchers do
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
describe "should have_sym(*args)" do
|
6
|
+
|
7
|
+
it "should pass if #has_sym?(*args) returns true" do
|
8
|
+
{:a => "A"}.should have_key(:a)
|
9
|
+
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
it "should fail if #has_sym?(*args) returns false" do
|
12
|
+
lambda {
|
13
|
+
{:b => "B"}.should have_key(:a)
|
14
|
+
}.should fail_with("expected #has_key?(:a) to return true, got false")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fail if target does not respond to #has_sym?" do
|
18
|
+
lambda {
|
19
|
+
Object.new.should have_key(:a)
|
20
|
+
}.should raise_error(NoMethodError)
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
it "should reraise an exception thrown in #has_sym?(*args)" do
|
24
|
+
o = Object.new
|
25
|
+
def o.has_sym?(*args)
|
26
|
+
raise "Funky exception"
|
27
|
+
end
|
28
|
+
lambda { o.should have_sym(:foo) }.should raise_error("Funky exception")
|
24
29
|
end
|
25
|
-
|
30
|
+
|
26
31
|
end
|
27
|
-
end
|
28
32
|
|
29
|
-
describe "should_not have_sym(*args)" do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
describe "should_not have_sym(*args)" do
|
34
|
+
|
35
|
+
it "should pass if #has_sym?(*args) returns false" do
|
36
|
+
{:a => "A"}.should_not have_key(:b)
|
37
|
+
end
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
it "should fail if #has_sym?(*args) returns true" do
|
40
|
+
lambda {
|
41
|
+
{:a => "A"}.should_not have_key(:a)
|
42
|
+
}.should fail_with("expected #has_key?(:a) to return false, got true")
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
it "should fail if target does not respond to #has_sym?" do
|
46
|
+
lambda {
|
47
|
+
Object.new.should have_key(:a)
|
48
|
+
}.should raise_error(NoMethodError)
|
49
|
+
end
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
it "should reraise an exception thrown in #has_sym?(*args)" do
|
52
|
+
o = Object.new
|
53
|
+
def o.has_sym?(*args)
|
54
|
+
raise "Funky exception"
|
55
|
+
end
|
56
|
+
lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception")
|
50
57
|
end
|
51
|
-
|
58
|
+
|
52
59
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
|
61
|
+
describe "has" do
|
62
|
+
|
63
|
+
it "should work when the target implements #send" do
|
64
|
+
o = {:a => "A"}
|
65
|
+
def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
66
|
+
lambda { o.should have_key(:a) }.should_not raise_error
|
67
|
+
end
|
68
|
+
|
62
69
|
end
|
63
|
-
|
70
|
+
|
71
|
+
end
|
@@ -1,88 +1,103 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe
|
4
|
-
it "should pass if target includes expected" do
|
5
|
-
[1,2,3].should include(3)
|
6
|
-
"abc".should include("a")
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should pass if target is a Hash and has the expected as a key' do
|
10
|
-
{:key => 'value'}.should include(:key)
|
11
|
-
end
|
3
|
+
describe Micronaut::Matchers do
|
12
4
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
{:key => 'value'}.should include(:
|
22
|
-
|
23
|
-
|
24
|
-
|
5
|
+
describe "should include(expected)" do
|
6
|
+
|
7
|
+
it "should pass if target includes expected" do
|
8
|
+
[1,2,3].should include(3)
|
9
|
+
"abc".should include("a")
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should pass if target is a Hash and has the expected as a key' do
|
13
|
+
{:key => 'value'}.should include(:key)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should fail if target does not include expected" do
|
17
|
+
lambda do
|
18
|
+
[1,2,3].should include(4)
|
19
|
+
end.should fail_with("expected [1, 2, 3] to include 4")
|
20
|
+
lambda do
|
21
|
+
"abc".should include("d")
|
22
|
+
end.should fail_with("expected \"abc\" to include \"d\"")
|
23
|
+
lambda do
|
24
|
+
{:key => 'value'}.should include(:other)
|
25
|
+
end.should fail_with(%Q|expected {:key=>"value"} to include :other|)
|
26
|
+
end
|
25
27
|
|
26
|
-
describe "should include(with, multiple, args)" do
|
27
|
-
it "should pass if target includes all items" do
|
28
|
-
[1,2,3].should include(1,2,3)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should pass if target is a Hash including all items as keys' do
|
32
|
-
{:key => 'value', :other => 'value'}.should include(:key, :other)
|
33
28
|
end
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
describe "should include(with, multiple, args)" do
|
31
|
+
|
32
|
+
it "should pass if target includes all items" do
|
33
|
+
[1,2,3].should include(1,2,3)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should pass if target is a Hash including all items as keys' do
|
37
|
+
{:key => 'value', :other => 'value'}.should include(:key, :other)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should fail if target does not include any one of the items" do
|
41
|
+
lambda do
|
42
|
+
[1,2,3].should include(1,2,4)
|
43
|
+
end.should fail_with("expected [1, 2, 3] to include 1, 2 and 4")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should pass if target is a Hash missing any item as a key' do
|
47
|
+
lambda do
|
48
|
+
{:key => 'value'}.should include(:key, :other)
|
49
|
+
end.should fail_with(%Q|expected {:key=>"value"} to include :key and :other|)
|
50
|
+
end
|
51
|
+
|
39
52
|
end
|
53
|
+
|
54
|
+
describe "should_not include(expected)" do
|
40
55
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
56
|
+
it "should pass if target does not include expected" do
|
57
|
+
[1,2,3].should_not include(4)
|
58
|
+
"abc".should_not include("d")
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should pass if target is a Hash and does not have the expected as a key' do
|
62
|
+
{:other => 'value'}.should_not include(:key)
|
63
|
+
end
|
47
64
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
65
|
+
it "should fail if target includes expected" do
|
66
|
+
lambda {
|
67
|
+
[1,2,3].should_not include(3)
|
68
|
+
}.should fail_with("expected [1, 2, 3] not to include 3")
|
69
|
+
lambda {
|
70
|
+
"abc".should_not include("c")
|
71
|
+
}.should fail_with("expected \"abc\" not to include \"c\"")
|
72
|
+
lambda {
|
73
|
+
{:key => 'value'}.should_not include(:key)
|
74
|
+
}.should fail_with(%Q|expected {:key=>"value"} not to include :key|)
|
75
|
+
end
|
53
76
|
|
54
|
-
it 'should pass if target is a Hash and does not have the expected as a key' do
|
55
|
-
{:other => 'value'}.should_not include(:key)
|
56
77
|
end
|
57
78
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
describe "should include(:key => value)" do
|
80
|
+
|
81
|
+
it "should pass if target is a Hash and includes the key/value pair" do
|
82
|
+
{:key => 'value'}.should include(:key => 'value')
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should pass if target is a Hash and includes the key/value pair among others" do
|
86
|
+
{:key => 'value', :other => 'different'}.should include(:key => 'value')
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should fail if target is a Hash and has a different value for key" do
|
90
|
+
lambda {
|
91
|
+
{:key => 'different'}.should include(:key => 'value')
|
92
|
+
}.should fail_with(%Q|expected {:key=>"different"} to include {:key=>"value"}|)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should fail if target is a Hash and has a different key" do
|
96
|
+
lambda {
|
97
|
+
{:other => 'value'}.should include(:key => 'value')
|
98
|
+
}.should fail_with(%Q|expected {:other=>"value"} to include {:key=>"value"}|)
|
99
|
+
end
|
100
|
+
|
68
101
|
end
|
69
|
-
end
|
70
102
|
|
71
|
-
|
72
|
-
it "should pass if target is a Hash and includes the key/value pair" do
|
73
|
-
{:key => 'value'}.should include(:key => 'value')
|
74
|
-
end
|
75
|
-
it "should pass if target is a Hash and includes the key/value pair among others" do
|
76
|
-
{:key => 'value', :other => 'different'}.should include(:key => 'value')
|
77
|
-
end
|
78
|
-
it "should fail if target is a Hash and has a different value for key" do
|
79
|
-
lambda {
|
80
|
-
{:key => 'different'}.should include(:key => 'value')
|
81
|
-
}.should fail_with(%Q|expected {:key=>"different"} to include {:key=>"value"}|)
|
82
|
-
end
|
83
|
-
it "should fail if target is a Hash and has a different key" do
|
84
|
-
lambda {
|
85
|
-
{:other => 'value'}.should include(:key => 'value')
|
86
|
-
}.should fail_with(%Q|expected {:other=>"value"} to include {:key=>"value"}|)
|
87
|
-
end
|
88
|
-
end
|
103
|
+
end
|
@@ -1,39 +1,43 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Micronaut::Matchers do
|
4
4
|
|
5
|
-
|
6
|
-
"string".should match(/tri/)
|
7
|
-
end
|
5
|
+
describe "should match(expected)" do
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
it "should provide message, expected and actual on failure" do
|
14
|
-
matcher = match(/rings/)
|
15
|
-
matcher.matches?("string")
|
16
|
-
matcher.failure_message.should == ["expected \"string\" to match /rings/", /rings/, "string"]
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
7
|
+
it "should pass when target (String) matches expected (Regexp)" do
|
8
|
+
"string".should match(/tri/)
|
9
|
+
end
|
20
10
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
11
|
+
it "should fail when target (String) does not match expected (Regexp)" do
|
12
|
+
lambda { "string".should match(/rings/) }.should fail
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should provide message, expected and actual on failure" do
|
16
|
+
matcher = match(/rings/)
|
17
|
+
matcher.matches?("string")
|
18
|
+
matcher.failure_message.should == ["expected \"string\" to match /rings/", /rings/, "string"]
|
19
|
+
end
|
26
20
|
|
27
|
-
it "should fail when target (String) matches expected (Regexp)" do
|
28
|
-
lambda {
|
29
|
-
"string".should_not match(/tri/)
|
30
|
-
}.should fail
|
31
21
|
end
|
32
22
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
describe "should_not match(expected)" do
|
24
|
+
|
25
|
+
it "should pass when target (String) matches does not match (Regexp)" do
|
26
|
+
"string".should_not match(/rings/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should fail when target (String) matches expected (Regexp)" do
|
30
|
+
lambda {
|
31
|
+
"string".should_not match(/tri/)
|
32
|
+
}.should fail
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should provide message, expected and actual on failure" do
|
36
|
+
matcher = match(/tri/)
|
37
|
+
matcher.matches?("string")
|
38
|
+
matcher.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
|
39
|
+
end
|
40
|
+
|
37
41
|
end
|
38
|
-
|
42
|
+
|
39
43
|
end
|