expects_chain 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/expects_chain.rb
CHANGED
@@ -32,7 +32,12 @@ module ExpectsChain
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def mocker
|
35
|
-
@_mocker
|
35
|
+
if @_mocker.nil?
|
36
|
+
framework = RSpec.configuration.mock_framework.framework_name.to_s.capitalize.to_sym
|
37
|
+
raise StandardError.new("expects_chain unsupported framework: #{framework}") unless Mockers.constants.include?(framework)
|
38
|
+
@_mocker = Mockers::const_get(framework)
|
39
|
+
end
|
40
|
+
@_mocker
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ExpectsChain
|
2
|
+
module Mockers
|
3
|
+
module Rspec
|
4
|
+
def self.mock_object obj, method, ret
|
5
|
+
obj.should_receive(method).and_return(ret)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.mock_object_with_arguments obj, method, attrs, ret
|
9
|
+
obj.should_receive(method).with(*attrs).and_return(ret)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.stub_object obj, method, ret
|
13
|
+
obj.stub!(method).and_return(ret)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.stub_object_with_arguments obj, method, attrs, ret
|
17
|
+
obj.stub!(method).with(*attrs).and_return(ret)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.mock
|
21
|
+
::RSpec::Mocks::Mock.new(nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.stub
|
25
|
+
::RSpec::Mocks::Mock.new(nil)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expects_chain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ cert_chain: []
|
|
12
12
|
date: 2012-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: RSpec extension that allows you to set chained expectations on objects.
|
15
|
-
Currently supports mocha
|
15
|
+
Currently supports rspec & mocha
|
16
16
|
email: pewniak747@gmail.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- lib/expects_chain.rb
|
22
22
|
- lib/expects_chain/expectation.rb
|
23
23
|
- lib/expects_chain/mockers/mocha.rb
|
24
|
+
- lib/expects_chain/mockers/rspec.rb
|
24
25
|
homepage: http://github.com/pewniak747/expects_chain
|
25
26
|
licenses: []
|
26
27
|
post_install_message:
|