json_api_client_mock 0.2.3 → 0.2.4

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: e62e74f6a4163d43ba75e943c68aff457a67c8ef
4
- data.tar.gz: 7f3ebc0fa5d282d3d368d84af9b4bd8dbe9eb301
3
+ metadata.gz: ded8a7a37ecd597a987172d22a4497699d008675
4
+ data.tar.gz: 88339c610ac9c50d9a41eac4e746becafd97e8f2
5
5
  SHA512:
6
- metadata.gz: 4146df344d2cc37a798ff3e5cfdc187a1ca3253eeeb6e6046ccf04e7618f2374767fc9249abd43e7ab826e522aeb89ae359567364385a22ef6adb3b7ba6f0a9e
7
- data.tar.gz: ddde9037bc917ec35a29bab0b45f951cb8552851e568bdfce5158141d24f9d00407155b03649a001876b3746702c96c61afb83c4cad0d827068d44778db7a222
6
+ metadata.gz: a70ae80ea4e04c6eba89a8b8e482a1ac559a34fe7499dda86c3e621032853ebeebc447145fa1312e5bd93dfbe96c7abb61d9f44881d78a81dec484f78f4fe2de
7
+ data.tar.gz: f89e5e46ddc5bb09b6244be88a6aa6c61e41bee6afe57e6f23d517127e3177bd914ec2fff10b81488a327a7d2addf461a62e147ea388567821b8846e977fb9f0
@@ -36,13 +36,14 @@ module JsonApiClientMock
36
36
  end
37
37
 
38
38
  def find_test_results(query)
39
- class_mocks(query).detect{|mock| mock[:conditions] == query.params} ||
40
- class_mocks(query).detect{|mock| mock[:conditions].nil?}
39
+ class_mocks(query).detect { |mock| mock[:conditions] == query.params } ||
40
+ class_mocks(query).detect { |mock| mock[:conditions] && (mock[:conditions][:path] == query.path) } ||
41
+ class_mocks(query).detect { |mock| mock[:conditions].nil? }
41
42
  end
42
43
 
43
44
  def missing_message(query)
44
- ["no test results set for #{query.klass.name} with conditions: #{query.params.pretty_inspect}",
45
- "mocks conditions available: #{class_mocks(query).map {|m| m[:conditions]}.pretty_inspect}"].join("\n\n")
45
+ ["no test results set for #{query.klass.name} with conditions: #{query.params.pretty_inspect} or for request path #{query.path}",
46
+ "mocks conditions available: #{class_mocks(query).map { |m| m[:conditions] }.pretty_inspect}"].join("\n\n")
46
47
  end
47
48
  end
48
49
  end
@@ -1,3 +1,3 @@
1
1
  module JsonApiClientMock
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -50,6 +50,21 @@ class JsonApiClientMockTest < MiniTest::Unit::TestCase
50
50
  assert_equal('asdf', first.qwer)
51
51
  end
52
52
 
53
+ def test_by_conditional_request_path_mocking
54
+ BarResource.set_test_results([{foo: 'bar', qwer: 'asdf'}], {path: 'bar_resources/10'})
55
+ assert_raises(JsonApiClientMock::MissingMock) do
56
+ BarResource.all
57
+ end
58
+
59
+ results = BarResource.find(10)
60
+ assert_equal(1, results.length)
61
+
62
+ first = results.first
63
+ assert_equal(BarResource, first.class)
64
+ assert_equal('bar', first.foo)
65
+ assert_equal('asdf', first.qwer)
66
+ end
67
+
53
68
  def test_conditional_mocking_param_order
54
69
  BarResource.set_test_results([{foo: 'bar', qwer: 'asdf'}], {foo: 'bar', qwer: 'asdf'})
55
70
 
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.2.3
4
+ version: 0.2.4
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-09-24 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client