spicycode-micronaut 0.1.2 → 0.1.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.
- data/Rakefile +2 -4
- data/examples/example_helper.rb +1 -1
- data/lib/micronaut/configuration.rb +5 -1
- data/lib/micronaut/expectations.rb +5 -3
- data/lib/micronaut/expectations/extensions/object.rb +1 -2
- data/lib/micronaut/expectations/extensions/string_and_symbol.rb +2 -0
- data/lib/micronaut/expectations/wrap_expectation.rb +1 -0
- data/lib/micronaut/matchers.rb +1 -1
- data/lib/micronaut/matchers/be.rb +1 -0
- data/lib/micronaut/matchers/be_close.rb +1 -0
- data/lib/micronaut/matchers/change.rb +1 -1
- data/lib/micronaut/matchers/eql.rb +1 -0
- data/lib/micronaut/matchers/equal.rb +1 -0
- data/lib/micronaut/matchers/have.rb +2 -2
- data/lib/micronaut/matchers/operator_matcher.rb +1 -0
- data/lib/micronaut/matchers/respond_to.rb +4 -1
- data/lib/micronaut/matchers/satisfy.rb +3 -0
- data/lib/micronaut/matchers/simple_matcher.rb +4 -1
- data/lib/micronaut/matchers/throw_symbol.rb +3 -1
- data/lib/micronaut/mocking.rb +4 -3
- data/lib/micronaut/mocking/with_rr.rb +24 -0
- data/lib/micronaut/runner.rb +14 -7
- data/lib/micronaut/world.rb +7 -5
- metadata +3 -2
- data/lib/micronaut/expectations/errors.rb +0 -7
- data/lib/micronaut/expectations/extensions.rb +0 -2
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems/specification'
|
|
4
4
|
require 'date'
|
5
5
|
|
6
6
|
GEM = "micronaut"
|
7
|
-
GEM_VERSION = "0.1.
|
7
|
+
GEM_VERSION = "0.1.3"
|
8
8
|
AUTHOR = "Chad Humphries"
|
9
9
|
EMAIL = "chad@spicycode.com"
|
10
10
|
HOMEPAGE = "http://spicycode.com"
|
@@ -50,9 +50,7 @@ namespace :micronaut do
|
|
50
50
|
desc 'Run all examples'
|
51
51
|
task :examples do
|
52
52
|
examples = Dir["examples/**/*_example.rb"].map { |g| Dir.glob(g) }.flatten
|
53
|
-
examples.
|
54
|
-
command = "-e '#{examples.join("; ")}'"
|
55
|
-
ruby command
|
53
|
+
ruby examples.join(" ")
|
56
54
|
end
|
57
55
|
|
58
56
|
desc "List files that don't have examples"
|
data/examples/example_helper.rb
CHANGED
@@ -30,6 +30,6 @@ end
|
|
30
30
|
Micronaut.configure do |config|
|
31
31
|
config.mock_with :mocha
|
32
32
|
config.options = Micronaut::RunnerOptions.new(:color => true, :formatter => :documentation)
|
33
|
-
config.add_filter :options => { :focused => true }
|
33
|
+
# config.add_filter :options => { :focused => true }
|
34
34
|
config.autorun!
|
35
35
|
end
|
@@ -18,7 +18,11 @@ module Micronaut
|
|
18
18
|
def mock_with(make_a_mockery_with=nil)
|
19
19
|
@mock_framework = case make_a_mockery_with
|
20
20
|
when :mocha
|
21
|
+
require 'micronaut/mocking/with_mocha'
|
21
22
|
Micronaut::Mocking::WithMocha
|
23
|
+
when :rr
|
24
|
+
require 'micronaut/mocking/with_rr'
|
25
|
+
Micronaut::Mocking::WithRR
|
22
26
|
else
|
23
27
|
Micronaut::Mocking::WithAbsolutelyNothing
|
24
28
|
end
|
@@ -108,4 +112,4 @@ module Micronaut
|
|
108
112
|
|
109
113
|
end
|
110
114
|
|
111
|
-
end
|
115
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'micronaut/matchers'
|
2
|
-
require 'micronaut/expectations/
|
3
|
-
require 'micronaut/expectations/extensions'
|
2
|
+
require 'micronaut/expectations/extensions/object'
|
3
|
+
require 'micronaut/expectations/extensions/string_and_symbol'
|
4
4
|
require 'micronaut/expectations/handler'
|
5
5
|
require 'micronaut/expectations/wrap_expectation'
|
6
6
|
|
@@ -31,6 +31,8 @@ module Micronaut
|
|
31
31
|
# Micronaut 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
|
+
|
35
|
+
class ExpectationNotMetError < ::StandardError; end
|
34
36
|
|
35
37
|
def self.fail_with(message, expected=nil, target=nil) # :nodoc:
|
36
38
|
if Array === message && message.length == 3
|
@@ -41,4 +43,4 @@ module Micronaut
|
|
41
43
|
|
42
44
|
end
|
43
45
|
|
44
|
-
end
|
46
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Micronaut
|
2
2
|
module Expectations
|
3
|
-
# rspec adds #should and #should_not to every Object (and,
|
4
|
-
# implicitly, every Class).
|
3
|
+
# rspec adds #should and #should_not to every Object (and, implicitly, every Class).
|
5
4
|
module ObjectExpectations
|
6
5
|
# :call-seq:
|
7
6
|
# should(matcher)
|
data/lib/micronaut/matchers.rb
CHANGED
@@ -17,7 +17,7 @@ require 'micronaut/matchers/operator_matcher'
|
|
17
17
|
|
18
18
|
module Micronaut
|
19
19
|
|
20
|
-
# We ship (courtesy of
|
20
|
+
# We ship (courtesy of RSpec and Micronaut) with a number of useful Expression Matchers. An Expression Matcher
|
21
21
|
# is any object that responds to the following methods:
|
22
22
|
#
|
23
23
|
# matches?(actual)
|
@@ -22,7 +22,7 @@ module Micronaut
|
|
22
22
|
return (@before + @amount == @after) if @amount
|
23
23
|
return ((@after - @before) >= @minimum) if @minimum
|
24
24
|
return ((@after - @before) <= @maximum) if @maximum
|
25
|
-
|
25
|
+
@before != @after
|
26
26
|
end
|
27
27
|
|
28
28
|
def raise_block_syntax_error
|
@@ -31,7 +31,7 @@ module Micronaut
|
|
31
31
|
raise not_a_collection if @given.nil?
|
32
32
|
return @given >= @expected if @relativity == :at_least
|
33
33
|
return @given <= @expected if @relativity == :at_most
|
34
|
-
|
34
|
+
@given == @expected
|
35
35
|
end
|
36
36
|
|
37
37
|
def not_a_collection
|
@@ -150,4 +150,4 @@ EOF
|
|
150
150
|
end
|
151
151
|
|
152
152
|
end
|
153
|
-
end
|
153
|
+
end
|
@@ -2,6 +2,7 @@ module Micronaut
|
|
2
2
|
module Matchers
|
3
3
|
|
4
4
|
class RespondTo #:nodoc:
|
5
|
+
|
5
6
|
def initialize(*names)
|
6
7
|
@names = names
|
7
8
|
@names_not_responded_to = []
|
@@ -14,7 +15,7 @@ module Micronaut
|
|
14
15
|
@names_not_responded_to << name
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
|
+
@names_not_responded_to.empty?
|
18
19
|
end
|
19
20
|
|
20
21
|
def failure_message
|
@@ -29,6 +30,7 @@ module Micronaut
|
|
29
30
|
# Ruby 1.9 returns the same thing for array.to_s as array.inspect, so just use array.inspect here
|
30
31
|
"respond to #{@names.inspect}"
|
31
32
|
end
|
33
|
+
|
32
34
|
end
|
33
35
|
|
34
36
|
# :call-seq:
|
@@ -43,5 +45,6 @@ module Micronaut
|
|
43
45
|
def respond_to(*names)
|
44
46
|
Matchers::RespondTo.new(*names)
|
45
47
|
end
|
48
|
+
|
46
49
|
end
|
47
50
|
end
|
@@ -2,6 +2,7 @@ module Micronaut
|
|
2
2
|
module Matchers
|
3
3
|
|
4
4
|
class Satisfy #:nodoc:
|
5
|
+
|
5
6
|
def initialize(&block)
|
6
7
|
@block = block
|
7
8
|
end
|
@@ -19,6 +20,7 @@ module Micronaut
|
|
19
20
|
def negative_failure_message
|
20
21
|
"expected #{@given} not to satisfy block"
|
21
22
|
end
|
23
|
+
|
22
24
|
end
|
23
25
|
|
24
26
|
# :call-seq:
|
@@ -43,5 +45,6 @@ module Micronaut
|
|
43
45
|
def satisfy(&block)
|
44
46
|
Matchers::Satisfy.new(&block)
|
45
47
|
end
|
48
|
+
|
46
49
|
end
|
47
50
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Micronaut
|
2
2
|
module Matchers
|
3
3
|
class SimpleMatcher
|
4
|
+
|
4
5
|
attr_writer :failure_message, :negative_failure_message, :description
|
5
6
|
|
6
7
|
def initialize(description, &match_block)
|
@@ -33,6 +34,7 @@ module Micronaut
|
|
33
34
|
def explanation
|
34
35
|
"No description provided. See RDoc for simple_matcher()"
|
35
36
|
end
|
37
|
+
|
36
38
|
end
|
37
39
|
|
38
40
|
# simple_matcher makes it easy for you to create your own custom matchers
|
@@ -128,5 +130,6 @@ module Micronaut
|
|
128
130
|
def simple_matcher(description=nil, &match_block)
|
129
131
|
SimpleMatcher.new(description, &match_block)
|
130
132
|
end
|
133
|
+
|
131
134
|
end
|
132
|
-
end
|
135
|
+
end
|
@@ -2,6 +2,7 @@ module Micronaut
|
|
2
2
|
module Matchers
|
3
3
|
|
4
4
|
class ThrowSymbol #:nodoc:
|
5
|
+
|
5
6
|
def initialize(expected_symbol = nil, expected_arg=nil)
|
6
7
|
@expected_symbol = expected_symbol
|
7
8
|
@expected_arg = expected_arg
|
@@ -27,7 +28,6 @@ module Micronaut
|
|
27
28
|
rescue NameError, ArgumentError => e
|
28
29
|
raise e unless e.message =~ /uncaught throw (`|\:)([a-zA-Z0-9_]*)(')?/
|
29
30
|
@caught_symbol = $2.to_sym
|
30
|
-
|
31
31
|
ensure
|
32
32
|
if @expected_symbol.nil?
|
33
33
|
return !@caught_symbol.nil?
|
@@ -41,6 +41,7 @@ module Micronaut
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
44
45
|
end
|
45
46
|
|
46
47
|
def failure_message
|
@@ -102,5 +103,6 @@ module Micronaut
|
|
102
103
|
def throw_symbol(sym=nil)
|
103
104
|
Matchers::ThrowSymbol.new(sym)
|
104
105
|
end
|
106
|
+
|
105
107
|
end
|
106
108
|
end
|
data/lib/micronaut/mocking.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rr'
|
2
|
+
|
3
|
+
Micronaut.configuration.backtrace_clean_patterns.push(RR::Errors::BACKTRACE_IDENTIFIER)
|
4
|
+
|
5
|
+
module Micronaut
|
6
|
+
module Mocking
|
7
|
+
module WithRR
|
8
|
+
include RR::Extensions::InstanceMethods
|
9
|
+
|
10
|
+
def _setup_mocks
|
11
|
+
RR::Space.instance.reset
|
12
|
+
end
|
13
|
+
|
14
|
+
def _verify_mocks
|
15
|
+
RR::Space.instance.verify_doubles
|
16
|
+
end
|
17
|
+
|
18
|
+
def _teardown_mocks
|
19
|
+
RR::Space.instance.reset
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/micronaut/runner.rb
CHANGED
@@ -14,18 +14,23 @@ module Micronaut
|
|
14
14
|
def options
|
15
15
|
Micronaut.configuration.options
|
16
16
|
end
|
17
|
-
|
18
|
-
def
|
19
|
-
|
17
|
+
|
18
|
+
def load_all_behaviours(files_from_args=[])
|
19
|
+
files_from_args.inject([]) { |files, arg| files.concat(Dir[arg].map { |g| Dir.glob(g) }.flatten) }.each do |file|
|
20
20
|
load file
|
21
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def run(args = [])
|
25
|
+
load_all_behaviours(args)
|
22
26
|
|
23
27
|
behaviours_to_run = Micronaut::World.behaviours_to_run
|
24
|
-
|
28
|
+
|
29
|
+
total_examples = behaviours_to_run.inject(0) { |sum, b| sum + b.examples_to_run.size }
|
25
30
|
|
26
31
|
old_sync, options.formatter.output.sync = options.formatter.output.sync, true if options.formatter.output.respond_to?(:sync=)
|
27
32
|
|
28
|
-
options.formatter.start(
|
33
|
+
options.formatter.start(total_examples)
|
29
34
|
|
30
35
|
suite_success = true
|
31
36
|
|
@@ -38,7 +43,9 @@ module Micronaut
|
|
38
43
|
options.formatter.start_dump
|
39
44
|
options.formatter.dump_pending
|
40
45
|
options.formatter.dump_failures
|
41
|
-
|
46
|
+
|
47
|
+
# TODO: Stop passing in the last two items, the formatter knows this info
|
48
|
+
options.formatter.dump_summary(duration, total_examples, options.formatter.failed_examples.size, options.formatter.pending_examples.size)
|
42
49
|
|
43
50
|
options.formatter.output.sync = old_sync if options.formatter.output.respond_to? :sync=
|
44
51
|
|
@@ -47,4 +54,4 @@ module Micronaut
|
|
47
54
|
|
48
55
|
end
|
49
56
|
|
50
|
-
end
|
57
|
+
end
|
data/lib/micronaut/world.rb
CHANGED
@@ -20,11 +20,13 @@ module Micronaut
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
number_of_behaviours_left = behaviours.inject(0) { |sum, b| sum += b.examples_to_run.size }
|
24
|
+
|
25
|
+
if number_of_behaviours_left.zero? && Micronaut.configuration.filters.size.zero?
|
26
|
+
behaviours.each do |behaviour|
|
27
|
+
behaviour.examples_to_run.concat(behaviour.examples)
|
28
|
+
end
|
29
|
+
end
|
28
30
|
|
29
31
|
behaviours
|
30
32
|
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.1.
|
4
|
+
version: 0.1.3
|
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-15 00:00:00 -08:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/micronaut/mocking
|
74
74
|
- lib/micronaut/mocking/with_absolutely_nothing.rb
|
75
75
|
- lib/micronaut/mocking/with_mocha.rb
|
76
|
+
- lib/micronaut/mocking/with_rr.rb
|
76
77
|
- lib/micronaut/mocking.rb
|
77
78
|
- lib/micronaut/runner.rb
|
78
79
|
- lib/micronaut/runner_options.rb
|