json_api_client_mock 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 982f33f937d4878ade0324d595acf46535e2206d
|
4
|
+
data.tar.gz: 201fe5e3c5307627b06f5e5d4bbbc12c707734d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c378206af0be909fda4f77faa69e51203fcfe2fb3669341b51ec8b28bc273eed93fcf679492c8a8fdc4041c8a4d3fbe1b3a3395c5479a8f5cea7d613831a4c
|
7
|
+
data.tar.gz: 47403f111489581ef6ea01f937922b6a586bd36fb4d911c41fac368390506daa31835cf53841d47e44204715a04ab96a4ea05a6ea231990ad20bb2af085d38c3
|
@@ -2,14 +2,13 @@ require 'ostruct'
|
|
2
2
|
|
3
3
|
module JsonApiClientMock
|
4
4
|
class MockConnection
|
5
|
-
|
6
|
-
|
7
|
-
end
|
5
|
+
class_attribute :mocks
|
6
|
+
self.mocks = {}
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
8
|
+
# ignored
|
9
|
+
def initialize(*attrs); end
|
10
|
+
def use(*attrs); end
|
11
|
+
def delete(*attrs); end
|
13
12
|
|
14
13
|
def execute(query)
|
15
14
|
if results = find_test_results(query)
|
@@ -22,18 +21,18 @@ module JsonApiClientMock
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def set_test_results(klass, results, conditions = nil)
|
25
|
-
|
26
|
-
|
24
|
+
self.class.mocks[klass.name] ||= []
|
25
|
+
self.class.mocks[klass.name].unshift({results: results, conditions: conditions})
|
27
26
|
end
|
28
27
|
|
29
28
|
def clear_test_results
|
30
|
-
|
29
|
+
self.class.mocks = {}
|
31
30
|
end
|
32
31
|
|
33
32
|
protected
|
34
33
|
|
35
34
|
def find_test_results(query)
|
36
|
-
class_mocks =
|
35
|
+
class_mocks = self.class.mocks.fetch(query.klass.name, [])
|
37
36
|
class_mocks.detect{|mock| mock[:conditions] == query.params} ||
|
38
37
|
class_mocks.detect{|mock| mock[:conditions].nil?}
|
39
38
|
end
|
@@ -2,11 +2,11 @@ module JsonApiClientMock
|
|
2
2
|
module ResourceExtensions
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
included do
|
6
|
+
self.connection_class = MockConnection
|
7
|
+
end
|
9
8
|
|
9
|
+
module ClassMethods
|
10
10
|
def set_test_results(results, conditions = nil)
|
11
11
|
connection.set_test_results(self, results, conditions)
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_client_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mocha
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|