spicycode-micronaut 0.1.3 → 0.1.4
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/Rakefile +1 -1
- data/examples/example_helper.rb +2 -1
- data/examples/lib/micronaut/configuration_example.rb +9 -9
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +21 -25
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +3 -2
- data/examples/lib/micronaut/matchers/matcher_methods_example.rb +73 -61
- data/examples/lib/micronaut/matchers/operator_matcher_example.rb +141 -137
- data/examples/lib/micronaut/matchers/raise_error_example.rb +251 -249
- data/lib/micronaut/behaviour.rb +1 -1
- data/lib/micronaut/configuration.rb +3 -0
- data/lib/micronaut/formatters/base_formatter.rb +5 -0
- data/lib/micronaut/formatters/base_text_formatter.rb +29 -1
- metadata +2 -4
data/Rakefile
CHANGED
data/examples/example_helper.rb
CHANGED
@@ -29,7 +29,8 @@ end
|
|
29
29
|
|
30
30
|
Micronaut.configure do |config|
|
31
31
|
config.mock_with :mocha
|
32
|
-
config.options = Micronaut::RunnerOptions.new(:color => true, :formatter => :
|
32
|
+
config.options = Micronaut::RunnerOptions.new(:color => true, :formatter => :progress)
|
33
|
+
config.profile_examples = true
|
33
34
|
# config.add_filter :options => { :focused => true }
|
34
35
|
config.autorun!
|
35
36
|
end
|
@@ -6,12 +6,12 @@ describe Micronaut::Configuration do
|
|
6
6
|
|
7
7
|
it "should include the mocha adapter when called with :mocha" do
|
8
8
|
Micronaut::Behaviour.expects(:send).with(:include, Micronaut::Mocking::WithMocha)
|
9
|
-
Micronaut
|
9
|
+
Micronaut.configuration.mock_with :mocha
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should include the do absolutely nothing mocking adapter for all other cases" do
|
13
13
|
Micronaut::Behaviour.expects(:send).with(:include, Micronaut::Mocking::WithAbsolutelyNothing)
|
14
|
-
Micronaut
|
14
|
+
Micronaut.configuration.mock_with
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -37,18 +37,18 @@ describe Micronaut::Configuration do
|
|
37
37
|
|
38
38
|
describe "#extend" do
|
39
39
|
|
40
|
-
module
|
40
|
+
module ThatThingISentYou
|
41
41
|
|
42
|
-
def
|
43
|
-
it(desc, options.update(:
|
42
|
+
def that_thing(desc, options={}, &block)
|
43
|
+
it(desc, options.update(:that_thing => true), &block)
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
-
focused "should extend the given module into each behaviour
|
49
|
-
Micronaut.configuration.extend(
|
50
|
-
group = Micronaut::Behaviour.describe(
|
51
|
-
group.should respond_to(:
|
48
|
+
focused "should extend the given module into each behaviour" do
|
49
|
+
Micronaut.configuration.extend(ThatThingISentYou)
|
50
|
+
group = Micronaut::Behaviour.describe(ThatThingISentYou, 'that thing i sent you') { }
|
51
|
+
group.should respond_to(:that_thing)
|
52
52
|
remove_last_describe_from_world
|
53
53
|
end
|
54
54
|
|
@@ -1,31 +1,27 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe Micronaut::Matchers do
|
3
|
+
describe Micronaut::Matchers, '#wrap_expectation' do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def failing_matcher
|
13
|
-
@_failing_matcher ||= simple_matcher do
|
14
|
-
1.should == 2
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return true if there is no error" do
|
19
|
-
wrap_expectation stub_matcher do
|
20
|
-
end.should be_true
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should return false if there is an error" do
|
24
|
-
wrap_expectation failing_matcher do
|
25
|
-
raise "error"
|
26
|
-
end.should be_false
|
27
|
-
end
|
5
|
+
def stub_matcher
|
6
|
+
@_stub_matcher ||= simple_matcher do
|
7
|
+
end
|
8
|
+
end
|
28
9
|
|
10
|
+
def failing_matcher
|
11
|
+
@_failing_matcher ||= simple_matcher do
|
12
|
+
1.should == 2
|
29
13
|
end
|
30
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return true if there is no error" do
|
17
|
+
wrap_expectation stub_matcher do
|
18
|
+
end.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return false if there is an error" do
|
22
|
+
wrap_expectation failing_matcher do
|
23
|
+
raise "error"
|
24
|
+
end.should be_false
|
25
|
+
end
|
26
|
+
|
31
27
|
end
|
@@ -7,6 +7,7 @@ describe Micronaut::Formatters::ProgressFormatter do
|
|
7
7
|
@options = mock('options')
|
8
8
|
@options.stubs(:enable_color_in_output?).returns(false)
|
9
9
|
@formatter = Micronaut::Formatters::ProgressFormatter.new(@options, @io)
|
10
|
+
@original_profile_setting = Micronaut.configuration.profile_examples
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should produce line break on start dump" do
|
@@ -16,7 +17,7 @@ describe Micronaut::Formatters::ProgressFormatter do
|
|
16
17
|
|
17
18
|
it "should produce standard summary without pending when pending has a 0 count" do
|
18
19
|
@formatter.dump_summary(3, 2, 1, 0)
|
19
|
-
@io.string.should
|
20
|
+
@io.string.should =~ /\nFinished in 3 seconds\n2 examples, 1 failure\n/
|
20
21
|
end
|
21
22
|
|
22
23
|
it "should produce standard summary" do
|
@@ -28,7 +29,7 @@ describe Micronaut::Formatters::ProgressFormatter do
|
|
28
29
|
@formatter.example_pending(example, "message")
|
29
30
|
@io.rewind
|
30
31
|
@formatter.dump_summary(3, 2, 1, 1)
|
31
|
-
@io.string.should
|
32
|
+
@io.string.should =~ /\nFinished in 3 seconds\n2 examples, 1 failure, 1 pending\n/
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should push green dot for passing spec" do
|
@@ -1,66 +1,78 @@
|
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
3
|
+
describe Micronaut::Matchers, "provides the following matchers to examples" do
|
4
|
+
|
5
|
+
it "be_true" do
|
6
|
+
be_true.should be_an_instance_of(Micronaut::Matchers::Be)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "be_false" do
|
10
|
+
be_false.should be_an_instance_of(Micronaut::Matchers::Be)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "be_nil" do
|
14
|
+
be_nil.should be_an_instance_of(Micronaut::Matchers::Be)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "be_arbitrary_predicate" do
|
18
|
+
be_arbitrary_predicate.should be_an_instance_of(Micronaut::Matchers::Be)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "change" do
|
22
|
+
change("target", :message).should be_an_instance_of(Micronaut::Matchers::Change)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "have" do
|
26
|
+
have(0).should be_an_instance_of(Micronaut::Matchers::Have)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "have_exactly" do
|
30
|
+
have_exactly(0).should be_an_instance_of(Micronaut::Matchers::Have)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "have_at_least" do
|
34
|
+
have_at_least(0).should be_an_instance_of(Micronaut::Matchers::Have)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "have_at_most" do
|
38
|
+
have_at_most(0).should be_an_instance_of(Micronaut::Matchers::Have)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "include" do
|
42
|
+
include(:value).should be_an_instance_of(Micronaut::Matchers::Include)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raise_error" do
|
46
|
+
raise_error.should be_an_instance_of(Micronaut::Matchers::RaiseError)
|
47
|
+
raise_error(NoMethodError).should be_an_instance_of(Micronaut::Matchers::RaiseError)
|
48
|
+
raise_error(NoMethodError, "message").should be_an_instance_of(Micronaut::Matchers::RaiseError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "satisfy" do
|
52
|
+
satisfy{}.should be_an_instance_of(Micronaut::Matchers::Satisfy)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "throw_symbol" do
|
56
|
+
throw_symbol.should be_an_instance_of(Micronaut::Matchers::ThrowSymbol)
|
57
|
+
throw_symbol(:sym).should be_an_instance_of(Micronaut::Matchers::ThrowSymbol)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "respond_to" do
|
61
|
+
respond_to(:sym).should be_an_instance_of(Micronaut::Matchers::RespondTo)
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#method_missing" do
|
65
|
+
|
66
|
+
it "should convert be_xyz to Be(:be_xyz)" do
|
67
|
+
Micronaut::Matchers::Be.expects(:new).with(:be_whatever)
|
68
|
+
be_whatever
|
52
69
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
be_whatever
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should convert have_xyz to Has(:have_xyz)" do
|
61
|
-
self.expects(:has).with(:have_whatever)
|
62
|
-
have_whatever
|
63
|
-
end
|
70
|
+
|
71
|
+
it "should convert have_xyz to Has(:have_xyz)" do
|
72
|
+
self.expects(:has).with(:have_whatever)
|
73
|
+
have_whatever
|
64
74
|
end
|
75
|
+
|
65
76
|
end
|
66
|
-
|
77
|
+
|
78
|
+
end
|
@@ -1,189 +1,193 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "Operator Matchers" do
|
4
4
|
|
5
|
-
|
6
|
-
subject = "apple"
|
7
|
-
subject.expects(:==).with("apple").returns(true)
|
8
|
-
subject.should == "apple"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should return true on success" do
|
12
|
-
subject = "apple"
|
13
|
-
(subject.should == "apple").should be_true
|
14
|
-
end
|
5
|
+
describe "should ==" do
|
15
6
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
7
|
+
it "should delegate message to target" do
|
8
|
+
subject = "apple"
|
9
|
+
subject.expects(:==).with("apple").returns(true)
|
10
|
+
subject.should == "apple"
|
11
|
+
end
|
21
12
|
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
it "should return true on success" do
|
14
|
+
subject = "apple"
|
15
|
+
(subject.should == "apple").should be_true
|
16
|
+
end
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
it "should fail when target.==(actual) returns false" do
|
19
|
+
subject = "apple"
|
20
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
|
21
|
+
subject.should == "orange"
|
22
|
+
end
|
31
23
|
|
32
|
-
it "should return true on success" do
|
33
|
-
subject = "apple"
|
34
|
-
(subject.should_not == "orange").should be_true
|
35
24
|
end
|
36
25
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
26
|
+
describe "should_not ==" do
|
27
|
+
|
28
|
+
it "should delegate message to target" do
|
29
|
+
subject = "orange"
|
30
|
+
subject.expects(:==).with("apple").returns(false)
|
31
|
+
subject.should_not == "apple"
|
32
|
+
end
|
42
33
|
|
43
|
-
|
34
|
+
it "should return true on success" do
|
35
|
+
subject = "apple"
|
36
|
+
(subject.should_not == "orange").should be_true
|
37
|
+
end
|
44
38
|
|
45
|
-
|
39
|
+
it "should fail when target.==(actual) returns false" do
|
40
|
+
subject = "apple"
|
41
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple")
|
42
|
+
subject.should_not == "apple"
|
43
|
+
end
|
46
44
|
|
47
|
-
it "should delegate message to target" do
|
48
|
-
subject = "apple"
|
49
|
-
subject.expects(:===).with("apple").returns(true)
|
50
|
-
subject.should === "apple"
|
51
45
|
end
|
46
|
+
|
47
|
+
describe "should ===" do
|
52
48
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
49
|
+
it "should delegate message to target" do
|
50
|
+
subject = "apple"
|
51
|
+
subject.expects(:===).with("apple").returns(true)
|
52
|
+
subject.should === "apple"
|
53
|
+
end
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
it "should fail when target.===(actual) returns false" do
|
56
|
+
subject = "apple"
|
57
|
+
subject.expects(:===).with("orange").returns(false)
|
58
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple")
|
59
|
+
subject.should === "orange"
|
60
|
+
end
|
63
61
|
|
64
|
-
it "should delegate message to target" do
|
65
|
-
subject = "orange"
|
66
|
-
subject.expects(:===).with("apple").returns(false)
|
67
|
-
subject.should_not === "apple"
|
68
62
|
end
|
63
|
+
|
64
|
+
describe "should_not ===" do
|
69
65
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
66
|
+
it "should delegate message to target" do
|
67
|
+
subject = "orange"
|
68
|
+
subject.expects(:===).with("apple").returns(false)
|
69
|
+
subject.should_not === "apple"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should fail when target.===(actual) returns false" do
|
73
|
+
subject = "apple"
|
74
|
+
subject.expects(:===).with("apple").returns(true)
|
75
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple")
|
76
|
+
subject.should_not === "apple"
|
77
|
+
end
|
76
78
|
|
77
|
-
end
|
79
|
+
end
|
78
80
|
|
79
|
-
describe "should =~" do
|
81
|
+
describe "should =~" do
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
it "should delegate message to target" do
|
84
|
+
subject = "foo"
|
85
|
+
subject.expects(:=~).with(/oo/).returns(true)
|
86
|
+
subject.should =~ /oo/
|
87
|
+
end
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
it "should fail when target.=~(actual) returns false" do
|
90
|
+
subject = "fu"
|
91
|
+
subject.expects(:=~).with(/oo/).returns(false)
|
92
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu")
|
93
|
+
subject.should =~ /oo/
|
94
|
+
end
|
93
95
|
|
94
|
-
end
|
96
|
+
end
|
95
97
|
|
96
|
-
describe "should_not =~" do
|
98
|
+
describe "should_not =~" do
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
it "should delegate message to target" do
|
101
|
+
subject = "fu"
|
102
|
+
subject.expects(:=~).with(/oo/).returns(false)
|
103
|
+
subject.should_not =~ /oo/
|
104
|
+
end
|
103
105
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
it "should fail when target.=~(actual) returns false" do
|
107
|
+
subject = "foo"
|
108
|
+
subject.expects(:=~).with(/oo/).returns(true)
|
109
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo")
|
110
|
+
subject.should_not =~ /oo/
|
111
|
+
end
|
110
112
|
|
111
|
-
end
|
113
|
+
end
|
112
114
|
|
113
|
-
describe "should >" do
|
115
|
+
describe "should >" do
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
-
|
117
|
+
it "should pass if > passes" do
|
118
|
+
4.should > 3
|
119
|
+
end
|
118
120
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
121
|
+
it "should fail if > fails" do
|
122
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4)
|
123
|
+
4.should > 5
|
124
|
+
end
|
123
125
|
|
124
|
-
end
|
126
|
+
end
|
125
127
|
|
126
|
-
describe "should >=" do
|
128
|
+
describe "should >=" do
|
127
129
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
130
|
+
it "should pass if >= passes" do
|
131
|
+
4.should > 3
|
132
|
+
4.should >= 4
|
133
|
+
end
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
it "should fail if > fails" do
|
136
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4)
|
137
|
+
4.should >= 5
|
138
|
+
end
|
137
139
|
|
138
|
-
end
|
140
|
+
end
|
139
141
|
|
140
|
-
describe "should <" do
|
142
|
+
describe "should <" do
|
141
143
|
|
142
|
-
|
143
|
-
|
144
|
-
|
144
|
+
it "should pass if < passes" do
|
145
|
+
4.should < 5
|
146
|
+
end
|
145
147
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
148
|
+
it "should fail if > fails" do
|
149
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4)
|
150
|
+
4.should < 3
|
151
|
+
end
|
150
152
|
|
151
|
-
end
|
153
|
+
end
|
152
154
|
|
153
|
-
describe "should <=" do
|
155
|
+
describe "should <=" do
|
154
156
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
157
|
+
it "should pass if <= passes" do
|
158
|
+
4.should <= 5
|
159
|
+
4.should <= 4
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should fail if > fails" do
|
163
|
+
Micronaut::Expectations.expects(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4)
|
164
|
+
4.should <= 3
|
165
|
+
end
|
159
166
|
|
160
|
-
it "should fail if > fails" do
|
161
|
-
Micronaut::Expectations.expects(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4)
|
162
|
-
4.should <= 3
|
163
167
|
end
|
164
168
|
|
165
|
-
|
169
|
+
describe Micronaut::Matchers::PositiveOperatorMatcher do
|
166
170
|
|
167
|
-
|
171
|
+
it "should work when the target has implemented #send" do
|
172
|
+
o = Object.new
|
173
|
+
def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
174
|
+
lambda {
|
175
|
+
o.should == o
|
176
|
+
}.should_not raise_error
|
177
|
+
end
|
168
178
|
|
169
|
-
it "should work when the target has implemented #send" do
|
170
|
-
o = Object.new
|
171
|
-
def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
172
|
-
lambda {
|
173
|
-
o.should == o
|
174
|
-
}.should_not raise_error
|
175
179
|
end
|
176
180
|
|
177
|
-
|
181
|
+
describe Micronaut::Matchers::NegativeOperatorMatcher do
|
178
182
|
|
179
|
-
|
183
|
+
it "should work when the target has implemented #send" do
|
184
|
+
o = Object.new
|
185
|
+
def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
186
|
+
lambda {
|
187
|
+
o.should_not == :foo
|
188
|
+
}.should_not raise_error
|
189
|
+
end
|
180
190
|
|
181
|
-
it "should work when the target has implemented #send" do
|
182
|
-
o = Object.new
|
183
|
-
def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
184
|
-
lambda {
|
185
|
-
o.should_not == :foo
|
186
|
-
}.should_not raise_error
|
187
191
|
end
|
188
192
|
|
189
|
-
end
|
193
|
+
end
|