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
@@ -0,0 +1,93 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
+
3
+ module Micronaut
4
+ module Matchers
5
+ describe SimpleMatcher do
6
+ it "should pass match arg to block" do
7
+ actual = nil
8
+ matcher = simple_matcher("message") do |given| actual = given end
9
+ matcher.matches?("foo")
10
+ actual.should == "foo"
11
+ end
12
+
13
+ it "should provide a stock failure message" do
14
+ matcher = simple_matcher("thing") do end
15
+ matcher.matches?("other")
16
+ matcher.failure_message.should =~ /expected \"thing\" but got \"other\"/
17
+ end
18
+
19
+ it "should provide a stock negative failure message" do
20
+ matcher = simple_matcher("thing") do end
21
+ matcher.matches?("other")
22
+ matcher.negative_failure_message.should =~ /expected not to get \"thing\", but got \"other\"/
23
+ end
24
+
25
+ it "should provide the given description" do
26
+ matcher = simple_matcher("thing") do end
27
+ matcher.description.should =="thing"
28
+ end
29
+
30
+ it "should fail if a wrapped 'should' fails" do
31
+ matcher = simple_matcher("should fail") do
32
+ 2.should == 3
33
+ end
34
+ lambda do
35
+ matcher.matches?("anything").should be_true
36
+ end.should fail_with(/expected: 3/)
37
+ end
38
+ end
39
+
40
+ describe "with arity of 2" do
41
+ it "should provide the matcher so you can access its messages" do
42
+ provided_matcher = nil
43
+ matcher = simple_matcher("thing") do |given, matcher|
44
+ provided_matcher = matcher
45
+ end
46
+ matcher.matches?("anything")
47
+ provided_matcher.should equal(matcher)
48
+ end
49
+
50
+ it "should support a custom failure message" do
51
+ matcher = simple_matcher("thing") do |given, matcher|
52
+ matcher.failure_message = "custom message"
53
+ end
54
+ matcher.matches?("other")
55
+ matcher.failure_message.should == "custom message"
56
+ end
57
+
58
+ it "should complain when asked for a failure message if you don't give it a description or a message" do
59
+ matcher = simple_matcher do |given, matcher| end
60
+ matcher.matches?("other")
61
+ matcher.failure_message.should =~ /No description provided/
62
+ end
63
+
64
+ it "should support a custom negative failure message" do
65
+ matcher = simple_matcher("thing") do |given, matcher|
66
+ matcher.negative_failure_message = "custom message"
67
+ end
68
+ matcher.matches?("other")
69
+ matcher.negative_failure_message.should == "custom message"
70
+ end
71
+
72
+ it "should complain when asked for a negative failure message if you don't give it a description or a message" do
73
+ matcher = simple_matcher do |given, matcher| end
74
+ matcher.matches?("other")
75
+ matcher.negative_failure_message.should =~ /No description provided/
76
+ end
77
+
78
+ it "should support a custom description" do
79
+ matcher = simple_matcher("thing") do |given, matcher|
80
+ matcher.description = "custom message"
81
+ end
82
+ matcher.matches?("description")
83
+ matcher.description.should == "custom message"
84
+ end
85
+
86
+ it "should tell you no description was provided when it doesn't receive one" do
87
+ matcher = simple_matcher do end
88
+ matcher.description.should =~ /No description provided/
89
+ end
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,96 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
+
3
+ module Micronaut
4
+ module Matchers
5
+ describe ThrowSymbol do
6
+ describe "with no args" do
7
+ before { @matcher = ThrowSymbol.new }
8
+
9
+ it "should match if any Symbol is thrown" do
10
+ @matcher.matches?(lambda{ throw :sym }).should be_true
11
+ end
12
+ it "should match if any Symbol is thrown with an arg" do
13
+ @matcher.matches?(lambda{ throw :sym, "argument" }).should be_true
14
+ end
15
+ it "should not match if no Symbol is thrown" do
16
+ @matcher.matches?(lambda{ }).should be_false
17
+ end
18
+ it "should provide a failure message" do
19
+ @matcher.matches?(lambda{})
20
+ @matcher.failure_message.should == "expected a Symbol but nothing was thrown"
21
+ end
22
+ it "should provide a negative failure message" do
23
+ @matcher.matches?(lambda{ throw :sym})
24
+ @matcher.negative_failure_message.should == "expected no Symbol, got :sym"
25
+ end
26
+ end
27
+
28
+ describe "with a symbol" do
29
+ before { @matcher = ThrowSymbol.new(:sym) }
30
+
31
+ it "should match if correct Symbol is thrown" do
32
+ @matcher.matches?(lambda{ throw :sym }).should be_true
33
+ end
34
+ it "should match if correct Symbol is thrown with an arg" do
35
+ @matcher.matches?(lambda{ throw :sym, "argument" }).should be_true
36
+ end
37
+ it "should not match if no Symbol is thrown" do
38
+ @matcher.matches?(lambda{ }).should be_false
39
+ end
40
+ it "should not match if correct Symbol is thrown" do
41
+ @matcher.matches?(lambda{ throw :other_sym }).should be_false
42
+ end
43
+ it "should provide a failure message when no Symbol is thrown" do
44
+ @matcher.matches?(lambda{})
45
+ @matcher.failure_message.should == "expected :sym but nothing was thrown"
46
+ end
47
+ it "should provide a failure message when wrong Symbol is thrown" do
48
+ @matcher.matches?(lambda{ throw :other_sym })
49
+ @matcher.failure_message.should == "expected :sym, got :other_sym"
50
+ end
51
+ it "should provide a negative failure message" do
52
+ @matcher.matches?(lambda{ throw :sym })
53
+ @matcher.negative_failure_message.should == "expected :sym not to be thrown"
54
+ end
55
+ it "should only match NameErrors raised by uncaught throws" do
56
+ @matcher.matches?(lambda{ sym }).should be_false
57
+ end
58
+ end
59
+
60
+ describe "with a symbol and an arg" do
61
+ before { @matcher = ThrowSymbol.new(:sym, "a") }
62
+
63
+ it "should match if correct Symbol and args are thrown" do
64
+ @matcher.matches?(lambda{ throw :sym, "a" }).should be_true
65
+ end
66
+ it "should not match if nothing is thrown" do
67
+ @matcher.matches?(lambda{ }).should be_false
68
+ end
69
+ it "should not match if other Symbol is thrown" do
70
+ @matcher.matches?(lambda{ throw :other_sym, "a" }).should be_false
71
+ end
72
+ it "should not match if no arg is thrown" do
73
+ @matcher.matches?(lambda{ throw :sym }).should be_false
74
+ end
75
+ it "should not match if wrong arg is thrown" do
76
+ @matcher.matches?(lambda{ throw :sym, "b" }).should be_false
77
+ end
78
+ it "should provide a failure message when no Symbol is thrown" do
79
+ @matcher.matches?(lambda{})
80
+ @matcher.failure_message.should == %q[expected :sym with "a" but nothing was thrown]
81
+ end
82
+ it "should provide a failure message when wrong Symbol is thrown" do
83
+ @matcher.matches?(lambda{ throw :other_sym })
84
+ @matcher.failure_message.should == %q[expected :sym with "a", got :other_sym]
85
+ end
86
+ it "should provide a negative failure message" do
87
+ @matcher.matches?(lambda{ throw :sym })
88
+ @matcher.negative_failure_message.should == %q[expected :sym with "a" not to be thrown]
89
+ end
90
+ it "should only match NameErrors raised by uncaught throws" do
91
+ @matcher.matches?(lambda{ sym }).should be_false
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,67 @@
1
+ # This file contains various classes used by the specs.
2
+ module Micronaut
3
+ module Expectations
4
+ class Person
5
+ attr_reader :name
6
+ def initialize name
7
+ @name = name
8
+ end
9
+ def == other
10
+ return @name == other.name
11
+ end
12
+ end
13
+
14
+ class ClassWithMultiWordPredicate
15
+ def multi_word_predicate?
16
+ true
17
+ end
18
+ end
19
+
20
+ module Helper
21
+ class CollectionWithSizeMethod
22
+ def initialize; @list = []; end
23
+ def size; @list.size; end
24
+ def push(item); @list.push(item); end
25
+ end
26
+
27
+ class CollectionWithLengthMethod
28
+ def initialize; @list = []; end
29
+ def length; @list.size; end
30
+ def push(item); @list.push(item); end
31
+ end
32
+
33
+ class CollectionOwner
34
+ attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method
35
+
36
+ def initialize
37
+ @items_in_collection_with_size_method = CollectionWithSizeMethod.new
38
+ @items_in_collection_with_length_method = CollectionWithLengthMethod.new
39
+ end
40
+
41
+ def add_to_collection_with_size_method(item)
42
+ @items_in_collection_with_size_method.push(item)
43
+ end
44
+
45
+ def add_to_collection_with_length_method(item)
46
+ @items_in_collection_with_length_method.push(item)
47
+ end
48
+
49
+ def items_for(arg)
50
+ return [1, 2, 3] if arg == 'a'
51
+ [1]
52
+ end
53
+
54
+ def items
55
+ @items_in_collection_with_size_method
56
+ end
57
+ end
58
+
59
+ class ClassWithUnqueriedPredicate
60
+ attr_accessor :foo
61
+ def initialize(foo)
62
+ @foo = foo
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -7,10 +7,10 @@ Autotest.add_hook :initialize do |at|
7
7
  at.add_mapping(%r%^examples/.*_example.rb$%) { |filename, _|
8
8
  filename
9
9
  }
