mocha-on-bacon 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -64,7 +64,7 @@ For more information see the Mocha and Bacon websites.
64
64
  License
65
65
  -------
66
66
 
67
- Copyright (C) 2011, Eloy Durán <eloy.de.enige@gmail.com>
67
+ Copyright (C) 2011-2012, Eloy Durán <eloy.de.enige@gmail.com>
68
68
 
69
69
  Mocha-on-Bacon is available under the MIT license. See the LICENSE file or
70
70
  http://www.opensource.org/licenses/mit-license.php
@@ -1,4 +1,4 @@
1
- require "mocha"
1
+ require "mocha_standalone"
2
2
 
3
3
  module Bacon
4
4
  module MochaRequirementsCounter
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha-on-bacon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
- - 0
10
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Eloy Duran
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-17 00:00:00 +01:00
17
+ date: 2012-07-19 00:00:00 +02:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: mocha
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 43
30
27
  segments:
31
28
  - 0
32
29
  - 9
@@ -47,8 +44,6 @@ files:
47
44
  - LICENSE
48
45
  - README.md
49
46
  - lib/mocha-on-bacon.rb
50
- - spec/mocha-on-bacon_spec.rb
51
- - spec/spec_helper.rb
52
47
  has_rdoc: true
53
48
  homepage: https://github.com/alloy/mocha-on-bacon
54
49
  licenses: []
@@ -59,30 +54,25 @@ rdoc_options:
59
54
  require_paths:
60
55
  - lib
61
56
  required_ruby_version: !ruby/object:Gem::Requirement
62
- none: false
63
57
  requirements:
64
58
  - - ">="
65
59
  - !ruby/object:Gem::Version
66
- hash: 3
67
60
  segments:
68
61
  - 0
69
62
  version: "0"
70
63
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
64
  requirements:
73
65
  - - ">="
74
66
  - !ruby/object:Gem::Version
75
- hash: 3
76
67
  segments:
77
68
  - 0
78
69
  version: "0"
79
70
  requirements: []
80
71
 
81
72
  rubyforge_project:
82
- rubygems_version: 1.3.7
73
+ rubygems_version: 1.3.6
83
74
  signing_key:
84
75
  specification_version: 3
85
76
  summary: A Mocha adapter for Bacon
