rspec-multi-mock 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ *.log
3
+ *.db
4
+ pkg
5
+ rdoc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in transformers.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec-multi-mock (0.2.1)
5
+ rspec (>= 2.3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ mocha (0.9.12)
12
+ not_a_mock (1.0.1)
13
+ rake (0.9.2.2)
14
+ rr (1.0.4)
15
+ rspec (2.11.0)
16
+ rspec-core (~> 2.11.0)
17
+ rspec-expectations (~> 2.11.0)
18
+ rspec-mocks (~> 2.11.0)
19
+ rspec-core (2.11.1)
20
+ rspec-expectations (2.11.3)
21
+ diff-lcs (~> 1.1.3)
22
+ rspec-mocks (2.11.3)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ mocha (~> 0.9.8)
29
+ not_a_mock (~> 1.0.1)
30
+ rake
31
+ rr (~> 1.0.2)
32
+ rspec-multi-mock!
@@ -1,28 +1,28 @@
1
- == Description
1
+ ## rspec-multi-mock [![Build Status](http://travis-ci.org/endeepak/rspec-multi-mock.png)](http://travis-ci.org/endeepak/rspec-multi-mock)
2
2
 
3
- Allows multiple mock frameworks to be in action in RSpec. This version is for rspec ~>2.3.0.
3
+ Allows multiple mock frameworks to be in action in RSpec. This version is for rspec >=2.3.0.
4
4
 
5
- For rspec 1.3.1 refer to v0.1.0[https://github.com/endeepak/rspec-multi-mock/tree/v0.1.0]
5
+ For rspec 1.3.1 refer to [v0.1.0](https://github.com/endeepak/rspec-multi-mock/tree/v0.1.0)
6
6
 
7
- == Installation
7
+ ## Installation
8
8
 
9
- gem install rspec-multi-mock
9
+ gem install rspec-multi-mock
10
10
 
11
- == Usage
11
+ ## Usage
12
12
 
13
13
  If you are using bundler add the dependency in Gemfile
14
14
 
15
- gem 'rspec-multi-mock', :group => :test
15
+ gem 'rspec-multi-mock', :group => :test
16
16
 
17
17
  Configure multi-mock for RSpec runner (Usually done in spec_helper.rb)
18
18
 
19
- RSpec.configure do |config|
20
- config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr, :not_a_mock, ::NewMockFramework::RSpecAdapter)
21
- end
19
+ RSpec.configure do |config|
20
+ config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr, :not_a_mock, ::NewMockFramework::RSpecAdapter)
21
+ end
22
22
 
23
23
  As shown above you can use a symbol for frameworks listed above. The usage of adapter module directly may not work completely if the adapter module contains any extensions methods to be used in specs. For instance RR rspec adapter includes both the adapter methods and the extension methods.
24
24
 
25
- == When & How is this useful?
25
+ ## When & How is this useful?
26
26
 
27
27
  There are cases where you might have to use two different mocking in the same project(for a while). It could be because
28
28
 
@@ -42,13 +42,13 @@ Using this gem you can
42
42
 
43
43
  Please note that using multiple mocking frameworks can create a lot of confusion in the team. So make sure that the end goal is to use single mocking framework(Your favorite one!). Use this gem only during the transition phase.
44
44
 
45
- == Note
45
+ ## Note
46
46
 
47
47
  If you are already using multiple mock frameworks with just one mock framework configured in spec runner, the mocks may not be working completely as you expected.
48
48
 
49
49
  * The expectations set using the un-configured mocking framework will not be verified.
50
50
  * The methods mocked or stubbed using the un-configured mocking framework will not be cleaned up after the spec run is completed. This becomes a serious issue if it is a class method.
51
51
 
52
- == Limitations
52
+ ## Limitations
53
53
 
54
54
  * RR ad Not-A-Mock can not be used together since both frameworks have different implementation of 'have_received' matcher. This is true for any two frameworks with similar interface and different implementations.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec"
5
+ require "rspec/core/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.rspec_opts = %w(--format documentation --color)
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ task :default => ["spec"]
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module MultiMock
2
+ VERSION = "0.2.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rspec-multi-mock"
7
+ s.version = MultiMock::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Deepak N"]
10
+ s.email = ["endeep123@gmail.com"]
11
+ s.homepage = "https://github.com/endeepak/rspec-multi-mock"
12
+ s.summary = %q{Multiple mock frameworks support for RSpec}
13
+ s.description = %q{Allows multiple mock frameworks to be in action in RSpec.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ s.add_runtime_dependency("rspec", ">= 2.3.0")
20
+ s.add_development_dependency("rake")
21
+ s.add_development_dependency("mocha", "~> 0.9.8")
22
+ s.add_development_dependency("not_a_mock", "~> 1.0.1")
23
+ s.add_development_dependency("rr", "~> 1.0.2")
24
+ end
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe MultiMock::Adapter do
4
+ context "with mocha" do
5
+ it "should return the stubbed value" do
6
+ Object.expects(:hello).returns("Hello Mocha")
7
+
8
+ Object.hello.should == "Hello Mocha"
9
+ end
10
+
11
+ it "should verify the proxied expectation" do
12
+ stub(Mocha::Mockery.instance).verify #This is to make sure mocha does not verify expecteations at the end of this spec
13
+ Object.expects(:hello).never
14
+ begin
15
+ Object.hello
16
+ fail "Expected to raise Mocha::ExpectationError"
17
+ rescue Mocha::ExpectationError
18
+ end
19
+ end
20
+
21
+ it "is setting up data for next spec" do
22
+ Object.stubs(:stubbed_method).returns("Hello Mocha")
23
+ Object.stubbed_method
24
+ end
25
+
26
+ it "should clear the stubs created in previous specs" do
27
+ lambda { Object.stubbed_method }.should raise_error(NoMethodError)
28
+ end
29
+ end
30
+
31
+ context "with ::NotAMock::RspecMockFrameworkAdapter" do
32
+ it "should return the stubbed value" do
33
+ Object.stub_method(:hello => "Hello Not A Mock")
34
+
35
+ Object.hello.should == "Hello Not A Mock"
36
+ end
37
+
38
+ it "should verify the proxied expectation" do
39
+ Object.stub_method(:hello) {}
40
+
41
+ Object.hello
42
+
43
+ Object.should have_received(:hello)
44
+ end
45
+
46
+ it "is setting up data for next spec" do
47
+ Object.stub_method(:stubbed_method) {}
48
+ Object.stubbed_method
49
+ end
50
+
51
+ it "should clear the stubs created in previous specs" do
52
+ lambda { Object.stubbed_method }.should raise_error(NoMethodError)
53
+ end
54
+ end
55
+
56
+ context "with rr" do
57
+ it "should return the stubbed value" do
58
+ stub(Object).hello { "Hello RR" }
59
+
60
+ Object.hello.should == "Hello RR"
61
+ end
62
+
63
+ it "should verify the proxied expectation" do
64
+ dont_allow(Object).hello
65
+
66
+ lambda { Object.hello }.should raise_error(RR::Errors::TimesCalledError)
67
+ end
68
+
69
+ it "is setting up data for next spec" do
70
+ stub(Object).stubbed_method {}
71
+ Object.stubbed_method
72
+ end
73
+
74
+ it "should clear the stubs created in previous specs" do
75
+ lambda { Object.stubbed_method }.should raise_error(NoMethodError)
76
+ end
77
+ end
78
+
79
+ context "with rspec mock" do
80
+ it "should return the stubbed value" do
81
+ Object.should_receive(:hello).and_return("Hello RSpec mock")
82
+
83
+ Object.hello.should == "Hello RSpec mock"
84
+ end
85
+
86
+ it "should verify the proxied expectation" do
87
+ Object.should_receive(:hello).never
88
+
89
+ lambda { Object.hello }.should raise_error(RSpec::Mocks::MockExpectationError)
90
+ end
91
+
92
+ it "is setting up data for next spec" do
93
+ Object.should_receive(:stubbed_method).and_return("Hello Mocha")
94
+ Object.stubbed_method
95
+ end
96
+
97
+ it "should clear the stubs created in previous specs" do
98
+ lambda { Object.stubbed_method }.should raise_error(NoMethodError)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+ require 'rspec-multi-mock'
4
+ require 'not_a_mock'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with MultiMock::Adapter.for(:rspec, :mocha, :rr, ::NotAMock::RspecMockFrameworkAdapter)
8
+ # config.mock_with :mocha
9
+ # config.mock_with :rspec
10
+ # config.mock_with ::NotAMock::RspecMockFrameworkAdapter
11
+ # config.mock_with :rr
12
+ end
metadata CHANGED
@@ -1,93 +1,84 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rspec-multi-mock
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Deepak N
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-02-01 00:00:00 +05:30
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-10-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2165689140 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 3
31
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
32
21
  version: 2.3.0
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: mocha
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2165689140
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &2165688540 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2165688540
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &2165676360 !ruby/object:Gem::Requirement
39
39
  none: false
40
- requirements:
40
+ requirements:
41
41
  - - ~>
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- - 9
46
- - 8
42
+ - !ruby/object:Gem::Version
47
43
  version: 0.9.8
48
44
  type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: not_a_mock
52
45
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: *2165676360
47
+ - !ruby/object:Gem::Dependency
48
+ name: not_a_mock
49
+ requirement: &2165675560 !ruby/object:Gem::Requirement
54
50
  none: false
55
- requirements:
51
+ requirements:
56
52
  - - ~>
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 1
60
- - 0
61
- - 1
53
+ - !ruby/object:Gem::Version
62
54
  version: 1.0.1
63
55
  type: :development
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: rr
67
56
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ version_requirements: *2165675560
58
+ - !ruby/object:Gem::Dependency
59
+ name: rr
60
+ requirement: &2165674800 !ruby/object:Gem::Requirement
69
61
  none: false
70
- requirements:
62
+ requirements:
71
63
  - - ~>
72
- - !ruby/object:Gem::Version
73
- segments:
74
- - 1
75
- - 0
76
- - 2
64
+ - !ruby/object:Gem::Version
77
65
  version: 1.0.2
78
66
  type: :development
79
- version_requirements: *id004
80
- description: Allows multiple mock frameworks to be in action in RSpec
81
- email: endeep123@gmail.com
67
+ prerelease: false
68
+ version_requirements: *2165674800
69
+ description: Allows multiple mock frameworks to be in action in RSpec.
70
+ email:
71
+ - endeep123@gmail.com
82
72
  executables: []
83
-
84
73
  extensions: []
85
-
86
- extra_rdoc_files:
87
- - README.rdoc
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - Gemfile.lock
88
79
  - LICENSE
89
- files:
90
- - README.rdoc
80
+ - README.md
81
+ - Rakefile
91
82
  - lib/adapter.rb
92
83
  - lib/adapters/mocha.rb
93
84
  - lib/adapters/not_a_mock.rb
@@ -96,39 +87,40 @@ files:
96
87
  - lib/adapters/unknown.rb
97
88
  - lib/multi_mock.rb
98
89
  - lib/rspec-multi-mock.rb
99
- - LICENSE
100
- has_rdoc: true
101
- homepage: http://github.com/endeepak/rspec-multi-mock
90
+ - lib/version.rb
91
+ - rspec-multi-mock.gemspec
92
+ - spec/adapter_spec.rb
93
+ - spec/spec_helper.rb
94
+ homepage: https://github.com/endeepak/rspec-multi-mock
102
95
  licenses: []
103
-
104
96
  post_install_message:
105
- rdoc_options:
106
- - --main
107
- - README.rdoc
108
- require_paths:
97
+ rdoc_options: []
98
+ require_paths:
109
99
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
100
+ required_ruby_version: !ruby/object:Gem::Requirement
111
101
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- segments:
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ segments:
116
107
  - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
108
+ hash: -3547394442165570990
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
110
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- segments:
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ segments:
124
116
  - 0
125
- version: "0"
117
+ hash: -3547394442165570990
126
118
  requirements: []
127
-
128
119
  rubyforge_project:
129
- rubygems_version: 1.3.7
120
+ rubygems_version: 1.8.15
130
121
  signing_key:
131
122
  specification_version: 3
132
123
  summary: Multiple mock frameworks support for RSpec
133
- test_files: []
134
-
124
+ test_files:
125
+ - spec/adapter_spec.rb
126
+ - spec/spec_helper.rb