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
@@ -1,167 +1,175 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe
|
4
|
-
after do
|
5
|
-
Micronaut::Matchers.clear_generated_description
|
6
|
-
end
|
3
|
+
describe Micronaut::Matchers do
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
it "should not == expected" do
|
14
|
-
"this".should_not == "that"
|
15
|
-
Micronaut::Matchers.generated_description.should == "should not == \"that\""
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be empty (arbitrary predicate)" do
|
19
|
-
[].should be_empty
|
20
|
-
Micronaut::Matchers.generated_description.should == "should be empty"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should not be empty (arbitrary predicate)" do
|
24
|
-
[1].should_not be_empty
|
25
|
-
Micronaut::Matchers.generated_description.should == "should not be empty"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should be true" do
|
29
|
-
true.should be_true
|
30
|
-
Micronaut::Matchers.generated_description.should == "should be true"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should be false" do
|
34
|
-
false.should be_false
|
35
|
-
Micronaut::Matchers.generated_description.should == "should be false"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should be nil" do
|
39
|
-
nil.should be_nil
|
40
|
-
Micronaut::Matchers.generated_description.should == "should be nil"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should be > n" do
|
44
|
-
5.should be > 3
|
45
|
-
Micronaut::Matchers.generated_description.should == "should be > 3"
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should be predicate arg1, arg2 and arg3" do
|
49
|
-
5.0.should be_between(0,10)
|
50
|
-
Micronaut::Matchers.generated_description.should == "should be between 0 and 10"
|
51
|
-
end
|
5
|
+
describe "should be able to generate their own descriptions" do
|
6
|
+
|
7
|
+
after do
|
8
|
+
Micronaut::Matchers.clear_generated_description
|
9
|
+
end
|
52
10
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
11
|
+
it "should == expected" do
|
12
|
+
"this".should == "this"
|
13
|
+
Micronaut::Matchers.generated_description.should == "should == \"this\""
|
14
|
+
end
|
57
15
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
16
|
+
it "should not == expected" do
|
17
|
+
"this".should_not == "that"
|
18
|
+
Micronaut::Matchers.generated_description.should == "should not == \"that\""
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be empty (arbitrary predicate)" do
|
22
|
+
[].should be_empty
|
23
|
+
Micronaut::Matchers.generated_description.should == "should be empty"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not be empty (arbitrary predicate)" do
|
27
|
+
[1].should_not be_empty
|
28
|
+
Micronaut::Matchers.generated_description.should == "should not be empty"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be true" do
|
32
|
+
true.should be_true
|
33
|
+
Micronaut::Matchers.generated_description.should == "should be true"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be false" do
|
37
|
+
false.should be_false
|
38
|
+
Micronaut::Matchers.generated_description.should == "should be false"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be nil" do
|
42
|
+
nil.should be_nil
|
43
|
+
Micronaut::Matchers.generated_description.should == "should be nil"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be > n" do
|
47
|
+
5.should be > 3
|
48
|
+
Micronaut::Matchers.generated_description.should == "should be > 3"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be predicate arg1, arg2 and arg3" do
|
52
|
+
5.0.should be_between(0,10)
|
53
|
+
Micronaut::Matchers.generated_description.should == "should be between 0 and 10"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be_few_words predicate should be transformed to 'be few words'" do
|
57
|
+
5.should be_kind_of(Fixnum)
|
58
|
+
Micronaut::Matchers.generated_description.should == "should be kind of Fixnum"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should preserve a proper prefix for be predicate" do
|
62
|
+
5.should be_a_kind_of(Fixnum)
|
63
|
+
Micronaut::Matchers.generated_description.should == "should be a kind of Fixnum"
|
64
|
+
5.should be_an_instance_of(Fixnum)
|
65
|
+
Micronaut::Matchers.generated_description.should == "should be an instance of Fixnum"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should equal" do
|
69
|
+
expected = "expected"
|
70
|
+
expected.should equal(expected)
|
71
|
+
Micronaut::Matchers.generated_description.should == "should equal \"expected\""
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should_not equal" do
|
75
|
+
5.should_not equal(37)
|
76
|
+
Micronaut::Matchers.generated_description.should == "should not equal 37"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should eql" do
|
80
|
+
"string".should eql("string")
|
81
|
+
Micronaut::Matchers.generated_description.should == "should eql \"string\""
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should not eql" do
|
85
|
+
"a".should_not eql(:a)
|
86
|
+
Micronaut::Matchers.generated_description.should == "should not eql :a"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should have_key" do
|
90
|
+
{:a => "a"}.should have_key(:a)
|
91
|
+
Micronaut::Matchers.generated_description.should == "should have key :a"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should have n items" do
|
95
|
+
team.should have(3).players
|
96
|
+
Micronaut::Matchers.generated_description.should == "should have 3 players"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should have at least n items" do
|
100
|
+
team.should have_at_least(2).players
|
101
|
+
Micronaut::Matchers.generated_description.should == "should have at least 2 players"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should have at most n items" do
|
105
|
+
team.should have_at_most(4).players
|
106
|
+
Micronaut::Matchers.generated_description.should == "should have at most 4 players"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should include" do
|
110
|
+
[1,2,3].should include(3)
|
111
|
+
Micronaut::Matchers.generated_description.should == "should include 3"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should match" do
|
115
|
+
"this string".should match(/this string/)
|
116
|
+
Micronaut::Matchers.generated_description.should == "should match /this string/"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should raise_error" do
|
120
|
+
lambda { raise }.should raise_error
|
121
|
+
Micronaut::Matchers.generated_description.should == "should raise Exception"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should raise_error with type" do
|
125
|
+
lambda { raise }.should raise_error(RuntimeError)
|
126
|
+
Micronaut::Matchers.generated_description.should == "should raise RuntimeError"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should raise_error with type and message" do
|
130
|
+
lambda { raise "there was an error" }.should raise_error(RuntimeError, "there was an error")
|
131
|
+
Micronaut::Matchers.generated_description.should == "should raise RuntimeError with \"there was an error\""
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should respond_to" do
|
135
|
+
[].should respond_to(:insert)
|
136
|
+
Micronaut::Matchers.generated_description.should == "should respond to [:insert]"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should throw symbol" do
|
140
|
+
lambda { throw :what_a_mess }.should throw_symbol
|
141
|
+
Micronaut::Matchers.generated_description.should == "should throw a Symbol"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should throw symbol (with named symbol)" do
|
145
|
+
lambda { throw :what_a_mess }.should throw_symbol(:what_a_mess)
|
146
|
+
Micronaut::Matchers.generated_description.should == "should throw :what_a_mess"
|
147
|
+
end
|
148
|
+
|
149
|
+
def team
|
150
|
+
Class.new do
|
151
|
+
def players
|
152
|
+
[1,2,3]
|
153
|
+
end
|
154
|
+
end.new
|
155
|
+
end
|
156
|
+
|
161
157
|
end
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
158
|
+
|
159
|
+
describe "a matcher with no description" do
|
160
|
+
|
161
|
+
def matcher
|
162
|
+
Class.new do
|
163
|
+
def matches?(ignore); true; end
|
164
|
+
def failure_message; ""; end
|
165
|
+
end.new
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should provide a helpful message when used in a string-less example block" do
|
169
|
+
5.should matcher
|
170
|
+
Micronaut::Matchers.generated_description.should =~ /When you call.*description method/m
|
171
|
+
end
|
172
|
+
|
166
173
|
end
|
167
|
-
|
174
|
+
|
175
|
+
end
|
@@ -1,29 +1,35 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
matcher.matches?(1)
|
20
|
-
matcher.failure_message.should == ["expected \"1\", got 1 (using .eql?)", "1", 1]
|
21
|
-
end
|
22
|
-
it "should provide message, expected and actual on #negative_failure_message" do
|
23
|
-
matcher = eql(1)
|
24
|
-
matcher.matches?(1)
|
25
|
-
matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .eql?)", 1, 1]
|
26
|
-
end
|
3
|
+
describe Micronaut::Matchers do
|
4
|
+
|
5
|
+
describe "eql" do
|
6
|
+
|
7
|
+
it "should match when actual.eql?(expected)" do
|
8
|
+
eql(1).matches?(1).should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not match when !actual.eql?(expected)" do
|
12
|
+
eql(1).matches?(2).should be_false
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should describe itself" do
|
16
|
+
matcher = eql(1)
|
17
|
+
matcher.matches?(1)
|
18
|
+
matcher.description.should == "eql 1"
|
27
19
|
end
|
20
|
+
|
21
|
+
it "should provide message, expected and actual on #failure_message" do
|
22
|
+
matcher = eql("1")
|
23
|
+
matcher.matches?(1)
|
24
|
+
matcher.failure_message.should == ["expected \"1\", got 1 (using .eql?)", "1", 1]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should provide message, expected and actual on #negative_failure_message" do
|
28
|
+
matcher = eql(1)
|
29
|
+
matcher.matches?(1)
|
30
|
+
matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .eql?)", 1, 1]
|
31
|
+
end
|
32
|
+
|
28
33
|
end
|
34
|
+
|
29
35
|
end
|
@@ -1,29 +1,35 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
matcher.matches?(1)
|
20
|
-
matcher.failure_message.should == ["expected \"1\", got 1 (using .equal?)", "1", 1]
|
21
|
-
end
|
22
|
-
it "should provide message, expected and actual on #negative_failure_message" do
|
23
|
-
matcher = equal(1)
|
24
|
-
matcher.matches?(1)
|
25
|
-
matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .equal?)", 1, 1]
|
26
|
-
end
|
3
|
+
describe Micronaut::Matchers do
|
4
|
+
|
5
|
+
describe "equal" do
|
6
|
+
|
7
|
+
it "should match when actual.equal?(expected)" do
|
8
|
+
equal(1).matches?(1).should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not match when !actual.equal?(expected)" do
|
12
|
+
equal("1").matches?("1").should be_false
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should describe itself" do
|
16
|
+
matcher = equal(1)
|
17
|
+
matcher.matches?(1)
|
18
|
+
matcher.description.should == "equal 1"
|
27
19
|
end
|
20
|
+
|
21
|
+
it "should provide message, expected and actual on #failure_message" do
|
22
|
+
matcher = equal("1")
|
23
|
+
matcher.matches?(1)
|
24
|
+
matcher.failure_message.should == ["expected \"1\", got 1 (using .equal?)", "1", 1]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should provide message, expected and actual on #negative_failure_message" do
|
28
|
+
matcher = equal(1)
|
29
|
+
matcher.matches?(1)
|
30
|
+
matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .equal?)", 1, 1]
|
31
|
+
end
|
32
|
+
|
28
33
|
end
|
29
|
-
|
34
|
+
|
35
|
+
end
|