10
- at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
11
- ["examples/#{m[1]}_example.rb"]
10
+ at.add_mapping(%r%^lib/(.*)\.rb$%) { |filename, m|
11
+ ["examples/lib/#{m[1]}_example.rb"]
12
12
  }
13
- at.add_mapping(%r%^examples/(examples_helper|shared/.*)\.rb$%) {
13
+ at.add_mapping(%r%^examples/(example_helper|shared/.*)\.rb$%) {
14
14
  at.files_matching %r%^examples/.*_example\.rb$%
15
15
  }
16
16
  end
@@ -37,7 +37,12 @@ class Autotest::Micronaut < Autotest
37
37
 
38
38
  def make_test_cmd(files_to_test)
39
39
  return '' if files_to_test.empty?
40
- return "#{ruby} -S #{files_to_test.keys.flatten.join(' ')}"
40
+
41
+ examples = files_to_test.keys.flatten
42
+
43
+ examples.map! {|f| %Q(require "#{f}")}
44
+
45
+ return "#{ruby} -e '#{examples.join("; ")}'"
41
46
  end
42
47
 
43
48
  end
@@ -0,0 +1,43 @@
1
+ module Micronaut
2
+ class BehaviourGroup
3
+ extend Micronaut::BehaviourGroupClassMethods
4
+ include Micronaut::Matchers
5
+ include Micronaut::Mocking::WithMocha
6
+
7
+ def execute(runner)
8
+ result = ''
9
+ return result if self.class.examples.empty?
10
+ self.class.all_before_alls.each { |aba| instance_eval(&aba) }
11
+
12
+ self.class.examples.each do |desc, opts, block|
13
+ execution_error = nil
14
+
15
+ begin
16
+ setup_mocks
17
+ self.class.befores[:each].each { |be| instance_eval(&be) }
18
+ if block
19
+ result << '.'
20
+ instance_eval(&block)
21
+ else
22
+ result << 'P'
23
+ end
24
+ verify_mocks
25
+ rescue Exception => e
26
+ runner.complain(self, e)
27
+ execution_error ||= e
28
+ ensure
29
+ teardown_mocks
30
+ end
31
+
32
+ begin
33
+ self.class.afters[:each].each { |ae| instance_eval(&ae) }
34
+ rescue Exception => e
35
+ runner.complain(self, e)
36
+ execution_error ||= e
37
+ end
38
+ end
39
+ result
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,134 @@
1
+ module Micronaut
2
+ module BehaviourGroupClassMethods
3
+
4
+ def inherited(klass)
5
+ super
6
+ Micronaut::ExampleWorld.example_groups << klass
7
+ end
8
+
9
+ def befores
10
+ @_befores ||= { :all => [], :each => [] }
11
+ end
12
+
13
+ def before_eachs
14
+ befores[:each]
15
+ end
16
+
17
+ def before_alls
18
+ befores[:all]
19
+ end
20
+
21
+ def before(type=:each, &block)
22
+ befores[type] << block
23
+ end
24
+
25
+ def afters
26
+ @_afters ||= { :all => [], :each => [] }
27
+ end
28
+
29
+ def after_eachs
30
+ afters[:each]
31
+ end
32
+
33
+ def after_alls
34
+ afters[:all]
35
+ end
36
+
37
+ def after(type=:each, &block)
38
+ afters[type] << block
39
+ end
40
+
41
+ def it(desc=nil, options={}, &block)
42
+ examples << [desc, options, block]
43
+ end
44
+
45
+ def examples
46
+ @_examples ||= []
47
+ end
48
+
49
+ def set_it_up(name_or_const, given_description, given_options)
50
+ @_behaviour_group_name = name_or_const.to_s
51
+ @_behaviour_described_type = name_or_const.is_a?(String) ? Object : name_or_const
52
+ @_behaviour_group_description = given_description
53
+ @_behaviour_group_options = given_options
54
+ end
55
+
56
+ def name
57
+ @_behaviour_group_name
58
+ end
59
+
60
+ def described_type
61
+ @_behaviour_described_type
62
+ end
63
+
64
+ def description
65
+ @_behaviour_group_description
66
+ end
67
+
68
+ def options
69
+ @_behaviour_group_options
70
+ end
71
+
72
+ def describe(name_or_const, desc=nil, options={}, &block)
73
+ raise ArgumentError if block.nil? || name_or_const.nil?
74
+
75
+ subclass('NestedLevel') do
76
+ set_it_up(name_or_const, desc, options)
77
+
78
+ module_eval(&block)
79
+ end
80
+ end
81
+
82
+ def create_example_group(name_or_const, desc=nil, options={}, &describe_block)
83
+ describe(name_or_const, desc, options, &describe_block)
84
+ end
85
+
86
+ def each_ancestor(superclass_last=false)
87
+ classes = []
88
+ current_class = self
89
+ while is_example_group_class?(current_class)
90
+ superclass_last ? classes << current_class : classes.unshift(current_class)
91
+ current_class = current_class.superclass
92
+ end
93
+
94
+ classes.each do |example_group|
95
+ yield example_group
96
+ end
97
+ end
98
+
99
+ def is_example_group_class?(klass)
100
+ klass.kind_of?(Micronaut::BehaviourGroup)
101
+ end
102
+
103
+ def all_before_alls
104
+ _before_alls = []
105
+ each_ancestor do |ancestor|
106
+ _before_alls << ancestor.befores[:all]
107
+ end
108
+ _before_alls
109
+ end
110
+
111
+ def run(runner)
112
+ new.execute(runner)
113
+ end
114
+
115
+ def subclass(base_name, &body)
116
+ klass = Class.new(self)
117
+ class_name = "#{base_name}_#{_sub_class_count!}"
118
+ instance_eval do
119
+ const_set(class_name, klass)
120
+ end
121
+ klass.instance_eval(&body) if block_given?
122
+ klass
123
+ end
124
+
125
+ private
126
+
127
+ def _sub_class_count!
128
+ @_sub_class_count ||= 0
129
+ @_sub_class_count += 1
130
+ @_sub_class_count
131
+ end
132
+
133
+ end
134
+ end
@@ -26,22 +26,20 @@ module Micronaut
26
26
  end
27
27
 
28
28
  def location(e)
29
- e.backtrace.find { |s|
30
- s !~ /in .(assert|refute|flunk|pass|fail|raise)/
31
- }.sub(/:in .*$/, '')
29
+ e.backtrace.find { |s| s !~ /in .(expectations|fail)/ }.sub(/:in .*$/, '')
32
30
  end
33
31
 
34
- def complain(cls, method_in_question, e)
32
+ def complain(group, e)
35
33
  bt = Micronaut::filter_backtrace(e.backtrace).join("\n ")
36
34
 
37
35
  e = case e.class.to_s
38
- when 'Micronaut::Exceptions::ExpectationNotMetError', 'Mocha::ExpectationError' then
36
+ when /Micronaut::Expectations/, 'Mocha::ExpectationError' then
39
37
  @failures += 1
40
- "Failure:\n#{method_in_question}(#{cls}) [#{location(e)}]:\n#{e.message}\n #{bt}\n"
38
+ "Failure:\n#{group.class.name}(#{group.class}) [#{location(e)}]:\n#{e.message}\n #{bt}\n"
41
39
  else
42
40
  puts e.to_s
43
41
  @errors += 1
44
- "Error:\n#{method_in_question}(#{cls}):\n#{e.class}: #{e.message}\n #{bt}\n"
42
+ "Error:\n#{group.class.name}(#{group.class}):\n#{e.class}: #{e.message}\n #{bt}\n"
45
43
  end
46
44
  @report << e
47
45
  e[0, 1]
@@ -90,12 +88,12 @@ module Micronaut
90
88
  @@out.print "#{example_group.name}: " if @verbose
91
89
 
92
90
  t = Time.now if @verbose
93
- result = example_group.run_group_using(self)
91
+ result = example_group.run(self)
94
92
 
95
93
  @example_count += example_group.examples.size
96
94
 
97
95
  @@out.print "%.6fs: " % (Time.now - t) if @verbose
98
- @@out.print result
96
+ @@out.print(result) if result
99
97
  @@out.puts if @verbose
100
98
  # end
101
99
  end
@@ -1,13 +1,17 @@
1
- class Micronaut::ExampleWorld
1
+ module Micronaut
2
+
3
+ class ExampleWorld
2
4
 
3
- def self.reset
4
- @@example_groups = []
5
- end
5
+ def self.reset
6
+ @@example_groups = []
7
+ end
6
8
 
7
- reset
9
+ reset
10
+
11
+ def self.example_groups
12
+ @@example_groups
13
+ end
8
14
 
9
- def self.example_groups
10
- @@example_groups
11
15
  end
12
16
 
13
17
  end
@@ -12,9 +12,8 @@ module Micronaut
12
12
 
13
13
  # TODO add some rdoc
14
14
  class Default
15
- def initialize(diff_type = :unified, context_lines = 3)
16
- @format = diff_type
17
- @context_lines = context_lines
15
+ def initialize(format = :unified, context_lines = 3)
16
+ @format, @context_lines = format, context_lines
18
17
  end
19
18
 
20
19
  # This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
@@ -28,17 +27,17 @@ module Micronaut
28
27
  file_length_difference = 0
29
28
  diffs.each do |piece|
30
29
  begin
31
- hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, context_lines,
30
+ hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, @context_lines,
32
31
  file_length_difference)
