spicycode-micronaut 0.0.2 → 0.0.3

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 (58) hide show
  1. data/Rakefile +23 -10
  2. data/examples/example_helper.rb +3 -3
  3. data/examples/lib/micronaut/behaviour_group_example.rb +175 -0
  4. data/examples/lib/micronaut/expectations/differs/default_example.rb +1 -2
  5. data/examples/lib/micronaut/expectations/extensions/object_example.rb +15 -8
  6. data/examples/lib/micronaut/expectations/fail_with_example.rb +2 -2
  7. data/examples/lib/micronaut/matchers/be_close_example.rb +42 -0
  8. data/examples/lib/micronaut/matchers/be_example.rb +257 -0
  9. data/examples/lib/micronaut/matchers/change_example.rb +329 -0
  10. data/examples/lib/micronaut/matchers/description_generation_example.rb +167 -0
  11. data/examples/lib/micronaut/matchers/eql_example.rb +29 -0
  12. data/examples/lib/micronaut/matchers/equal_example.rb +29 -0
  13. data/examples/lib/micronaut/matchers/exist_example.rb +69 -0
  14. data/examples/lib/micronaut/matchers/handler_example.rb +146 -0
  15. data/examples/lib/micronaut/matchers/has_example.rb +63 -0
  16. data/examples/lib/micronaut/matchers/have_example.rb +575 -0
  17. data/examples/lib/micronaut/matchers/include_example.rb +88 -0
  18. data/examples/lib/micronaut/matchers/match_example.rb +41 -0
  19. data/examples/lib/micronaut/matchers/matcher_methods_example.rb +66 -0
  20. data/examples/lib/micronaut/matchers/operator_matcher_example.rb +191 -0
  21. data/examples/lib/micronaut/matchers/raise_error_example.rb +315 -0
  22. data/examples/lib/micronaut/matchers/respond_to_example.rb +54 -0
  23. data/examples/lib/micronaut/matchers/satisfy_example.rb +36 -0
  24. data/examples/lib/micronaut/matchers/simple_matcher_example.rb +93 -0
  25. data/examples/lib/micronaut/matchers/throw_symbol_example.rb +96 -0
  26. data/examples/resources/example_classes.rb +67 -0
  27. data/lib/autotest/micronaut.rb +9 -4
  28. data/lib/micronaut/behaviour_group.rb +43 -0
  29. data/lib/micronaut/behaviour_group_class_methods.rb +134 -0
  30. data/lib/micronaut/example_runner.rb +7 -9
  31. data/lib/micronaut/example_world.rb +11 -7
  32. data/lib/micronaut/expectations/differs/default.rb +6 -15
  33. data/lib/micronaut/expectations/errors.rb +7 -0
  34. data/lib/micronaut/expectations/{object_extensions.rb → extensions/object.rb} +5 -4
  35. data/lib/micronaut/expectations/{string_and_symbol_extensions.rb → extensions/string_and_symbol.rb} +0 -0
  36. data/lib/micronaut/expectations/extensions.rb +2 -0
  37. data/lib/micronaut/expectations/wrap_expectation.rb +5 -0
  38. data/lib/micronaut/expectations.rb +5 -5
  39. data/lib/micronaut/extensions/kernel.rb +2 -4
  40. data/lib/micronaut/matchers/be_close.rb +6 -22
  41. data/lib/micronaut/matchers/eql.rb +7 -25
  42. data/lib/micronaut/matchers/equal.rb +6 -24
  43. data/lib/micronaut/matchers/exist.rb +8 -14
  44. data/lib/micronaut/matchers/has.rb +12 -28
  45. data/lib/micronaut/matchers/include.rb +12 -9
  46. data/lib/micronaut/matchers/match.rb +8 -27
  47. data/lib/micronaut/matchers/method_missing.rb +1 -1
  48. data/lib/micronaut/matchers/operator_matcher.rb +23 -46
  49. data/lib/micronaut/matchers/raise_error.rb +4 -8
  50. data/lib/micronaut/matchers/respond_to.rb +2 -1
  51. data/lib/micronaut/matchers/throw_symbol.rb +9 -3
  52. data/lib/micronaut/matchers.rb +10 -3
  53. data/lib/micronaut/mocking/with_mocha.rb +0 -1
  54. data/lib/micronaut.rb +3 -3
  55. metadata +31 -7
  56. data/examples/lib/micronaut/example_group_example.rb +0 -116
  57. data/lib/micronaut/example_group.rb +0 -100
  58. data/lib/micronaut/exceptions.rb +0 -7
