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.
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
@@ -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
- # describe Micronaut::Expectations::ExpectationMatcherHandler do
120
- # include ExampleExpectations
121
- #
122
- # it "should handle submitted args" do
123
- # 5.should arbitrary_matcher(:expected => 5)
124
- # 5.should arbitrary_matcher(:expected => "wrong").with(5)
125
- # lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5")
126
- # lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5")
127
- # 5.should_not arbitrary_matcher(:expected => 4)
128
- # 5.should_not arbitrary_matcher(:expected => 5).with(4)
129
- # lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5")
130
- # lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5")
131
- # end
132
- #
133
- # it "should handle the submitted block" do
134
- # 5.should arbitrary_matcher { 5 }
135
- # 5.should arbitrary_matcher(:expected => 4) { 5 }
136
- # 5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
137
- # end
138
- #
139
- # it "should explain when matcher does not support should_not" do
140
- # lambda {
141
- # 5.should_not positive_only_matcher(:expected => 5)
142
- # }.should fail_with(/Matcher does not support should_not.\n/)
143
- # end
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 "should have_sym(*args)" do
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
- it "should fail if #has_sym?(*args) returns false" do
9
- lambda {
10
- {:b => "B"}.should have_key(:a)
11
- }.should fail_with("expected #has_key?(:a) to return true, got false")
12
- end
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
- it "should fail if target does not respond to #has_sym?" do
15
- lambda {
16
- Object.new.should have_key(:a)
17
- }.should raise_error(NoMethodError)
18
- end
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
- it "should reraise an exception thrown in #has_sym?(*args)" do
21
- o = Object.new
22
- def o.has_sym?(*args)
23
- raise "Funky exception"
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
- lambda { o.should have_sym(:foo) }.should raise_error("Funky exception")
30
+
26
31
  end
27
- end
28
32
 
29
- describe "should_not have_sym(*args)" do
30
- it "should pass if #has_sym?(*args) returns false" do
31
- {:a => "A"}.should_not have_key(:b)
32
- end
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
- it "should fail if #has_sym?(*args) returns true" do
35
- lambda {
36
- {:a => "A"}.should_not have_key(:a)
37
- }.should fail_with("expected #has_key?(:a) to return false, got true")
38
- end
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
- it "should fail if target does not respond to #has_sym?" do
41
- lambda {
42
- Object.new.should have_key(:a)
43
- }.should raise_error(NoMethodError)
44
- end
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
- it "should reraise an exception thrown in #has_sym?(*args)" do
47
- o = Object.new
48
- def o.has_sym?(*args)
49
- raise "Funky exception"
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
- lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception")
58
+
52
59
  end
53
- end
54
-
55
- describe "has" do
56
- it "should work when the target implements #send" do
57
- o = {:a => "A"}
58
- def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
59
- lambda {
60
- o.should have_key(:a)
61
- }.should_not raise_error
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
- end
70
+
71
+ end
@@ -1,88 +1,103 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
2
 
3
- describe "should include(expected)" do
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
- it "should fail if target does not include expected" do
14
- lambda {
15
- [1,2,3].should include(4)
16
- }.should fail_with("expected [1, 2, 3] to include 4")
17
- lambda {
18
- "abc".should include("d")
19
- }.should fail_with("expected \"abc\" to include \"d\"")
20
- lambda {
21
- {:key => 'value'}.should include(:other)
22
- }.should fail_with(%Q|expected {:key=>"value"} to include :other|)
23
- end
24
- end
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
- it "should fail if target does not include any one of the items" do
36
- lambda {
37
- [1,2,3].should include(1,2,4)
38
- }.should fail_with("expected [1, 2, 3] to include 1, 2 and 4")
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
- it 'should pass if target is a Hash missing any item as a key' do
42
- lambda {
43
- {:key => 'value'}.should include(:key, :other)
44
- }.should fail_with(%Q|expected {:key=>"value"} to include :key and :other|)
45
- end
46
- end
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
- describe "should_not include(expected)" do
49
- it "should pass if target does not include expected" do
50
- [1,2,3].should_not include(4)
51
- "abc".should_not include("d")
52
- end
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
- it "should fail if target includes expected" do
59
- lambda {
60
- [1,2,3].should_not include(3)
61
- }.should fail_with("expected [1, 2, 3] not to include 3")
62
- lambda {
63
- "abc".should_not include("c")
64
- }.should fail_with("expected \"abc\" not to include \"c\"")
65
- lambda {
66
- {:key => 'value'}.should_not include(:key)
67
- }.should fail_with(%Q|expected {:key=>"value"} not to include :key|)
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
- describe "should include(:key => value)" do
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 "should match(expected)" do
3
+ describe Micronaut::Matchers do
4
4
 
5
- it "should pass when target (String) matches expected (Regexp)" do
6
- "string".should match(/tri/)
7
- end
5
+ describe "should match(expected)" do
8
6
 
9
- it "should fail when target (String) does not match expected (Regexp)" do
10
- lambda { "string".should match(/rings/) }.should fail
11
- end
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
- describe "should_not match(expected)" do
22
-
23
- it "should pass when target (String) matches does not match (Regexp)" do
24
- "string".should_not match(/rings/)
25
- end
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
- it "should provide message, expected and actual on failure" do
34
- matcher = match(/tri/)
35
- matcher.matches?("string")
36
- matcher.negative_failure_message.should == ["expected \"string\" not to match /tri/", /tri/, "string"]
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