rspecproxies 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +3 -1
- data/README.md +5 -3
- data/lib/rspecproxies/proxies.rb +5 -3
- data/lib/rspecproxies/version.rb +1 -1
- data/rspecproxies.gemspec +2 -1
- data/spec/rspecproxies/proxies_spec.rb +1 -0
- data/spec/spec_helper.rb +3 -0
- metadata +20 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b3a0b1c4a48a2cea5b58e1c967c5a15d23f68c2
|
4
|
+
data.tar.gz: eca395f2f3c1aa00361a83b117b77f010770a236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0237c662bc25f4ccd32906389a8e7a55ebf133a8985d1f431496a134780ad6c4f2d36ccc08a64e658f8f593b6f4cba161774dcfffe6e179ec7c8cb37d8b7271e
|
7
|
+
data.tar.gz: ebd24e274002755e08bb7f0d2a1979d5c31652d5b4effa4df151585000d9258deff6fe32cddaff94e2e82763878fb3e3f769e4de248ecabff17f5ad1701faf3e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/philou/rspecproxies.svg?branch=master)](https://travis-ci.org/philou/rspecproxies) [![Test Coverage](https://codeclimate.com/github/philou/rspecproxies/badges/coverage.svg)](https://codeclimate.com/github/philou/rspecproxies) [![Code Climate](https://codeclimate.com/github/philou/rspecproxies/badges/gpa.svg)](https://codeclimate.com/github/philou/rspecproxies)
|
2
|
+
|
1
3
|
# RSpecProxies
|
2
4
|
|
3
5
|
Special RSpec extensions to simplify mocking by providing proxies.
|
@@ -35,7 +37,7 @@ it 'caches users' do
|
|
35
37
|
controller.login('joe', 'secret')
|
36
38
|
controller.login('joe', 'secret')
|
37
39
|
|
38
|
-
expect(users).to have_exactly(
|
40
|
+
expect(users).to have_exactly(1).items
|
39
41
|
end
|
40
42
|
```
|
41
43
|
|
@@ -47,7 +49,7 @@ it 'loads the actual user' do
|
|
47
49
|
|
48
50
|
controller.login('joe', 'secret')
|
49
51
|
|
50
|
-
expect(response).to
|
52
|
+
expect(response).to include(@user.login_count)
|
51
53
|
end
|
52
54
|
```
|
53
55
|
|
@@ -63,7 +65,7 @@ it 'retries on error' do
|
|
63
65
|
|
64
66
|
resources = Resource.get_at_least(10)
|
65
67
|
|
66
|
-
expect(resources).to have_exactly(
|
68
|
+
expect(resources).to have_exactly(10).items
|
67
69
|
end
|
68
70
|
```
|
69
71
|
|
data/lib/rspecproxies/proxies.rb
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
class Object
|
4
4
|
|
5
|
+
include RSpec::Mocks::ExampleMethods
|
6
|
+
|
5
7
|
# Will call the given block with it's result every time the method
|
6
8
|
# returns
|
7
9
|
def on_result_from(method_name)
|
8
10
|
stock_response = self.original_response(method_name)
|
9
11
|
|
10
|
-
self.
|
12
|
+
allow(self).to receive(method_name) do |*args, &block|
|
11
13
|
result = stock_response.call(*args, &block)
|
12
14
|
yield result
|
13
15
|
result
|
@@ -34,7 +36,7 @@ class Object
|
|
34
36
|
def on_call_to(method_name)
|
35
37
|
stock_response = self.original_response(method_name)
|
36
38
|
|
37
|
-
self.
|
39
|
+
allow(self).to receive(method_name) do |*args, &block|
|
38
40
|
yield *args
|
39
41
|
stock_response.call(*args, &block)
|
40
42
|
end
|
@@ -46,7 +48,7 @@ class Object
|
|
46
48
|
# Allows to set up stub chains quickly and safely.
|
47
49
|
def proxy_chain(*selectors, &block)
|
48
50
|
if selectors.count == 1
|
49
|
-
final_stub = self.
|
51
|
+
final_stub = allow(self).to receive(selectors.first)
|
50
52
|
block.call(final_stub) unless block.nil?
|
51
53
|
else
|
52
54
|
self.on_result_from(selectors.first) do |result|
|
data/lib/rspecproxies/version.rb
CHANGED
data/rspecproxies.gemspec
CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "rspec"
|
21
|
+
spec.add_dependency "rspec", "~> 3.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "rake"
|
26
26
|
spec.add_development_dependency "guard-rspec"
|
27
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
27
28
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspecproxies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philou
|
@@ -31,22 +31,22 @@ cert_chain:
|
|
31
31
|
yLcl1cmm5ALtJ/+Bkkmp0i4amXeTDMvq9r8PBsVsQwxYOYJBP+Umxz3PX6HjFHrQ
|
32
32
|
XdkXx3oZ
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-
|
34
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
42
|
+
version: '3.0'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '0'
|
49
|
+
version: '3.0'
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: bundler
|
52
52
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +103,20 @@ dependencies:
|
|
103
103
|
- - '>='
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: codeclimate-test-reporter
|
108
|
+
requirement: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
type: :development
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
106
120
|
description: Proxy doubles for RSpec
|
107
121
|
email:
|
108
122
|
- philippe.bourgau@gmail.com
|
metadata.gz.sig
CHANGED
Binary file
|