86
- test_files:
87
- - spec/mocha-on-bacon_spec.rb
88
- - spec/spec_helper.rb
77
+ test_files: []
78
+
@@ -1,69 +0,0 @@
1
- require File.expand_path('../spec_helper', __FILE__)
2
-
3
- describe "Bacon specs using Mocha, with a mock" do
4
- extend MochaBaconHelper
5
-
6
- it "passes when all expectations were fulfilled" do
7
- mockee = mock()
8
- lambda do
9
- mockee.expects(:blah)
10
- mockee.blah
11
- end.should.be satisfied
12
- end
13
-
14
- it "fails when not all expectations were fulfilled" do
15
- mockee = mock()
16
- lambda { mockee.expects(:blah) }.should.be unsatisfied(mockee, :blah)
17
- end
18
-
19
- it "fails when there is an unexpected invocation" do
20
- mockee = mock()
21
- lambda { mockee.blah }.should.have received_unexpected_invocation(mockee, :blah)
22
- end
23
-
24
- it "passes when the mockee receives all expected parameters" do
25
- mockee = mock()
26
- lambda do
27
- mockee.expects(:blah).with(:wibble => 1)
28
- mockee.blah(:wibble => 1)
29
- end.should.be satisfied
30
- end
31
-
32
- it "fails when the mockee receives unexpected parameters and complains about not being satisfied" do
33
- mockee = mock()
34
- lambda do
35
- mockee.expects(:blah).with(:wobble => 1)
36
- mockee.blah(:wobble => 2)
37
- end.should.be unsatisfied(mockee, :blah, ':wobble => 1')
38
- end
39
-
40
- it "fails when the mockee receives unexpected parameters and complains about the unexpected parameters" do
41
- mockee = mock()
42
- lambda do
43
- mockee.expects(:blah).with(:wabble => 1)
44
- mockee.blah(:wabble => 2)
45
- end.should.have received_unexpected_invocation(mockee, :blah, ':wabble => 2')
46
- end
47
- end
48
-
49
- class AStub
50
- def blah
51
- end
52
- end
53
-
54
- describe "Bacon specs using Mocha, with a stub" do
55
- extend MochaBaconHelper
56
-
57
- it "passes when all Stubba expectations are fulfilled" do
58
- stubbee = AStub.new
59
- lambda do
60
- stubbee.expects(:blah)
61
- stubbee.blah
62
- end.should.be satisfied
63
- end
64
-
65
- it "fails when not all Stubba expectations were fulfilled" do
66
- stubbee = AStub.new
67
- lambda { stubbee.expects(:blah) }.should.be unsatisfied(stubbee, :blah)
68
- end
69
- end
data/spec/spec_helper.rb DELETED
@@ -1,116 +0,0 @@
1
- require "rubygems" rescue LoadError
2
- require File.expand_path('../../lib/mocha-on-bacon', __FILE__)
3
-
4
- class Should
5
- alias_method :have, :be
6
- end
7
-
8
- class MochaTestContext < Bacon::Context
9
- def initialize(name)
10
- @name = name
11
- @before, @after = [], []
12
- @specifications = []
13
- @current_specification_index = 0
14
- end
15
-
16
- def it(description, &block)
17
- super
18
- @specifications.pop
19
- end
20
-
21
- def specification_did_finish(spec)
22
- # We don't care in this case
23
- end
24
- end
25
-
26
- module MochaBaconHelper
27
- module SilenceOutput
28
- attr_accessor :silence
29
-
30
- def handle_specification_begin(name)
31
- puts name unless silence
32
- end
33
-
34
- def handle_specification_end
35
- puts unless silence
36
- end
37
-
38
- def handle_specification(name)
39
- handle_specification_begin(name)
40
- yield
41
- handle_specification_end
42
- end
43
-
44
- def handle_requirement_begin(description)
45
- print "- #{description}" unless silence
46
- end
47
-
48
- def handle_requirement_end(error)
49
- puts(error.empty? ? "" : " [#{error}]") unless silence
50
- end
51
-
52
- def handle_requirement(description)
53
- handle_requirement_begin(description)
54
- error = yield
55
- handle_requirement_end(error)
56
- end
57
-
58
- def handle_summary
59
- print Bacon::ErrorLog if Bacon::Backtraces && !silence
60
- puts "%d specifications (%d requirements), %d failures, %d errors" %
61
- Bacon::Counter.values_at(:specifications, :requirements, :failed, :errors) unless silence
62
- end
63
- end
64
- Bacon.extend SilenceOutput
65
-
66
- def counter
67
- Bacon::Counter
68
- end
69
-
70
- def error_log
71
- Bacon::ErrorLog
72
- end
73
-
74
- def mocha_context
75
- @mocha_context ||= MochaTestContext.new("Mocha test context") {}
76
- end
77
-
78
- def run_example(proc)
79
- @example_counter ||= 0; @example_counter += 1
80
-
81
- counter_before = counter.dup
82
- error_log_before = error_log.dup
83
- Bacon.silence = true
84
-
85
- spec = mocha_context.it("Mocha example `#{@example_counter}'", &proc)
86
- spec.run if spec.respond_to?(:run) # MacBacon
87
- [{ :failed => counter[:failed] - counter_before[:failed], :errors => counter_before[:errors] - counter_before[:errors] }, error_log.dup]
88
- ensure
89
- counter.replace(counter_before)
90
- error_log.replace(error_log_before)
91
- Bacon.silence = false
92
- end
93
-
94
- def satisfied
95
- lambda do |proc|
96
- difference, _ = run_example(proc)
97
- difference[:errors] == 0 && difference[:failed] == 0
98
- end
99
- end
100
-
101
- def unsatisfied(mockee, method, params = 'any_parameters')
102
- lambda do |proc|
103
- difference, error_log = run_example(proc)
104
- difference[:errors] == 0 && difference[:failed] == 1 &&
105
- error_log.include?("- expected exactly once, not yet invoked: #{mockee.mocha_inspect}.#{method}(#{params})")
106
- end
107
- end
108
-
109
- def received_unexpected_invocation(mockee, method, params = '')
110
- lambda do |proc|
111
- difference, error_log = run_example(proc)
112
- difference[:errors] == 0 && difference[:failed] == 1 &&
113
- error_log.include?("unexpected invocation: #{mockee.mocha_inspect}.#{method}(#{params})")
114
- end
115
- end
116
- end