spicycode-micronaut 0.0.4 → 0.0.5
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/RSPEC-LICENSE +23 -0
 - data/Rakefile +2 -2
 - data/examples/example_helper.rb +10 -0
 - data/examples/lib/micronaut/behaviour_group_example.rb +170 -159
 - data/examples/lib/micronaut/expectations/fail_with_example.rb +10 -64
 - data/examples/lib/micronaut/formatters/progress_formatter_example.rb +3 -7
 - data/examples/lib/micronaut/matchers/description_generation_example.rb +1 -1
 - data/examples/lib/micronaut/matchers/have_example.rb +2 -2
 - data/examples/lib/micronaut/matchers/operator_matcher_example.rb +0 -2
 - data/examples/lib/micronaut/matchers/raise_error_example.rb +32 -1
 - data/examples/lib/micronaut/{example_runner_example.rb → runner_example.rb} +0 -0
 - data/examples/lib/micronaut/runner_options_example.rb +5 -0
 - data/examples/lib/micronaut/world_example.rb +94 -0
 - data/lib/micronaut.rb +1 -15
 - data/lib/micronaut/behaviour_group.rb +34 -16
 - data/lib/micronaut/behaviour_group_class_methods.rb +32 -47
 - data/lib/micronaut/expectations.rb +0 -12
 - data/lib/micronaut/extensions/kernel.rb +2 -2
 - data/lib/micronaut/formatters/base_formatter.rb +4 -3
 - data/lib/micronaut/formatters/base_text_formatter.rb +29 -17
 - data/lib/micronaut/formatters/progress_formatter.rb +1 -1
 - data/lib/micronaut/runner.rb +2 -2
 - data/lib/micronaut/world.rb +36 -0
 - metadata +7 -10
 - data/examples/lib/micronaut/expectations/differs/default_example.rb +0 -125
 - data/examples/lib/micronaut/matchers/exist_example.rb +0 -69
 - data/lib/micronaut/example_world.rb +0 -17
 - data/lib/micronaut/expectations/differs/default.rb +0 -58
 - data/lib/micronaut/matchers/exist.rb +0 -16
 
| 
         @@ -3,7 +3,7 @@ module Micronaut 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
                def inherited(klass)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  super
         
     | 
| 
       6 
     | 
    
         
            -
                  Micronaut:: 
     | 
| 
      
 6 
     | 
    
         
            +
                  Micronaut::World.behaviour_groups << klass
         
     | 
| 
       7 
7 
     | 
    
         
             
                end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                def befores
         
     | 
| 
         @@ -46,88 +46,73 @@ module Micronaut 
     | 
|
| 
       46 
46 
     | 
    
         
             
                  @_examples ||= []
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                def set_it_up( 
     | 
| 
       50 
     | 
    
         
            -
                   
     | 
| 
       51 
     | 
    
         
            -
                   
     | 
| 
       52 
     | 
    
         
            -
                   
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
      
 49 
     | 
    
         
            +
                def set_it_up(*args)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  metadata[:options] = args.last.is_a?(Hash) ? args.pop : {}
         
     | 
| 
      
 51 
     | 
    
         
            +
                  metadata[:described_type] = args.first.is_a?(String) ? self.superclass.described_type : args.shift
         
     | 
| 
      
 52 
     | 
    
         
            +
                  metadata[:description] = args.shift || ''
         
     | 
| 
      
 53 
     | 
    
         
            +
                  metadata[:name] = "#{metadata[:described_type]} #{metadata[:description]}".strip
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
                
         
     | 
| 
      
 56 
     | 
    
         
            +
                def metadata
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @_metadata ||= {}
         
     | 
| 
       54 
58 
     | 
    
         
             
                end
         
     | 
| 
       55 
59 
     | 
    
         | 
| 
       56 
60 
     | 
    
         
             
                def name
         
     | 
| 
       57 
     | 
    
         
            -
                   
     | 
| 
      
 61 
     | 
    
         
            +
                  metadata[:name]
         
     | 
| 
       58 
62 
     | 
    
         
             
                end
         
     | 
| 
       59 
63 
     | 
    
         | 
| 
       60 
64 
     | 
    
         
             
                def described_type
         
     | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
      
 65 
     | 
    
         
            +
                  metadata[:described_type]
         
     | 
| 
       62 
66 
     | 
    
         
             
                end
         
     | 
| 
       63 
67 
     | 
    
         | 
| 
       64 
68 
     | 
    
         
             
                def description
         
     | 
| 
       65 
     | 
    
         
            -
                   
     | 
| 
      
 69 
     | 
    
         
            +
                  metadata[:description]
         
     | 
| 
       66 
70 
     | 
    
         
             
                end
         
     | 
| 
       67 
71 
     | 
    
         | 
| 
       68 
72 
     | 
    
         
             
                def options
         
     | 
| 
       69 
     | 
    
         
            -
                   
     | 
| 
      
 73 
     | 
    
         
            +
                  metadata[:options]
         
     | 
| 
       70 
74 
     | 
    
         
             
                end
         
     | 
| 
       71 
75 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                def describe( 
     | 
| 
       73 
     | 
    
         
            -
                  raise ArgumentError if  
     | 
| 
      
 76 
     | 
    
         
            +
                def describe(*args, &describe_block)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  raise ArgumentError if args.empty? || describe_block.nil?
         
     | 
| 
      
 78 
     | 
    
         
            +
                  
         
     | 
| 
      
 79 
     | 
    
         
            +
                  args << {} unless Hash === args.last
         
     | 
| 
      
 80 
     | 
    
         
            +
                 # args.last[:spec_path] ||= File.expand_path(caller(0)[2])
         
     | 
| 
       74 
81 
     | 
    
         | 
| 
       75 
82 
     | 
    
         
             
                  subclass('NestedLevel') do
         
     | 
| 
       76 
     | 
    
         
            -
                    set_it_up( 
     | 
| 
       77 
     | 
    
         
            -
                    
         
     | 
| 
       78 
     | 
    
         
            -
                    module_eval(&block)
         
     | 
| 
      
 83 
     | 
    
         
            +
                    set_it_up(*args)
         
     | 
| 
      
 84 
     | 
    
         
            +
                    module_eval(&describe_block)
         
     | 
| 
       79 
85 
     | 
    
         
             
                  end
         
     | 
| 
       80 
86 
     | 
    
         
             
                end
         
     | 
| 
       81 
87 
     | 
    
         | 
| 
       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 
88 
     | 
    
         
             
                def each_ancestor(superclass_last=false)
         
     | 
| 
       87 
89 
     | 
    
         
             
                  classes = []
         
     | 
| 
       88 
90 
     | 
    
         
             
                  current_class = self
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                  while current_class < Micronaut::BehaviourGroup
         
     | 
| 
       90 
93 
     | 
    
         
             
                    superclass_last ? classes << current_class : classes.unshift(current_class)
         
     | 
| 
       91 
94 
     | 
    
         
             
                    current_class = current_class.superclass
         
     | 
| 
       92 
95 
     | 
    
         
             
                  end
         
     | 
| 
       93 
96 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                  classes.each  
     | 
| 
       95 
     | 
    
         
            -
                    yield example_group
         
     | 
| 
       96 
     | 
    
         
            -
                  end
         
     | 
| 
      
 97 
     | 
    
         
            +
                  classes.each { |example_group| yield example_group }
         
     | 
| 
       97 
98 
     | 
    
         
             
                end
         
     | 
| 
       98 
     | 
    
         
            -
                
         
     | 
| 
       99 
     | 
    
         
            -
                def is_example_group_class?(klass)
         
     | 
| 
       100 
     | 
    
         
            -
                  klass.kind_of?(Micronaut::BehaviourGroup)
         
     | 
| 
       101 
     | 
    
         
            -
                end    
         
     | 
| 
       102 
99 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
                def all_before_alls
         
     | 
| 
       104 
     | 
    
         
            -
                  all_before_alls = []
         
     | 
| 
       105 
     | 
    
         
            -
                  each_ancestor do |ancestor|
         
     | 
| 
       106 
     | 
    
         
            -
                    all_before_alls << ancestor.before_alls
         
     | 
| 
       107 
     | 
    
         
            -
                  end
         
     | 
| 
       108 
     | 
    
         
            -
                  all_before_alls.concat(before_alls)
         
     | 
| 
       109 
     | 
    
         
            -
                end
         
     | 
| 
       110 
     | 
    
         
            -
                
         
     | 
| 
       111 
100 
     | 
    
         
             
                def run(runner)
         
     | 
| 
       112 
101 
     | 
    
         
             
                  new.execute(runner)
         
     | 
| 
       113 
102 
     | 
    
         
             
                end
         
     | 
| 
       114 
103 
     | 
    
         | 
| 
       115 
     | 
    
         
            -
                def subclass(base_name, &body)
         
     | 
| 
      
 104 
     | 
    
         
            +
                def subclass(base_name, &body) # :nodoc:
         
     | 
| 
      
 105 
     | 
    
         
            +
                  @_sub_class_count ||= 0
         
     | 
| 
      
 106 
     | 
    
         
            +
                  @_sub_class_count += 1
         
     | 
| 
       116 
107 
     | 
    
         
             
                  klass = Class.new(self)
         
     | 
| 
       117 
     | 
    
         
            -
                  class_name = "#{base_name}_#{_sub_class_count 
     | 
| 
       118 
     | 
    
         
            -
                   
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                  end
         
     | 
| 
       121 
     | 
    
         
            -
                  klass.instance_eval(&body) if block_given?
         
     | 
| 
      
 108 
     | 
    
         
            +
                  class_name = "#{base_name}_#{@_sub_class_count}"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  const_set(class_name, klass)
         
     | 
| 
      
 110 
     | 
    
         
            +
                  klass.instance_eval(&body)
         
     | 
| 
       122 
111 
     | 
    
         
             
                  klass
         
     | 
| 
       123 
112 
     | 
    
         
             
                end
         
     | 
| 
       124 
113 
     | 
    
         | 
| 
       125 
     | 
    
         
            -
                 
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                def _sub_class_count!
         
     | 
| 
       128 
     | 
    
         
            -
                  @_sub_class_count ||= 0
         
     | 
| 
       129 
     | 
    
         
            -
                  @_sub_class_count += 1
         
     | 
| 
       130 
     | 
    
         
            -
                  @_sub_class_count
         
     | 
| 
      
 114 
     | 
    
         
            +
                def to_s
         
     | 
| 
      
 115 
     | 
    
         
            +
                  name
         
     | 
| 
       131 
116 
     | 
    
         
             
                end
         
     | 
| 
       132 
117 
     | 
    
         | 
| 
       133 
118 
     | 
    
         
             
              end
         
     | 
| 
         @@ -34,22 +34,10 @@ module Micronaut 
     | 
|
| 
       34 
34 
     | 
    
         
             
                class << self
         
     | 
| 
       35 
35 
     | 
    
         
             
                  attr_accessor :differ
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                  # raises a Micronaut::Expectations::ExpectationNotMetError with message
         
     | 
| 
       38 
     | 
    
         
            -
                  #
         
     | 
| 
       39 
     | 
    
         
            -
                  # When a differ has been assigned and fail_with is passed
         
     | 
| 
       40 
     | 
    
         
            -
                  # <code>expected</code> and <code>target</code>, passes them
         
     | 
| 
       41 
     | 
    
         
            -
                  # to the differ to append a diff message to the failure message.
         
     | 
| 
       42 
37 
     | 
    
         
             
                  def fail_with(message, expected=nil, target=nil) # :nodoc:
         
     | 
| 
       43 
38 
     | 
    
         
             
                    if Array === message && message.length == 3
         
     | 
| 
       44 
39 
     | 
    
         
             
                      message, expected, target = message[0], message[1], message[2]
         
     | 
| 
       45 
40 
     | 
    
         
             
                    end
         
     | 
| 
       46 
     | 
    
         
            -
                    unless (differ.nil? || expected.nil? || target.nil?)
         
     | 
| 
       47 
     | 
    
         
            -
                      if expected.is_a?(String)
         
     | 
| 
       48 
     | 
    
         
            -
                        message << "\nDiff:" << self.differ.diff_as_string(target.to_s, expected)
         
     | 
| 
       49 
     | 
    
         
            -
                      elsif !target.is_a?(Proc)
         
     | 
| 
       50 
     | 
    
         
            -
                        message << "\nDiff:" << self.differ.diff_as_object(target, expected)
         
     | 
| 
       51 
     | 
    
         
            -
                      end
         
     | 
| 
       52 
     | 
    
         
            -
                    end
         
     | 
| 
       53 
41 
     | 
    
         
             
                    Kernel::raise(Micronaut::Expectations::ExpectationNotMetError.new(message))
         
     | 
| 
       54 
42 
     | 
    
         
             
                  end
         
     | 
| 
       55 
43 
     | 
    
         
             
                end
         
     | 
| 
         @@ -2,8 +2,8 @@ module Micronaut 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Extensions
         
     | 
| 
       3 
3 
     | 
    
         
             
                module Kernel
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                  def describe( 
     | 
| 
       6 
     | 
    
         
            -
                    Micronaut::BehaviourGroup. 
     | 
| 
      
 5 
     | 
    
         
            +
                  def describe(*args, &describe_block)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    Micronaut::BehaviourGroup.describe(*args, &describe_block)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
         @@ -2,9 +2,10 @@ module Micronaut 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Formatters
         
     | 
| 
       3 
3 
     | 
    
         
             
                # Baseclass for formatters that implements all required methods as no-ops. 
         
     | 
| 
       4 
4 
     | 
    
         
             
                class BaseFormatter
         
     | 
| 
       5 
     | 
    
         
            -
                  attr_accessor :example_group, :options, : 
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                  attr_accessor :example_group, :options, :output, :total_example_failed, :total_example_pending
         
     | 
| 
      
 6 
     | 
    
         
            +
                  
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def initialize(options, output_to)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @options, @output = options, output_to
         
     | 
| 
       8 
9 
     | 
    
         
             
                    @total_example_failed, @total_example_pending = 0, 0
         
     | 
| 
       9 
10 
     | 
    
         
             
                  end
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
         @@ -1,22 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Micronaut
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
              module Formatters
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
                class BaseTextFormatter < BaseFormatter
         
     | 
| 
       5 
     | 
    
         
            -
                  attr_reader : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_reader :pending_examples, :failed_examples
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
                  def initialize(options, output_to)
         
     | 
| 
       8 
9 
     | 
    
         
             
                    super
         
     | 
| 
       9 
     | 
    
         
            -
                    @output = output_to
         
     | 
| 
       10 
10 
     | 
    
         
             
                    @pending_examples = []
         
     | 
| 
       11 
11 
     | 
    
         
             
                    @failed_examples = []
         
     | 
| 
       12 
12 
     | 
    
         
             
                  end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       14 
14 
     | 
    
         
             
                  def example_pending(example, message)
         
     | 
| 
       15 
15 
     | 
    
         
             
                    super
         
     | 
| 
       16 
     | 
    
         
            -
                    # @pending_examples << [example.full_description, message, pending_caller]
         
     | 
| 
       17 
16 
     | 
    
         
             
                    @pending_examples << [example, message]
         
     | 
| 
       18 
17 
     | 
    
         
             
                  end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       20 
19 
     | 
    
         
             
                  def example_failed(example, exception)
         
     | 
| 
       21 
20 
     | 
    
         
             
                    super
         
     | 
| 
       22 
21 
     | 
    
         
             
                    @failed_examples << [example, exception]
         
     | 
| 
         @@ -25,11 +24,11 @@ module Micronaut 
     | 
|
| 
       25 
24 
     | 
    
         
             
                  def dump_failures        
         
     | 
| 
       26 
25 
     | 
    
         
             
                    @output.puts
         
     | 
| 
       27 
26 
     | 
    
         
             
                    @failed_examples.each_with_index do |examples_with_exception, index|
         
     | 
| 
       28 
     | 
    
         
            -
                      @output.puts "#{index.next})"
         
     | 
| 
       29 
27 
     | 
    
         
             
                      example, exception = examples_with_exception.first, examples_with_exception.last
         
     | 
| 
       30 
     | 
    
         
            -
                      @output.puts  
     | 
| 
      
 28 
     | 
    
         
            +
                      @output.puts "#{index.next})  #{example.class.name}"
         
     | 
| 
      
 29 
     | 
    
         
            +
                      @output.puts colorise(exception.message, exception)
         
     | 
| 
       31 
30 
     | 
    
         
             
                      @output.puts format_backtrace(exception.backtrace)
         
     | 
| 
       32 
     | 
    
         
            -
                      @output.puts  
     | 
| 
      
 31 
     | 
    
         
            +
                      @output.puts 
         
     | 
| 
       33 
32 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       34 
33 
     | 
    
         
             
                    end
         
     | 
| 
       35 
34 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -43,9 +42,7 @@ module Micronaut 
     | 
|
| 
       43 
42 
     | 
    
         
             
                  end
         
     | 
| 
       44 
43 
     | 
    
         | 
| 
       45 
44 
     | 
    
         
             
                  def dump_summary(duration, example_count, failure_count, pending_count)
         
     | 
| 
       46 
     | 
    
         
            -
                    @output.puts
         
     | 
| 
       47 
     | 
    
         
            -
                    @output.puts "Finished in #{duration} seconds"
         
     | 
| 
       48 
     | 
    
         
            -
                    @output.puts
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @output.puts "\nFinished in #{duration} seconds\n"
         
     | 
| 
       49 
46 
     | 
    
         | 
| 
       50 
47 
     | 
    
         
             
                    summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
         
     | 
| 
       51 
48 
     | 
    
         
             
                    summary << ", #{pending_count} pending" if pending_count > 0  
         
     | 
| 
         @@ -107,13 +104,28 @@ module Micronaut 
     | 
|
| 
       107 
104 
     | 
    
         
             
                    end
         
     | 
| 
       108 
105 
     | 
    
         
             
                  end
         
     | 
| 
       109 
106 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
                  def green(text) 
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                   
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                  def  
     | 
| 
      
 107 
     | 
    
         
            +
                  def green(text)
         
     | 
| 
      
 108 
     | 
    
         
            +
                    color(text, "\e[32m")
         
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                  def red(text)
         
     | 
| 
      
 112 
     | 
    
         
            +
                    color(text, "\e[31m")
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                  def magenta(text)
         
     | 
| 
      
 116 
     | 
    
         
            +
                    color(text, "\e[35m")
         
     | 
| 
      
 117 
     | 
    
         
            +
                  end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                  def yellow(text)
         
     | 
| 
      
 120 
     | 
    
         
            +
                    color(text, "\e[33m")
         
     | 
| 
      
 121 
     | 
    
         
            +
                  end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                  def blue(text)
         
     | 
| 
      
 124 
     | 
    
         
            +
                    color(text, "\e[34m")
         
     | 
| 
      
 125 
     | 
    
         
            +
                  end
         
     | 
| 
       115 
126 
     | 
    
         | 
| 
       116 
127 
     | 
    
         
             
                end
         
     | 
| 
      
 128 
     | 
    
         
            +
                
         
     | 
| 
       117 
129 
     | 
    
         
             
              end
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       119 
131 
     | 
    
         
             
            end
         
     | 
    
        data/lib/micronaut/runner.rb
    CHANGED
    
    | 
         @@ -30,7 +30,7 @@ module Micronaut 
     | 
|
| 
       30 
30 
     | 
    
         
             
                             /./ # anything - ^example_ already filtered by #examples
         
     | 
| 
       31 
31 
     | 
    
         
             
                           end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                   total_examples = Micronaut:: 
     | 
| 
      
 33 
     | 
    
         
            +
                   total_examples = Micronaut::World.behaviour_groups.inject(0) { |sum, eg| sum + eg.examples.size }
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
                   old_sync, options.formatter.output.sync = options.formatter.output.sync, true if options.formatter.output.respond_to?(:sync=)
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
         @@ -39,7 +39,7 @@ module Micronaut 
     | 
|
| 
       39 
39 
     | 
    
         
             
                   suite_success = true
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                   starts_at = Time.now
         
     | 
| 
       42 
     | 
    
         
            -
                   Micronaut:: 
     | 
| 
      
 42 
     | 
    
         
            +
                   Micronaut::World.behaviour_groups.each do |example_group|
         
     | 
| 
       43 
43 
     | 
    
         
             
                     suite_success &= example_group.run(options.formatter)
         
     | 
| 
       44 
44 
     | 
    
         
             
                   end
         
     | 
| 
       45 
45 
     | 
    
         
             
                   duration = Time.now - starts_at
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Micronaut
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              class World
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
                def self.reset
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @behaviour_groups = []
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                reset
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
                def self.behaviour_groups
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @behaviour_groups
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
                
         
     | 
| 
      
 15 
     | 
    
         
            +
                def self.find(conditions={})
         
     | 
| 
      
 16 
     | 
    
         
            +
                  return [] if conditions.empty?
         
     | 
| 
      
 17 
     | 
    
         
            +
                  
         
     | 
| 
      
 18 
     | 
    
         
            +
                  behaviour_groups.select do |group|
         
     | 
| 
      
 19 
     | 
    
         
            +
                    conditions.all? do |key, value|
         
     | 
| 
      
 20 
     | 
    
         
            +
                      case value
         
     | 
| 
      
 21 
     | 
    
         
            +
                      when Hash
         
     | 
| 
      
 22 
     | 
    
         
            +
                        value.all? { |k, v| group.metadata[key][k] == v }
         
     | 
| 
      
 23 
     | 
    
         
            +
                      when Regexp
         
     | 
| 
      
 24 
     | 
    
         
            +
                        group.metadata[key] =~ value
         
     | 
| 
      
 25 
     | 
    
         
            +
                      when Proc
         
     | 
| 
      
 26 
     | 
    
         
            +
                        value.call(group.metadata[key]) rescue false
         
     | 
| 
      
 27 
     | 
    
         
            +
                      else
         
     | 
| 
      
 28 
     | 
    
         
            +
                        group.metadata[key] == value
         
     | 
| 
      
 29 
     | 
    
         
            +
                      end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
              
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: spicycode-micronaut
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Chad Humphries
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: micronaut 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2008- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-12-02 00:00:00 -08:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -33,6 +33,7 @@ extra_rdoc_files: 
     | 
|
| 
       33 
33 
     | 
    
         
             
            files: 
         
     | 
| 
       34 
34 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       35 
35 
     | 
    
         
             
            - README
         
     | 
| 
      
 36 
     | 
    
         
            +
            - RSPEC-LICENSE
         
     | 
| 
       36 
37 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       37 
38 
     | 
    
         
             
            - lib/autotest
         
     | 
| 
       38 
39 
     | 
    
         
             
            - lib/autotest/discover.rb
         
     | 
| 
         @@ -40,10 +41,7 @@ files: 
     | 
|
| 
       40 
41 
     | 
    
         
             
            - lib/micronaut
         
     | 
| 
       41 
42 
     | 
    
         
             
            - lib/micronaut/behaviour_group.rb
         
     | 
| 
       42 
43 
     | 
    
         
             
            - lib/micronaut/behaviour_group_class_methods.rb
         
     | 
| 
       43 
     | 
    
         
            -
            - lib/micronaut/example_world.rb
         
     | 
| 
       44 
44 
     | 
    
         
             
            - lib/micronaut/expectations
         
     | 
| 
       45 
     | 
    
         
            -
            - lib/micronaut/expectations/differs
         
     | 
| 
       46 
     | 
    
         
            -
            - lib/micronaut/expectations/differs/default.rb
         
     | 
| 
       47 
45 
     | 
    
         
             
            - lib/micronaut/expectations/errors.rb
         
     | 
| 
       48 
46 
     | 
    
         
             
            - lib/micronaut/expectations/extensions
         
     | 
| 
       49 
47 
     | 
    
         
             
            - lib/micronaut/expectations/extensions/object.rb
         
     | 
| 
         @@ -66,7 +64,6 @@ files: 
     | 
|
| 
       66 
64 
     | 
    
         
             
            - lib/micronaut/matchers/eql.rb
         
     | 
| 
       67 
65 
     | 
    
         
             
            - lib/micronaut/matchers/equal.rb
         
     | 
| 
       68 
66 
     | 
    
         
             
            - lib/micronaut/matchers/errors.rb
         
     | 
| 
       69 
     | 
    
         
            -
            - lib/micronaut/matchers/exist.rb
         
     | 
| 
       70 
67 
     | 
    
         
             
            - lib/micronaut/matchers/generated_descriptions.rb
         
     | 
| 
       71 
68 
     | 
    
         
             
            - lib/micronaut/matchers/has.rb
         
     | 
| 
       72 
69 
     | 
    
         
             
            - lib/micronaut/matchers/have.rb
         
     | 
| 
         @@ -84,15 +81,13 @@ files: 
     | 
|
| 
       84 
81 
     | 
    
         
             
            - lib/micronaut/mocking/with_mocha.rb
         
     | 
| 
       85 
82 
     | 
    
         
             
            - lib/micronaut/runner.rb
         
     | 
| 
       86 
83 
     | 
    
         
             
            - lib/micronaut/runner_options.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - lib/micronaut/world.rb
         
     | 
| 
       87 
85 
     | 
    
         
             
            - lib/micronaut.rb
         
     | 
| 
       88 
86 
     | 
    
         
             
            - examples/example_helper.rb
         
     | 
| 
       89 
87 
     | 
    
         
             
            - examples/lib
         
     | 
| 
       90 
88 
     | 
    
         
             
            - examples/lib/micronaut
         
     | 
| 
       91 
89 
     | 
    
         
             
            - examples/lib/micronaut/behaviour_group_example.rb
         
     | 
| 
       92 
     | 
    
         
            -
            - examples/lib/micronaut/example_runner_example.rb
         
     | 
| 
       93 
90 
     | 
    
         
             
            - examples/lib/micronaut/expectations
         
     | 
| 
       94 
     | 
    
         
            -
            - examples/lib/micronaut/expectations/differs
         
     | 
| 
       95 
     | 
    
         
            -
            - examples/lib/micronaut/expectations/differs/default_example.rb
         
     | 
| 
       96 
91 
     | 
    
         
             
            - examples/lib/micronaut/expectations/extensions
         
     | 
| 
       97 
92 
     | 
    
         
             
            - examples/lib/micronaut/expectations/extensions/object_example.rb
         
     | 
| 
       98 
93 
     | 
    
         
             
            - examples/lib/micronaut/expectations/fail_with_example.rb
         
     | 
| 
         @@ -107,7 +102,6 @@ files: 
     | 
|
| 
       107 
102 
     | 
    
         
             
            - examples/lib/micronaut/matchers/description_generation_example.rb
         
     | 
| 
       108 
103 
     | 
    
         
             
            - examples/lib/micronaut/matchers/eql_example.rb
         
     | 
| 
       109 
104 
     | 
    
         
             
            - examples/lib/micronaut/matchers/equal_example.rb
         
     | 
| 
       110 
     | 
    
         
            -
            - examples/lib/micronaut/matchers/exist_example.rb
         
     | 
| 
       111 
105 
     | 
    
         
             
            - examples/lib/micronaut/matchers/handler_example.rb
         
     | 
| 
       112 
106 
     | 
    
         
             
            - examples/lib/micronaut/matchers/has_example.rb
         
     | 
| 
       113 
107 
     | 
    
         
             
            - examples/lib/micronaut/matchers/have_example.rb
         
     | 
| 
         @@ -120,6 +114,9 @@ files: 
     | 
|
| 
       120 
114 
     | 
    
         
             
            - examples/lib/micronaut/matchers/satisfy_example.rb
         
     | 
| 
       121 
115 
     | 
    
         
             
            - examples/lib/micronaut/matchers/simple_matcher_example.rb
         
     | 
| 
       122 
116 
     | 
    
         
             
            - examples/lib/micronaut/matchers/throw_symbol_example.rb
         
     | 
| 
      
 117 
     | 
    
         
            +
            - examples/lib/micronaut/runner_example.rb
         
     | 
| 
      
 118 
     | 
    
         
            +
            - examples/lib/micronaut/runner_options_example.rb
         
     | 
| 
      
 119 
     | 
    
         
            +
            - examples/lib/micronaut/world_example.rb
         
     | 
| 
       123 
120 
     | 
    
         
             
            - examples/lib/micronaut_example.rb
         
     | 
| 
       124 
121 
     | 
    
         
             
            - examples/resources
         
     | 
| 
       125 
122 
     | 
    
         
             
            - examples/resources/example_classes.rb
         
     | 
| 
         @@ -1,125 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path(File.dirname(__FILE__) + "/../../../../example_helper")
         
     | 
| 
       2 
     | 
    
         
            -
            require 'micronaut/expectations/differs/default'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module Micronaut
         
     | 
| 
       5 
     | 
    
         
            -
              module Fixtures
         
     | 
| 
       6 
     | 
    
         
            -
                class Animal
         
     | 
| 
       7 
     | 
    
         
            -
                  def initialize(name,species)
         
     | 
| 
       8 
     | 
    
         
            -
                    @name,@species = name,species
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                  def inspect
         
     | 
| 
       12 
     | 
    
         
            -
                    <<-EOA
         
     | 
| 
       13 
     | 
    
         
            -
            <Animal
         
     | 
| 
       14 
     | 
    
         
            -
              name=#{@name},
         
     | 
| 
       15 
     | 
    
         
            -
              species=#{@species}
         
     | 
| 
       16 
     | 
    
         
            -
            >
         
     | 
| 
       17 
     | 
    
         
            -
                    EOA
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            describe "Diff" do
         
     | 
| 
       24 
     | 
    
         
            -
              before do
         
     | 
| 
       25 
     | 
    
         
            -
                @differ = Micronaut::Expectations::Differs::Default.new(:unified)
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              it "should output unified diff of two strings" do
         
     | 
| 
       29 
     | 
    
         
            -
                expected="foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n"
         
     | 
| 
       30 
     | 
    
         
            -
                actual="foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n"
         
     | 
| 
       31 
     | 
    
         
            -
                expected_diff= <<'EOD'
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            @@ -1,6 +1,6 @@
         
     | 
| 
       35 
     | 
    
         
            -
             foo
         
     | 
| 
       36 
     | 
    
         
            -
            -zap
         
     | 
| 
       37 
     | 
    
         
            -
             bar
         
     | 
| 
       38 
     | 
    
         
            -
            +zap
         
     | 
| 
       39 
     | 
    
         
            -
             this
         
     | 
| 
       40 
     | 
    
         
            -
             is
         
     | 
| 
       41 
     | 
    
         
            -
             soo
         
     | 
| 
       42 
     | 
    
         
            -
            @@ -9,6 +9,5 @@
         
     | 
| 
       43 
     | 
    
         
            -
             equal
         
     | 
| 
       44 
     | 
    
         
            -
             insert
         
     | 
| 
       45 
     | 
    
         
            -
             a
         
     | 
| 
       46 
     | 
    
         
            -
            -another
         
     | 
| 
       47 
     | 
    
         
            -
             line
         
     | 
| 
       48 
     | 
    
         
            -
            EOD
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                diff = @differ.diff_as_string(expected, actual)
         
     | 
| 
       51 
     | 
    
         
            -
                diff.should eql(expected_diff)
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
              it "should output unified diff message of two arrays" do
         
     | 
| 
       55 
     | 
    
         
            -
                expected = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'charlie', :width, 'quite wide' ]
         
     | 
| 
       56 
     | 
    
         
            -
                actual   = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'tango'  , :width, 'very wide'  ]
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                expected_diff = <<'EOD'
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
            @@ -5,7 +5,7 @@
         
     | 
| 
       62 
     | 
    
         
            -
              :metasyntactic,
         
     | 
| 
       63 
     | 
    
         
            -
              "variable",
         
     | 
| 
       64 
     | 
    
         
            -
              :delta,
         
     | 
| 
       65 
     | 
    
         
            -
            - "tango",
         
     | 
| 
       66 
     | 
    
         
            -
            + "charlie",
         
     | 
| 
       67 
     | 
    
         
            -
              :width,
         
     | 
| 
       68 
     | 
    
         
            -
            - "very wide"]
         
     | 
| 
       69 
     | 
    
         
            -
            + "quite wide"]
         
     | 
| 
       70 
     | 
    
         
            -
            EOD
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                diff = @differ.diff_as_object(expected,actual)
         
     | 
| 
       74 
     | 
    
         
            -
                diff.should == expected_diff
         
     | 
| 
       75 
     | 
    
         
            -
              end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
              it "should output unified diff message of two objects" do
         
     | 
| 
       78 
     | 
    
         
            -
                expected = Micronaut::Fixtures::Animal.new "bob", "giraffe"
         
     | 
| 
       79 
     | 
    
         
            -
                actual   = Micronaut::Fixtures::Animal.new "bob", "tortoise"
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                expected_diff = <<'EOD'
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
            @@ -1,5 +1,5 @@
         
     | 
| 
       84 
     | 
    
         
            -
             <Animal
         
     | 
| 
       85 
     | 
    
         
            -
               name=bob,
         
     | 
| 
       86 
     | 
    
         
            -
            -  species=tortoise
         
     | 
| 
       87 
     | 
    
         
            -
            +  species=giraffe
         
     | 
| 
       88 
     | 
    
         
            -
             >
         
     | 
| 
       89 
     | 
    
         
            -
            EOD
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                diff = @differ.diff_as_object(expected,actual)
         
     | 
| 
       92 
     | 
    
         
            -
                diff.should == expected_diff
         
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
            end
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
            describe "Diff in context format" do
         
     | 
| 
       99 
     | 
    
         
            -
              before do
         
     | 
| 
       100 
     | 
    
         
            -
                @differ = Micronaut::Expectations::Differs::Default.new(:context)
         
     | 
| 
       101 
     | 
    
         
            -
              end
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
              it "should output unified diff message of two objects" do
         
     | 
| 
       104 
     | 
    
         
            -
                expected = Micronaut::Fixtures::Animal.new "bob", "giraffe"
         
     | 
| 
       105 
     | 
    
         
            -
                actual   = Micronaut::Fixtures::Animal.new "bob", "tortoise"
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                expected_diff = <<'EOD'
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
            ***************
         
     | 
| 
       110 
     | 
    
         
            -
            *** 1,5 ****
         
     | 
| 
       111 
     | 
    
         
            -
              <Animal
         
     | 
| 
       112 
     | 
    
         
            -
                name=bob,
         
     | 
| 
       113 
     | 
    
         
            -
            !   species=tortoise
         
     | 
| 
       114 
     | 
    
         
            -
              >
         
     | 
| 
       115 
     | 
    
         
            -
            --- 1,5 ----
         
     | 
| 
       116 
     | 
    
         
            -
              <Animal
         
     | 
| 
       117 
     | 
    
         
            -
                name=bob,
         
     | 
| 
       118 
     | 
    
         
            -
            !   species=giraffe
         
     | 
| 
       119 
     | 
    
         
            -
              >
         
     | 
| 
       120 
     | 
    
         
            -
            EOD
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                diff = @differ.diff_as_object(expected,actual)
         
     | 
| 
       123 
     | 
    
         
            -
                diff.should == expected_diff
         
     | 
| 
       124 
     | 
    
         
            -
              end
         
     | 
| 
       125 
     | 
    
         
            -
            end
         
     |