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 CHANGED
@@ -4,7 +4,7 @@ require 'rubygems/specification'
4
4
  require 'date'
5
5
 
6
6
  GEM = "micronaut"
7
- GEM_VERSION = "0.1.3"
7
+ GEM_VERSION = "0.1.4"
8
8
  AUTHOR = "Chad Humphries"
9
9
  EMAIL = "chad@spicycode.com"
10
10
  HOMEPAGE = "http://spicycode.com"
@@ -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 => :documentation)
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::Configuration.new.mock_with :mocha
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::Configuration.new.mock_with
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 FocusedSupport
40
+ module ThatThingISentYou
41
41
 
42
- def fit(desc, options={}, &block)
43
- it(desc, options.update(:focused => true), &block)
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 group" do
49
- Micronaut.configuration.extend(FocusedSupport)
50
- group = Micronaut::Behaviour.describe(FocusedSupport, 'the focused support ') { }
51
- group.should respond_to(:fit)
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
- describe "wrap_expectation" do
6
-
7
- def stub_matcher
8
- @_stub_matcher ||= simple_matcher do
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 == "\nFinished in 3 seconds\n2 examples, 1 failure\n"
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 == "\nFinished in 3 seconds\n2 examples, 1 failure, 1 pending\n"
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
- module Micronaut
4
- module Matchers
5
- describe %Q{The Micronaut::Matchers module gets included in the execution context of every spec.
6
- This module should provide the following methods, each of which returns a Matcher object.} do
7
- it "be_true" do
8
- be_true.should be_an_instance_of(Be)
9
- end
10
- it "be_false" do
11
- be_false.should be_an_instance_of(Be)
12
- end
13
- it "be_nil" do
14
- be_nil.should be_an_instance_of(Be)
15
- end
16
- it "be_arbitrary_predicate" do
17
- be_arbitrary_predicate.should be_an_instance_of(Be)
18
- end
19
- it "change" do
20
- change("target", :message).should be_an_instance_of(Change)
21
- end
22
- it "have" do
23
- have(0).should be_an_instance_of(Have)
24
- end
25
- it "have_exactly" do
26
- have_exactly(0).should be_an_instance_of(Have)
27
- end
28
- it "have_at_least" do
29
- have_at_least(0).should be_an_instance_of(Have)
30
- end
31
- it "have_at_most" do
32
- have_at_most(0).should be_an_instance_of(Have)
33
- end
34
- it "include" do
35
- include(:value).should be_an_instance_of(Include)
36
- end
37
- it "raise_error" do
38
- raise_error.should be_an_instance_of(RaiseError)
39
- raise_error(NoMethodError).should be_an_instance_of(RaiseError)
40
- raise_error(NoMethodError, "message").should be_an_instance_of(RaiseError)
41
- end
42
- it "satisfy" do
43
- satisfy{}.should be_an_instance_of(Satisfy)
44
- end
45
- it "throw_symbol" do
46
- throw_symbol.should be_an_instance_of(ThrowSymbol)
47
- throw_symbol(:sym).should be_an_instance_of(ThrowSymbol)
48
- end
49
- it "respond_to" do
50
- respond_to(:sym).should be_an_instance_of(RespondTo)
51
- end
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
- describe "Micronaut::Matchers#method_missing" do
55
- it "should convert be_xyz to Be(:be_xyz)" do
56
- Be.expects(:new).with(:be_whatever)
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
- end
77
+
78
+ end
@@ -1,189 +1,193 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
2
 
3
- describe "should ==" do
3
+ describe "Operator Matchers" do
4
4
 
5
- it "should delegate message to target" do
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
- it "should fail when target.==(actual) returns false" do
17
- subject = "apple"
18
- Micronaut::Expectations.expects(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
19
- subject.should == "orange"
20
- end
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
- end
23
-
24
- describe "should_not ==" do
13
+ it "should return true on success" do
14
+ subject = "apple"
15
+ (subject.should == "apple").should be_true
16
+ end
25
17
 
26
- it "should delegate message to target" do
27
- subject = "orange"
28
- subject.expects(:==).with("apple").returns(false)
29
- subject.should_not == "apple"
30
- end
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
- it "should fail when target.==(actual) returns false" do
38
- subject = "apple"
39
- Micronaut::Expectations.expects(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple")
40
- subject.should_not == "apple"
41
- end
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
- end
34
+ it "should return true on success" do
35
+ subject = "apple"
36
+ (subject.should_not == "orange").should be_true
37
+ end
44
38
 
45
- describe "should ===" do
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
- it "should fail when target.===(actual) returns false" do
54
- subject = "apple"
55
- subject.expects(:===).with("orange").returns(false)
56
- Micronaut::Expectations.expects(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple")
57
- subject.should === "orange"
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
- end
61
-
62
- describe "should_not ===" do
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
- it "should fail when target.===(actual) returns false" do
71
- subject = "apple"
72
- subject.expects(:===).with("apple").returns(true)
73
- Micronaut::Expectations.expects(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple")
74
- subject.should_not === "apple"
75
- end
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
- it "should delegate message to target" do
82
- subject = "foo"
83
- subject.expects(:=~).with(/oo/).returns(true)
84
- subject.should =~ /oo/
85
- end
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
- it "should fail when target.=~(actual) returns false" do
88
- subject = "fu"
89
- subject.expects(:=~).with(/oo/).returns(false)
90
- Micronaut::Expectations.expects(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu")
91
- subject.should =~ /oo/
92
- end
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
- it "should delegate message to target" do
99
- subject = "fu"
100
- subject.expects(:=~).with(/oo/).returns(false)
101
- subject.should_not =~ /oo/
102
- end
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
- it "should fail when target.=~(actual) returns false" do
105
- subject = "foo"
106
- subject.expects(:=~).with(/oo/).returns(true)
107
- Micronaut::Expectations.expects(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo")
108
- subject.should_not =~ /oo/
109
- end
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
- it "should pass if > passes" do
116
- 4.should > 3
117
- end
117
+ it "should pass if > passes" do
118
+ 4.should > 3
119
+ end
118
120
 
119
- it "should fail if > fails" do
120
- Micronaut::Expectations.expects(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4)
121
- 4.should > 5
122
- end
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
- it "should pass if >= passes" do
129
- 4.should > 3
130
- 4.should >= 4
131
- end
130
+ it "should pass if >= passes" do
131
+ 4.should > 3
132
+ 4.should >= 4
133
+ end
132
134
 
133
- it "should fail if > fails" do
134
- Micronaut::Expectations.expects(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4)
135
- 4.should >= 5
136
- end
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
- it "should pass if < passes" do
143
- 4.should < 5
144
- end
144
+ it "should pass if < passes" do
145
+ 4.should < 5
146
+ end
145
147
 
146
- it "should fail if > fails" do
147
- Micronaut::Expectations.expects(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4)
148
- 4.should < 3
149
- end
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
- it "should pass if <= passes" do
156
- 4.should <= 5
157
- 4.should <= 4
158
- end
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
- end
169
+ describe Micronaut::Matchers::PositiveOperatorMatcher do
166
170
 
167
- describe Micronaut::Matchers::PositiveOperatorMatcher do
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
- end
181
+ describe Micronaut::Matchers::NegativeOperatorMatcher do
178
182
 
179
- describe Micronaut::Matchers::NegativeOperatorMatcher do
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