33
32
  file_length_difference = hunk.file_length_difference
34
33
  next unless oldhunk
35
34
  # Hunks may overlap, which is why we need to be careful when our
36
35
  # diff includes lines of context. Otherwise, we might print
37
36
  # redundant lines.
38
- if (context_lines > 0) and hunk.overlaps?(oldhunk)
37
+ if (@context_lines > 0) and hunk.overlaps?(oldhunk)
39
38
  hunk.unshift(oldhunk)
40
39
  else
41
- output << oldhunk.diff(format)
40
+ output << oldhunk.diff(@format)
42
41
  end
43
42
  ensure
44
43
  oldhunk = hunk
@@ -46,21 +45,13 @@ module Micronaut
46
45
  end
47
46
  end
48
47
  #Handle the last remaining hunk
49
- output << oldhunk.diff(format) << "\n"
48
+ output << oldhunk.diff(@format) << "\n"
50
49
  end
51
50
 
52
51
  def diff_as_object(target,expected)
53
52
  diff_as_string(PP.pp(target,""), PP.pp(expected,""))
54
53
  end
55
54
 
56
- protected
57
- def format
58
- @format
59
- end
60
-
61
- def context_lines
62
- @context_lines
63
- end
64
55
  end
65
56
  end
66
57
  end
@@ -0,0 +1,7 @@
1
+ module Micronaut
2
+ module Expectations
3
+ class ExpectationNotMetError < ::StandardError
4
+
5
+ end
6
+ end
7
+ end
@@ -1,7 +1,8 @@
1
1
  module Micronaut