@@ -1,116 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
2
-
3
- describe Micronaut::ExampleGroup do
4
- class Foo; end
5
-
6
- def scenario_1
7
- example_group = Micronaut::ExampleGroup.new(Foo, "Scenario 1")
8
- example_group.it("should do 1 thing") { 1 }
9
- example_group.it("should do 2 thing") { 2 }
10
- example_group.it("should do 3 thing") { 3 }
11
- example_group
12
- end
13
-
14
- def scenario_2
15
- example_group = Micronaut::ExampleGroup.new(Foo, "Scenario 2")
16
- example_group.before { 'beforeeach1' }
17
- example_group.before { 'beforeeach2' }
18
- example_group.before(:all) { 'beforeall1' }
19
- example_group.before(:all) { 'beforeall2' }
20
- example_group
21
- end
22
-
23
- def scenario_3
24
- example_group = Micronaut::ExampleGroup.new(Foo, "Scenario 3")
25
- example_group.after { 'aftereach1' }
26
- example_group.after { 'aftereach2' }
27
- example_group.after(:all) { 'afterall1' }
28
- example_group.after(:all) { 'afterall2' }
29
- example_group
30
- end
31
-
32
- it "should make the first parameter the name by calling to_s on it" do
33
- scenario_1.name.should == 'Foo'
34
- end
35
-
36
- it "should make the second parameter the description" do
37
- scenario_1.description.should == 'Scenario 1'
38
- end
39
-
40
- it "scenario 1 should have 3 examples" do
41
- scenario_1.should have(3).examples
42
- end
43
-
44
- it "scenario 1 should maintain the example order" do
45
- example_group = scenario_1
46
- example_group.examples[0].first.should == 'should do 1 thing'
47
- example_group.examples[1].first.should == 'should do 2 thing'
48
- example_group.examples[2].first.should == 'should do 3 thing'
49
- end
50
-
51
- it "scenario 1 should allow you to call it's examples" do
52
- example_group = scenario_1
53
- example_group.examples[0].last.call.should == 1
54
- example_group.examples[1].last.call.should == 2
55
- example_group.examples[2].last.call.should == 3
56
- end
57
-
58
- it "scenario 2 should have 2 before each parts" do
59
- scenario_2.should have(2).before_each_parts
60
- end
61
-
62
- it "scenario 2 should have 2 before all parts" do
63
- scenario_2.should have(2).before_all_parts
64
- end
65
-
66
- it "scenario 2 should maintain the before parts order" do
67
- example_group = scenario_2
68
- example_group.before_all_parts[0].call.should == 'beforeall1'
69
- example_group.before_all_parts[1].call.should == 'beforeall2'
70
- example_group.before_each_parts[0].call.should == 'beforeeach1'
71
- example_group.before_each_parts[1].call.should == 'beforeeach2'
72
- end
73
-
74
- it "scenario 3 should have 2 after each parts" do
75
- scenario_3.should have(2).after_each_parts
76
- end
77
-
78
- it "scenario 3 should have 2 after all parts" do
79
- scenario_3.should have(2).after_all_parts
80
- end
81
-
82
- it "scenario 3 should maintain the after parts order" do
83
- example_group = scenario_3
84
- example_group.after_all_parts[0].call.should == 'afterall1'
85
- example_group.after_all_parts[1].call.should == 'afterall2'
86
- example_group.after_each_parts[0].call.should == 'aftereach1'
87
- example_group.after_each_parts[1].call.should == 'aftereach2'
88
- end
89
-
90
- def scenario_4
91
- example_group = Micronaut::ExampleGroup.new(Foo, "Scenario 4")
92
- example_group
93
- end
94
-
95
- it "scenario 4 should run the before all blocks, before each blocks, the example, the after each blocks, and finally the after all blocks" do
96
- example_group = scenario_4
97
- example_group.before(:all) { 'before_all_1' }
98
- example_group.before(:all) { 'before_all_2' }
99
- example_group.before { "before_each_1"; @foo = 2 }
100
- example_group.before { "before_each_2"; @foo += 1 }
101
- example_group.before { "before_each_3"; @foo += 2 }
102
- example_group.after { "after_each_1"; @foo = 3 }
103
- example_group.after { "after_each_2"; 'final after each' }
104
- example_group.after(:all) { 'after_all_1' }
105
- example_group.after(:all) { 'after_all_2' }
106
-
107
- example_group.it("prints out the value of the @foo variable") do
108
- @foo.should == 5
109
- end
110
- example_group.it("other example") do
111
-
112
- end
113
- example_group.run
114
- end
115
-
116
- end
@@ -1,100 +0,0 @@
1
- class Micronaut::ExampleGroup
2
- include Micronaut::Matchers
3
- include Micronaut::Mocking::WithMocha
4
-
5
- attr_reader :name, :description, :examples, :before_parts, :after_parts
6
-
7
- def initialize(const_or_name, description=nil)
8
- @name, @description = const_or_name.to_s, description
9
- @examples, @before_parts, @after_parts = [], {:each => [], :all => []}, {:each => [], :all => []}
10
- end
11
-
12
- def before(type = :each, &block)
13
- @before_parts[type] << block
14
- end
15
-
16
- def before_each_parts
17
- @before_parts[:each]
18
- end
19
-
20
- def before_all_parts
21
- @before_parts[:all]
22
- end
23
-
24
- def after(type = :each, &block)
25
- @after_parts[type] << block
26
- end
27
-
28
- def after_each_parts
29
- @after_parts[:each]
30
- end
31
-
32
- def after_all_parts
33
- @after_parts[:all]
34
- end
35
-
36
- def it(example_description, &example_block)
37
- @examples << [example_description, example_block]
38
- end
39
-
40
- def run
41
- before_all_parts.each { |part| part.call }
42
-
43
- @examples.each do |example_description, example_block|
44
-
45
- before_each_parts.each { |part| part.call }
46
-
47
- example_block.call
48
-
49
- after_each_parts.each { |part| part.call }
50
-
51
- end
52
-
53
- after_all_parts.each { |part| part.call }
54
- end
55
-
56
- def run_group_using(runner)
57
- result = ''
58
-
59
- begin
60
- @passed = nil
61
-
62
- before_all_parts.each { |part| part.call }
63
-
64
- @examples.each do |example_description, example_block|
65
-
66
- setup_mocks
67
-
68
- before_each_parts.each { |part| part.call }
69
-
70
- if example_block.nil?
71
- result << 'P'
72
- else
73
- example_block.call
74
- end
75
-
76
- result << '.'
77
-
78
- after_each_parts.each { |part| part.call }
79
-
80
- verify_mocks
81
-
82
- teardown_mocks
83
- end
84
-
85
- @passed = true
86
- rescue Exception => e
87
- result << runner.complain(self.class, self.name, e)
88
- @passed = false
89
- ensure
90
- begin
91
- after_all_parts.each { |part| part.call }
92
- rescue Exception => e
93
- result << runner.complain(self.class, self.name, e)
94
- end
95
- end
96
-
97
- result
98
- end
99
-
100
- end
@@ -1,7 +0,0 @@
1
- module Micronaut
2
- class Exceptions
3
-
4
- class ExpectationNotMetError < ::StandardError; end
5
-
6
- end
7
- end