spicycode-micronaut 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
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.2"
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.map! {|f| %Q(require "#{f}")}
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"
@@ -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/errors'
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)
@@ -1,9 +1,11 @@
1
1
  module Micronaut
2
2
  module Expectations
3
3
  module StringHelpers
4
+
4
5
  def starts_with?(prefix)
5
6
  to_s[0..(prefix.to_s.length - 1)] == prefix.to_s
6
7
  end
8
+
7
9
  end
8
10
  end
9
11
  end
@@ -52,5 +52,6 @@ module Micronaut
52
52
  return false
53
53
  end
54
54
  end
55
+
55
56
  end
56
57
  end
@@ -17,7 +17,7 @@ require 'micronaut/matchers/operator_matcher'
17
17
 
18
18
  module Micronaut
19
19
 
20
- # We ship (courtesy of OSS and Micronaut) with a number of useful Expression Matchers. An Expression Matcher
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)
@@ -199,5 +199,6 @@ it reads really poorly.
199
199
  def be(*args)
200
200
  Matchers::Be.new(*args)
201
201
  end
202
+
202
203
  end
203
204
  end
@@ -17,5 +17,6 @@ module Micronaut
17
17
  (actual - expected).abs < delta
18
18
  end
19
19
  end
20
+
20
21
  end
21
22
  end
@@ -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
- return @before != @after
25
+ @before != @after
26
26
  end
27
27
 
28
28
  def raise_block_syntax_error
@@ -21,5 +21,6 @@ module Micronaut
21
21
  actual.eql?(expected)
22
22
  end
23
23
  end
24
+
24
25
  end
25
26
  end
@@ -21,5 +21,6 @@ module Micronaut
21
21
  actual.equal?(expected)
22
22
  end
23
23
  end
24
+
24
25
  end
25
26
  end
@@ -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
- return @given == @expected
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
@@ -1,6 +1,7 @@
1
1
  module Micronaut
2
2
  module Matchers
3
3
  class OperatorMatcher
4
+
4
5
  def initialize(actual)
5
6
  @actual = actual
6
7
  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
- return @names_not_responded_to.empty?
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
@@ -1,6 +1,7 @@
1
+ require 'micronaut/mocking/with_absolutely_nothing'
2
+
1
3
  module Micronaut
2
4
  module Mocking
3
- autoload :WithMocha, 'micronaut/mocking/with_mocha'
4
- autoload :WithAbsolutelyNothing, 'micronaut/mocking/with_absolutely_nothing'
5
+
5
6
  end
6
- end
7
+ end
@@ -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
@@ -14,18 +14,23 @@ module Micronaut
14
14
  def options
15
15
  Micronaut.configuration.options
16
16
  end
17
-
18
- def run(args = [])
19
- args.inject([]) { |files, arg| files.concat(Dir[arg].map { |g| Dir.glob(g) }.flatten) }.each do |file|
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
- total_behaviours = behaviours_to_run.inject(0) { |sum, b| sum + b.examples_to_run.size }
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(total_behaviours)
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
- options.formatter.dump_summary(duration, total_behaviours, options.formatter.failed_examples.size, options.formatter.pending_examples.size)
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
@@ -20,11 +20,13 @@ module Micronaut
20
20
  end
21
21
  end
22
22
 
23
- # if behaviours.inject(0) { |sum, b| sum += b.examples_to_run.size }.zero?
24
- # behaviours.each do |behaviour|
25
- # behaviour.examples_to_run.concat(behaviour.examples)
26
- # end
27
- # end
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.2
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 00:00:00 -08:00
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
@@ -1,7 +0,0 @@
1
- module Micronaut
2
- module Expectations
3
- class ExpectationNotMetError < ::StandardError
4
-
5
- end
6
- end
7
- end
@@ -1,2 +0,0 @@
1
- require 'micronaut/expectations/extensions/object'
2
- require 'micronaut/expectations/extensions/string_and_symbol'