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: 45dd7ef868cb8b10798353c72c75f1cfab2b064e
4
- data.tar.gz: 509c8244ef6165a56669158d16f2990871fd8d41
3
+ metadata.gz: 982f33f937d4878ade0324d595acf46535e2206d
4
+ data.tar.gz: 201fe5e3c5307627b06f5e5d4bbbc12c707734d9
5
5
  SHA512:
6
- metadata.gz: 39c60de27ef35f0535959f54524b656f926da71e0f3184f048a74517ed1af3432f6707e5a5174420a2d0a0815d654f1eb7d00173afa5fc25e5c9d031966ddee1
7
- data.tar.gz: c3b888c0756c92edfc0c6747528e18cf8f30f4c1f69110b25ccd3f836e6d9716b0c98074e5806e15cd300f1d17300fa92b5ed5e7017dc44e6648cc8eb86ecf25
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
- def self.instance
6
- @instance ||= self.new
7
- end
5
+ class_attribute :mocks
6
+ self.mocks = {}
8
7
 
9
- def initialize
10
- # ignored
11
- @mocks = {}
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
- @mocks[klass.name] ||= []
26
- @mocks[klass.name].unshift({results: results, conditions: conditions})
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
- @mocks = {}
29
+ self.class.mocks = {}
31
30
  end
32
31
 
33
32
  protected
34
33
 
35
34
  def find_test_results(query)
36
- class_mocks = @mocks.fetch(query.klass.name, [])
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
- module ClassMethods
6
- def connection
7
- MockConnection.instance
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
@@ -1,3 +1,3 @@
1
1
  module JsonApiClientMock
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.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-04-24 00:00:00.000000000 Z
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.0
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.0
26
+ version: 0.2.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mocha
29
29
  requirement: !ruby/object:Gem::Requirement