spicycode-micronaut 0.0.7 → 0.0.9

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.
Files changed (33) hide show
  1. data/Rakefile +1 -1
  2. data/examples/lib/micronaut/{behaviour_group_example.rb → behaviour_example.rb} +15 -13
  3. data/examples/lib/micronaut/configuration_example.rb +4 -4
  4. data/examples/lib/micronaut/example_example.rb +46 -0
  5. data/examples/lib/micronaut/expectations/extensions/object_example.rb +63 -76
  6. data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +4 -3
  7. data/examples/lib/micronaut/formatters/base_formatter_example.rb +2 -2
  8. data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
  9. data/examples/lib/micronaut/formatters/progress_formatter_example.rb +8 -29
  10. data/examples/lib/micronaut/matchers/be_close_example.rb +48 -38
  11. data/examples/lib/micronaut/matchers/be_example.rb +287 -246
  12. data/examples/lib/micronaut/matchers/change_example.rb +306 -275
  13. data/examples/lib/micronaut/matchers/description_generation_example.rb +168 -160
  14. data/examples/lib/micronaut/matchers/eql_example.rb +30 -24
  15. data/examples/lib/micronaut/matchers/equal_example.rb +31 -25
  16. data/examples/lib/micronaut/matchers/handler_example.rb +36 -29
  17. data/examples/lib/micronaut/matchers/has_example.rb +57 -49
  18. data/examples/lib/micronaut/matchers/include_example.rb +89 -74
  19. data/examples/lib/micronaut/matchers/match_example.rb +33 -29
  20. data/examples/lib/micronaut/world_example.rb +4 -4
  21. data/lib/micronaut/{behaviour_group.rb → behaviour.rb} +8 -7
  22. data/lib/micronaut/configuration.rb +1 -1
  23. data/lib/micronaut/example.rb +5 -1
  24. data/lib/micronaut/formatters/base_formatter.rb +6 -6
  25. data/lib/micronaut/formatters/base_text_formatter.rb +8 -13
  26. data/lib/micronaut/formatters/documentation_formatter.rb +62 -0
  27. data/lib/micronaut/formatters/progress_formatter.rb +1 -0
  28. data/lib/micronaut/formatters.rb +1 -0
  29. data/lib/micronaut/kernel_extensions.rb +1 -1
  30. data/lib/micronaut/runner.rb +1 -4
  31. data/lib/micronaut/runner_options.rb +11 -4
  32. data/lib/micronaut.rb +2 -2
  33. metadata +7 -4
@@ -1,167 +1,175 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
2
 
3
- describe "Matchers should be able to generate their own descriptions" do
4
- after do
5
- Micronaut::Matchers.clear_generated_description
6
- end
3
+ describe Micronaut::Matchers do
7
4
 
8
- it "should == expected" do
9
- "this".should == "this"
10
- Micronaut::Matchers.generated_description.should == "should == \"this\""
11
- end
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
- it "should be_few_words predicate should be transformed to 'be few words'" do
54
- 5.should be_kind_of(Fixnum)
55
- Micronaut::Matchers.generated_description.should == "should be kind of Fixnum"
56
- end
11
+ it "should == expected" do
12
+ "this".should == "this"
13
+ Micronaut::Matchers.generated_description.should == "should == \"this\""
14
+ end
57
15
 
