spyke 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6613906c7dbb4e350d7d7bbe598b0775b8283ec
4
- data.tar.gz: c1532061ab3a9fb149ffcdd23edf6212e489b1cc
3
+ metadata.gz: 6bb23a4da9d9143ff6f62b5887a54b0244746be8
4
+ data.tar.gz: 926010cb42bae7510da165fa4c94cc69dbe96faa
5
5
  SHA512:
6
- metadata.gz: 3facc112e5940a263ee4ab013061c89302629e181db8d077e55d5e9307fc4cb00d5e11c394e0ced52d7de987b8bc92026ab0ee04731386e52ee41b622e79f306
7
- data.tar.gz: e4c8ffd32b2befab7ea1aa7a0387f82c71a0063c32c538ace19f701957914abc10e792a685957137f35eaea5dc117e010c54b088356f14c9a62e76fc91064bef
6
+ metadata.gz: 8a5ca662137935d28cd46ebe4fda3ca44a0158edde6c1d658f1a7195445a565626d393abb571d448564cee4910b75d9a477789b81b521591e56be0edac270267
7
+ data.tar.gz: 87ba21f060e68307b1aaf49386d180e2a511a5a5d8b4af9a68bd1f82ad9a585b4bb5760ea17e674d21a60e2e5260e4aaeaaa7702877cf14e0087b2d985fbee82
data/README.md CHANGED
@@ -32,13 +32,19 @@ Add this line to your application's Gemfile:
32
32
  gem 'spyke'
33
33
  ```
34
34
 
35
- Like Her, Spyke uses Faraday to handle requests and expects it to return a hash in the following format:
35
+ Spyke uses Faraday to handle requests and expects it to parse the response body into a hash in the following format:
36
36
 
37
37
  ```ruby
38
38
  { data: { id: 1, name: 'Bob' }, metadata: {}, errors: [] }
39
39
  ```
40
40
 
41
- The simplest possible configuration that can work is something like this:
41
+ So, for example for an API that returns JSON in the following format:
42
+
43
+ ```json
44
+ { "result": { "id": 1, "name": "Bob" }, "metadata": {}, "message": "" }
45
+ ```
46
+
47
+ ...the simplest possible configuration that could work is something like this:
42
48
 
43
49
  ```ruby
44
50
  # config/initializers/spyke.rb
@@ -6,7 +6,7 @@ module Spyke
6
6
 
7
7
  attr_reader :klass, :params
8
8
  attr_writer :params
9
- delegate :to_ary, :[], :empty?, :last, :size, :metadata, to: :find_some
9
+ delegate :to_ary, :[], :any?, :empty?, :last, :size, :metadata, to: :find_some
10
10
 
11
11
  def initialize(klass, options = {})
12
12
  @klass, @options, @params = klass, options, {}
data/lib/spyke/scoping.rb CHANGED
@@ -6,7 +6,7 @@ module Spyke
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  module ClassMethods
9
- delegate :where, :build, to: :all
9
+ delegate :where, :build, :any?, :empty?, to: :all
10
10
 
11
11
  def all
12
12
  current_scope || Relation.new(self, uri: uri)
data/lib/spyke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '1.7.1'
2
+ VERSION = '1.7.2'
3
3
  end
data/test/path_test.rb CHANGED
@@ -25,5 +25,11 @@ module Spyke
25
25
  Path.new('/users/:user_id/recipes/(:id)', id: 2).to_s
26
26
  end
27
27
  end
28
+
29
+ def test_optional_params_with_extension
30
+ skip 'wishlisted'
31
+ assert_equal '/1/profiles/2.json', Path.new('/1/profiles(/:id).json', id: 2).to_s
32
+ assert_equal '/1/profiles.json', Path.new('/1/profiles(/:id).json').to_s
33
+ end
28
34
  end
29
35
  end
@@ -12,6 +12,13 @@ module Spyke
12
12
  assert_equal 'meta', recipes.metadata
13
13
  end
14
14
 
15
+ def test_any?
16
+ endpoint = stub_request(:get, 'http://sushi.com/recipes').to_return_json(result: [{ id: 1 }])
17
+
18
+ assert_equal true, Recipe.any?
19
+ assert_requested endpoint
20
+ end
21
+
15
22
  def test_scope_independence
16
23
  endpoint = stub_request(:get, 'http://sushi.com/recipes?query=chicken')
17
24
  wrong_endpoint = stub_request(:get, 'http://sushi.com/recipes?query=chicken&page=1')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spyke
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-17 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport