spicycode-micronaut 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/examples/lib/micronaut/{behaviour_group_example.rb → behaviour_example.rb} +15 -13
- data/examples/lib/micronaut/configuration_example.rb +4 -4
- data/examples/lib/micronaut/example_example.rb +46 -0
- data/examples/lib/micronaut/expectations/extensions/object_example.rb +63 -76
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +4 -3
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +2 -2
- data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +8 -29
- data/examples/lib/micronaut/matchers/be_close_example.rb +48 -38
- data/examples/lib/micronaut/matchers/be_example.rb +287 -246
- data/examples/lib/micronaut/matchers/change_example.rb +306 -275
- data/examples/lib/micronaut/matchers/description_generation_example.rb +168 -160
- data/examples/lib/micronaut/matchers/eql_example.rb +30 -24
- data/examples/lib/micronaut/matchers/equal_example.rb +31 -25
- data/examples/lib/micronaut/matchers/handler_example.rb +36 -29
- data/examples/lib/micronaut/matchers/has_example.rb +57 -49
- data/examples/lib/micronaut/matchers/include_example.rb +89 -74
- data/examples/lib/micronaut/matchers/match_example.rb +33 -29
- data/examples/lib/micronaut/world_example.rb +4 -4
- data/lib/micronaut/{behaviour_group.rb → behaviour.rb} +8 -7
- data/lib/micronaut/configuration.rb +1 -1
- data/lib/micronaut/example.rb +5 -1
- data/lib/micronaut/formatters/base_formatter.rb +6 -6
- data/lib/micronaut/formatters/base_text_formatter.rb +8 -13
- data/lib/micronaut/formatters/documentation_formatter.rb +62 -0
- data/lib/micronaut/formatters/progress_formatter.rb +1 -0
- data/lib/micronaut/formatters.rb +1 -0
- data/lib/micronaut/kernel_extensions.rb +1 -1
- data/lib/micronaut/runner.rb +1 -4
- data/lib/micronaut/runner_options.rb +11 -4
- data/lib/micronaut.rb +2 -2
- metadata +7 -4
@@ -7,7 +7,7 @@ describe Micronaut::World do
|
|
7
7
|
describe "behaviour groups" do
|
8
8
|
|
9
9
|
it "should contain all defined behaviour groups" do
|
10
|
-
behaviour_group = Micronaut::
|
10
|
+
behaviour_group = Micronaut::Behaviour.describe(Bar, 'Empty Behaviour Group') { }
|
11
11
|
Micronaut::World.behaviour_groups.should include(behaviour_group)
|
12
12
|
remove_last_describe_from_world
|
13
13
|
end
|
@@ -20,9 +20,9 @@ describe Micronaut::World do
|
|
20
20
|
options_1 = { :foo => 1, :color => 'blue', :feature => 'reporting' }
|
21
21
|
options_2 = { :pending => true, :feature => 'reporting' }
|
22
22
|
options_3 = { :array => [1,2,3,4], :color => 'blue', :feature => 'weather status' }
|
23
|
-
@bg1 = Micronaut::
|
24
|
-
@bg2 = Micronaut::
|
25
|
-
@bg3 = Micronaut::
|
23
|
+
@bg1 = Micronaut::Behaviour.describe(Bar, "find group-1", options_1) { }
|
24
|
+
@bg2 = Micronaut::Behaviour.describe(Bar, "find group-2", options_2) { }
|
25
|
+
@bg3 = Micronaut::Behaviour.describe(Bar, "find group-3", options_3) { }
|
26
26
|
end
|
27
27
|
|
28
28
|
after(:all) do
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Micronaut
|
2
|
-
|
3
|
-
class BehaviourGroup
|
2
|
+
class Behaviour
|
4
3
|
include Micronaut::Matchers
|
5
4
|
|
6
5
|
def self.inherited(klass)
|
@@ -91,7 +90,7 @@ module Micronaut
|
|
91
90
|
classes = []
|
92
91
|
current_class = self
|
93
92
|
|
94
|
-
while current_class < Micronaut::
|
93
|
+
while current_class < Micronaut::Behaviour
|
95
94
|
superclass_last ? classes << current_class : classes.unshift(current_class)
|
96
95
|
current_class = current_class.superclass
|
97
96
|
end
|
@@ -141,9 +140,11 @@ module Micronaut
|
|
141
140
|
|
142
141
|
def self.run(reporter)
|
143
142
|
return true if examples.empty?
|
144
|
-
|
145
143
|
|
144
|
+
reporter.add_behaviour(self)
|
145
|
+
|
146
146
|
group = new
|
147
|
+
|
147
148
|
eval_before_alls(group)
|
148
149
|
success = true
|
149
150
|
|
@@ -187,8 +188,8 @@ module Micronaut
|
|
187
188
|
end
|
188
189
|
|
189
190
|
def self.to_s
|
190
|
-
self == Micronaut::
|
191
|
+
self == Micronaut::Behaviour ? 'Micronaut::Behaviour' : name
|
191
192
|
end
|
192
|
-
|
193
|
+
|
193
194
|
end
|
194
|
-
end
|
195
|
+
end
|
data/lib/micronaut/example.rb
CHANGED
@@ -2,7 +2,7 @@ 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 :
|
5
|
+
attr_accessor :behaviour, :options, :output, :total_example_failed, :total_example_pending
|
6
6
|
|
7
7
|
def initialize(options, output_to)
|
8
8
|
@options, @output = options, output_to
|
@@ -14,16 +14,16 @@ module Micronaut
|
|
14
14
|
# formatters that need to provide progress on feedback (graphical ones)
|
15
15
|
#
|
16
16
|
# This method will only be invoked once, and the next one to be invoked
|
17
|
-
# is #
|
17
|
+
# is #add_behaviour
|
18
18
|
def start(example_count)
|
19
19
|
end
|
20
20
|
|
21
|
-
# This method is invoked at the beginning of the execution of each
|
22
|
-
# +
|
21
|
+
# This method is invoked at the beginning of the execution of each behaviour.
|
22
|
+
# +behaviour+ is the behaviour.
|
23
23
|
#
|
24
24
|
# The next method to be invoked after this is #example_failed or #example_finished
|
25
|
-
def
|
26
|
-
@
|
25
|
+
def add_behaviour(behaviour)
|
26
|
+
@behaviour = behaviour
|
27
27
|
end
|
28
28
|
|
29
29
|
# This method is invoked when an +example+ starts.
|
@@ -12,7 +12,6 @@ module Micronaut
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def example_pending(example, message)
|
15
|
-
super
|
16
15
|
@pending_examples << [example, message]
|
17
16
|
end
|
18
17
|
|
@@ -25,7 +24,7 @@ module Micronaut
|
|
25
24
|
@output.puts
|
26
25
|
@failed_examples.each_with_index do |examples_with_exception, index|
|
27
26
|
example, exception = examples_with_exception.first, examples_with_exception.last
|
28
|
-
@output.puts "#{index.next})
|
27
|
+
@output.puts "#{index.next}) #{example}"
|
29
28
|
@output.puts colorise(exception.message, exception)
|
30
29
|
@output.puts format_backtrace(exception.backtrace)
|
31
30
|
@output.puts
|
@@ -78,7 +77,8 @@ module Micronaut
|
|
78
77
|
|
79
78
|
def format_backtrace(backtrace)
|
80
79
|
return "" if backtrace.nil?
|
81
|
-
backtrace.map { |line| backtrace_line(line) }.join("\n")
|
80
|
+
cleansed = backtrace.map { |line| backtrace_line(line) }.compact.join("\n")
|
81
|
+
cleansed.empty? ? backtrace : cleansed
|
82
82
|
end
|
83
83
|
|
84
84
|
protected
|
@@ -88,22 +88,17 @@ module Micronaut
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def backtrace_line(line)
|
91
|
-
line.
|
91
|
+
return nil if line.rindex(Micronaut::InstallDirectory, 0)
|
92
|
+
line.sub!(/\A([^:]+:\d+)$/, '\\1')
|
93
|
+
return nil if line == '-e:1'
|
94
|
+
line
|
92
95
|
end
|
93
96
|
|
94
97
|
def color(text, color_code)
|
95
|
-
return text unless enable_color_in_output?
|
98
|
+
return text unless enable_color_in_output?
|
96
99
|
"#{color_code}#{text}\e[0m"
|
97
100
|
end
|
98
101
|
|
99
|
-
def output_to_tty?
|
100
|
-
begin
|
101
|
-
@output.tty? || ENV.has_key?("AUTOTEST")
|
102
|
-
rescue NoMethodError
|
103
|
-
false
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
102
|
def green(text)
|
108
103
|
color(text, "\e[32m")
|
109
104
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Micronaut
|
2
|
+
module Formatters
|
3
|
+
|
4
|
+
class DocumentationFormatter < BaseTextFormatter
|
5
|
+
|
6
|
+
attr_reader :previous_nested_behaviours
|
7
|
+
|
8
|
+
def initialize(options, output_to)
|
9
|
+
super
|
10
|
+
@previous_nested_behaviours = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_behaviour(behaviour)
|
14
|
+
super
|
15
|
+
|
16
|
+
described_behaviour_chain.each_with_index do |nested_behaviour, i|
|
17
|
+
unless nested_behaviour == previous_nested_behaviours[i]
|
18
|
+
desc_or_name = (i == 0) ? nested_behaviour.name : nested_behaviour.description
|
19
|
+
output.puts "#{' ' * i}#{desc_or_name}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@previous_nested_behaviours = described_behaviour_chain
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_failed(example, exception)
|
27
|
+
super
|
28
|
+
expectation_not_met = exception.is_a?(Micronaut::Expectations::ExpectationNotMetError)
|
29
|
+
|
30
|
+
message = if expectation_not_met
|
31
|
+
"#{current_indentation}#{example.description} (FAILED)"
|
32
|
+
else
|
33
|
+
"#{current_indentation}#{example.description} (ERROR)"
|
34
|
+
end
|
35
|
+
|
36
|
+
@output.puts(expectation_not_met ? red(message) : magenta(message))
|
37
|
+
@output.flush
|
38
|
+
end
|
39
|
+
|
40
|
+
def example_passed(example)
|
41
|
+
output.puts green("#{current_indentation}#{example.description}")
|
42
|
+
output.flush
|
43
|
+
end
|
44
|
+
|
45
|
+
def example_pending(example, message)
|
46
|
+
super
|
47
|
+
output.puts yellow("#{current_indentation}#{example.description} (PENDING: #{message})")
|
48
|
+
output.flush
|
49
|
+
end
|
50
|
+
|
51
|
+
def current_indentation
|
52
|
+
' ' * previous_nested_behaviours.length
|
53
|
+
end
|
54
|
+
|
55
|
+
def described_behaviour_chain
|
56
|
+
behaviour.ancestors
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
data/lib/micronaut/formatters.rb
CHANGED
data/lib/micronaut/runner.rb
CHANGED
@@ -5,7 +5,7 @@ module Micronaut
|
|
5
5
|
@@installed_at_exit ||= false
|
6
6
|
|
7
7
|
def self.options
|
8
|
-
@options ||= Micronaut::RunnerOptions.new(:color => true, :formatter => :
|
8
|
+
@options ||= Micronaut::RunnerOptions.new(:color => true, :formatter => :documentation)
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.autorun
|
@@ -36,9 +36,6 @@ module Micronaut
|
|
36
36
|
end
|
37
37
|
duration = Time.now - starts_at
|
38
38
|
|
39
|
-
options.formatter.end
|
40
|
-
options.formatter.dump
|
41
|
-
|
42
39
|
options.formatter.start_dump
|
43
40
|
options.formatter.dump_pending
|
44
41
|
options.formatter.dump_failures
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module Micronaut
|
2
|
-
|
3
2
|
class RunnerOptions
|
4
3
|
|
5
4
|
attr_accessor :color, :formatter
|
@@ -10,7 +9,11 @@ module Micronaut
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def enable_color_in_output?
|
13
|
-
@color
|
12
|
+
!textmate? && @color
|
13
|
+
end
|
14
|
+
|
15
|
+
def textmate?
|
16
|
+
ENV['TEXTMATE'] || ENV['TM_RUBY']
|
14
17
|
end
|
15
18
|
|
16
19
|
def output
|
@@ -18,9 +21,13 @@ module Micronaut
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def formatter
|
21
|
-
@formatter_instance ||=
|
24
|
+
@formatter_instance ||= case @formatter.to_s
|
25
|
+
when 'documentation'
|
26
|
+
Micronaut::Formatters::DocumentationFormatter.new(self, output)
|
27
|
+
else
|
28
|
+
Micronaut::Formatters::ProgressFormatter.new(self, output)
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
end
|
25
|
-
|
26
33
|
end
|
data/lib/micronaut.rb
CHANGED
@@ -6,7 +6,7 @@ require 'micronaut/configuration'
|
|
6
6
|
require 'micronaut/runner'
|
7
7
|
require 'micronaut/runner_options'
|
8
8
|
require 'micronaut/example'
|
9
|
-
require 'micronaut/
|
9
|
+
require 'micronaut/behaviour'
|
10
10
|
require 'micronaut/kernel_extensions'
|
11
11
|
require 'micronaut/formatters'
|
12
12
|
|
@@ -24,7 +24,7 @@ module Micronaut
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# './lib' in project dir, or '/usr/local/blahblah' if installed
|
27
|
-
|
27
|
+
InstallDirectory = File.expand_path(File.dirname(File.dirname(file)))
|
28
28
|
|
29
29
|
def self.configuration
|
30
30
|
@configuration ||= Micronaut::Configuration.new
|
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.9
|
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-
|
12
|
+
date: 2008-12-06 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ files:
|
|
40
40
|
- lib/autotest/discover.rb
|
41
41
|
- lib/autotest/micronaut.rb
|
42
42
|
- lib/micronaut
|
43
|
-
- lib/micronaut/
|
43
|
+
- lib/micronaut/behaviour.rb
|
44
44
|
- lib/micronaut/configuration.rb
|
45
45
|
- lib/micronaut/example.rb
|
46
46
|
- lib/micronaut/expectations
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/micronaut/formatters
|
56
56
|
- lib/micronaut/formatters/base_formatter.rb
|
57
57
|
- lib/micronaut/formatters/base_text_formatter.rb
|
58
|
+
- lib/micronaut/formatters/documentation_formatter.rb
|
58
59
|
- lib/micronaut/formatters/progress_formatter.rb
|
59
60
|
- lib/micronaut/formatters.rb
|
60
61
|
- lib/micronaut/kernel_extensions.rb
|
@@ -88,8 +89,9 @@ files:
|
|
88
89
|
- examples/example_helper.rb
|
89
90
|
- examples/lib
|
90
91
|
- examples/lib/micronaut
|
91
|
-
- examples/lib/micronaut/
|
92
|
+
- examples/lib/micronaut/behaviour_example.rb
|
92
93
|
- examples/lib/micronaut/configuration_example.rb
|
94
|
+
- examples/lib/micronaut/example_example.rb
|
93
95
|
- examples/lib/micronaut/expectations
|
94
96
|
- examples/lib/micronaut/expectations/extensions
|
95
97
|
- examples/lib/micronaut/expectations/extensions/object_example.rb
|
@@ -97,6 +99,7 @@ files:
|
|
97
99
|
- examples/lib/micronaut/expectations/wrap_expectation_example.rb
|
98
100
|
- examples/lib/micronaut/formatters
|
99
101
|
- examples/lib/micronaut/formatters/base_formatter_example.rb
|
102
|
+
- examples/lib/micronaut/formatters/documentation_formatter_example.rb
|
100
103
|
- examples/lib/micronaut/formatters/progress_formatter_example.rb
|
101
104
|
- examples/lib/micronaut/kernel_extensions_example.rb
|
102
105
|
- examples/lib/micronaut/matchers
|