58
- it "should preserve a proper prefix for be predicate" do
59
- 5.should be_a_kind_of(Fixnum)
60
- Micronaut::Matchers.generated_description.should == "should be a kind of Fixnum"
61
- 5.should be_an_instance_of(Fixnum)
62
- Micronaut::Matchers.generated_description.should == "should be an instance of Fixnum"
63
- end
64
-
65
- it "should equal" do
66
- expected = "expected"
67
- expected.should equal(expected)
68
- Micronaut::Matchers.generated_description.should == "should equal \"expected\""
69
- end
70
-
71
- it "should_not equal" do
72
- 5.should_not equal(37)
73
- Micronaut::Matchers.generated_description.should == "should not equal 37"
74
- end
75
-
76
- it "should eql" do
77
- "string".should eql("string")
78
- Micronaut::Matchers.generated_description.should == "should eql \"string\""
79
- end
80
-
81
- it "should not eql" do
82
- "a".should_not eql(:a)
83
- Micronaut::Matchers.generated_description.should == "should not eql :a"
84
- end
85
-
86
- it "should have_key" do
87
- {:a => "a"}.should have_key(:a)
88
- Micronaut::Matchers.generated_description.should == "should have key :a"
89
- end
90
-
91
- it "should have n items" do
92
- team.should have(3).players
93
- Micronaut::Matchers.generated_description.should == "should have 3 players"
94
- end
95
-
96
- it "should have at least n items" do
97
- team.should have_at_least(2).players
98
- Micronaut::Matchers.generated_description.should == "should have at least 2 players"
99
- end
100
-
101
- it "should have at most n items" do
102
- team.should have_at_most(4).players
103
- Micronaut::Matchers.generated_description.should == "should have at most 4 players"
104
- end
105
-
106
- it "should include" do
107
- [1,2,3].should include(3)
108
- Micronaut::Matchers.generated_description.should == "should include 3"
109
- end
110
-
111
- it "should match" do
112
- "this string".should match(/this string/)
113
- Micronaut::Matchers.generated_description.should == "should match /this string/"
114
- end
115
-
116
- it "should raise_error" do
117
- lambda { raise }.should raise_error
118
- Micronaut::Matchers.generated_description.should == "should raise Exception"
119
- end
120
-
121
- it "should raise_error with type" do
122
- lambda { raise }.should raise_error(RuntimeError)
123
- Micronaut::Matchers.generated_description.should == "should raise RuntimeError"
124
- end
125
-
126
- it "should raise_error with type and message" do
127
- lambda { raise "there was an error" }.should raise_error(RuntimeError, "there was an error")
128
- Micronaut::Matchers.generated_description.should == "should raise RuntimeError with \"there was an error\""
129
- end
130
-
131
- it "should respond_to" do
132
- [].should respond_to(:insert)
133
- Micronaut::Matchers.generated_description.should == "should respond to [:insert]"
134
- end
135
-
136
- it "should throw symbol" do
137
- lambda { throw :what_a_mess }.should throw_symbol
138
- Micronaut::Matchers.generated_description.should == "should throw a Symbol"
139
- end
140
-
141
- it "should throw symbol (with named symbol)" do
142
- lambda { throw :what_a_mess }.should throw_symbol(:what_a_mess)
143
- Micronaut::Matchers.generated_description.should == "should throw :what_a_mess"
144
- end
145
-
146
- def team
147
- Class.new do
148
- def players
149
- [1,2,3]
150
- end
151
- end.new
152
- end
153
- end
154
-
155
- describe "a Matcher with no description" do
156
- def matcher
157
- Class.new do
158
- def matches?(ignore); true; end
159
- def failure_message; ""; end
160
- end.new
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
- it "should provide a helpful message when used in a string-less example block" do
164
- 5.should matcher
165
- Micronaut::Matchers.generated_description.should =~ /When you call.*description method/m
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
- end
174
+
175
+ end
@@ -1,29 +1,35 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
2
 
3
- module Micronaut
4
- module Matchers
5
- describe "eql" do
6
- it "should match when actual.eql?(expected)" do
7
- eql(1).matches?(1).should be_true
8
- end
9
- it "should not match when !actual.eql?(expected)" do
10
- eql(1).matches?(2).should be_false
11
- end
12
- it "should describe itself" do
13
- matcher = eql(1)
14
- matcher.matches?(1)
15
- matcher.description.should == "eql 1"
16
- end
17
- it "should provide message, expected and actual on #failure_message" do
18
- matcher = eql("1")
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
- module Micronaut
4
- module Matchers
5
- describe "equal" do
6
- it "should match when actual.equal?(expected)" do
7
- equal(1).matches?(1).should be_true
8
- end
9
- it "should not match when !actual.equal?(expected)" do
10
- equal("1").matches?("1").should be_false
11
- end
12
- it "should describe itself" do
13
- matcher = equal(1)
14
- matcher.matches?(1)
15
- matcher.description.should == "equal 1"
16
- end
17
- it "should provide message, expected and actual on #failure_message" do
18
- matcher = equal("1")
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
- end
34
+
35
+ end