2
2
  module Expectations
3
- # We add #should and #should_not to every Object (and, implicitly, every Class).
4
- module ObjectExtensions
3
+ # rspec adds #should and #should_not to every Object (and,
4
+ # implicitly, every Class).
5
+ module ObjectExpectations
5
6
  # :call-seq:
6
7
  # should(matcher)
7
8
  # should == expected
@@ -58,5 +59,5 @@ module Micronaut
58
59
  end
59
60
 
60
61
  class Object
61
- include Micronaut::Expectations::ObjectExtensions
62
- end
62
+ include Micronaut::Expectations::ObjectExpectations
63
+ end
@@ -0,0 +1,2 @@
1
+ require 'micronaut/expectations/extensions/object'
2
+ require 'micronaut/expectations/extensions/string_and_symbol'
@@ -5,6 +5,11 @@ module Micronaut
5
5
  # expectation passes and false if it fails (without bubbling up
6
6
  # the failure).
7
7
  #
8
+ # This is intended to be used in the context of a simple matcher,
9
+ # and is especially useful for wrapping multiple expectations or
10
+ # one or more assertions from test/unit extensions when running
11
+ # with test/unit.
12
+ #
8
13
  # == Examples
9
14
  #
10
15
  # def eat_cheese(cheese)
@@ -1,6 +1,6 @@
1
1
  require 'micronaut/matchers'
2
- require 'micronaut/expectations/object_extensions'
3
- require 'micronaut/expectations/string_and_symbol_extensions'
2
+ require 'micronaut/expectations/errors'
3
+ require 'micronaut/expectations/extensions'
4
4
  require 'micronaut/expectations/handler'
5
5
  require 'micronaut/expectations/wrap_expectation'
6
6
 
@@ -28,13 +28,13 @@ module Micronaut
28
28
  # it returns +false+, the spec passes and execution continues. If it returns
29
29
  # +true+, then the spec fails with the message returned by <tt>matcher.negative_failure_message</tt>.
30
30
  #
31
- # Micronaut ships with a standard set of useful matchers, and writing your own
31
+ # RMicronaut ships with a standard set of useful matchers, and writing your own
32
32
  # matchers is quite simple. See Micronaut::Matchers for details.
33
33
  module Expectations
34
34
  class << self
35
35
  attr_accessor :differ
36
36
 
37
- # raises a Micronaut::Exceptions::ExpectationNotMetError with message
37
+ # raises a Micronaut::Expectations::ExpectationNotMetError with message
38
38
  #
39
39
  # When a differ has been assigned and fail_with is passed
40
40
  # <code>expected</code> and <code>target</code>, passes them
@@ -50,7 +50,7 @@ module Micronaut
50
50
  message << "\nDiff:" << self.differ.diff_as_object(target, expected)
51
51
  end
52
52
  end
53
- Kernel::raise(Micronaut::Exceptions::ExpectationNotMetError.new(message))
53
+ Kernel::raise(Micronaut::Expectations::ExpectationNotMetError.new(message))
54
54
  end
55
55
  end
56
56
  end
@@ -2,10 +2,8 @@ module Micronaut
2
2
  module Extensions
3
3
  module Kernel
4
4
 
5
- def describe(name_or_const, desc=nil, &describe_block)
6
- example_group = Micronaut::ExampleGroup.new(name_or_const, desc)
7
- example_group.instance_eval(&describe_block)
8
- Micronaut::ExampleWorld.example_groups << example_group
5
+ def describe(name_or_const, desc=nil, options={}, &describe_block)
6
+ Micronaut::BehaviourGroup.create_example_group(name_or_const, desc, options, &describe_block)
9
7
  end
10
8
 
11
9
  end