spyke 3.1.5 → 4.0.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: 0e75ef98287bd1196be3c4647e76fbb520cfff40
4
- data.tar.gz: 3ad8efc200dc648c584a8ab15d9359d14890b039
3
+ metadata.gz: e980ff30e66724a75b850bd1f34c55e61811982a
4
+ data.tar.gz: 6445b6f21a1636cdd84ecb64228583f7abb3fde1
5
5
  SHA512:
6
- metadata.gz: d06077ba95eafba760c3ccdc3f89dc6b23466ab5dc5492b3d46f4be5f8ab12975d8dc14df01baed6207e2124b204265c83fcc4a0a155f78e10c78f8b23cce335
7
- data.tar.gz: 62ae17285e13c889012c101b7ca901968de20f15ba51381faf2398038d2b227f1251dd79f757c3f55b36526e85268bca1f96e2f25b691f3637cfbf484e360d85
6
+ metadata.gz: 72b27fd9fc2e31c0d20a0d6659fe3df37e7608c35a86fa65d9f770ff9c5f86e7f54efcbed52cc277496ca321f82c30f729a337aa8a2ec6db91e9839e8d9b5978
7
+ data.tar.gz: 366d92028af07c902f6e7a7dd4ef5c3938f1059de6e39caff50fa8dba158e70923b37b918f9e852ea33557cb9f18d471d2f872ab7eb5ba34fc4734201620fe85
data/README.md CHANGED
@@ -93,7 +93,7 @@ user = User.find(3)
93
93
  user.posts
94
94
  # => find embedded in returned JSON or GET http://api.com/users/3/posts
95
95
 
96
- user.update_attributes(name: 'Alice')
96
+ user.update(name: 'Alice')
97
97
  # => PUT http://api.com/users/3 - { user: { name: 'Alice' } }
98
98
 
99
99
  user.destroy
data/lib/spyke/orm.rb CHANGED
@@ -24,7 +24,6 @@ module Spyke
24
24
 
25
25
  def find(id)
26
26
  raise ResourceNotFound if id.blank?
27
- id = strip_slug(id)
28
27
  where(id: id).find_one || raise(ResourceNotFound)
29
28
  end
30
29
 
@@ -41,10 +40,6 @@ module Spyke
41
40
  def destroy(id = nil)
42
41
  new(id: id).destroy
43
42
  end
44
-
45
- def strip_slug(id)
46
- id.to_s.split('-').first
47
- end
48
43
  end
49
44
 
50
45
  def to_params
@@ -72,10 +67,11 @@ module Spyke
72
67
  self.attributes = delete
73
68
  end
74
69
 
75
- def update_attributes(new_attributes)
70
+ def update(new_attributes)
76
71
  self.attributes = new_attributes
77
72
  save
78
73
  end
74
+ alias :update_attributes :update
79
75
 
80
76
  def reload
81
77
  self.attributes = self.class.find(id).attributes
data/lib/spyke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '3.1.5'
2
+ VERSION = '4.0.0'
3
3
  end
data/test/orm_test.rb CHANGED
@@ -25,12 +25,6 @@ module Spyke
25
25
  assert_equal 'Sashimi', recipe.title
26
26
  end
27
27
 
28
- def test_find_with_slug
29
- endpoint = stub_request(:get, 'http://sushi.com/recipes/1').to_return_json(result: { id: 1 })
30
- Recipe.find('1-delicious-soup')
31
- assert_requested endpoint
32
- end
33
-
34
28
  def test_404
35
29
  stub_request(:get, 'http://sushi.com/recipes/1').to_return(status: 404, body: { message: 'Not found' }.to_json)
36
30
 
@@ -70,6 +64,16 @@ module Spyke
70
64
  assert_requested endpoint
71
65
  end
72
66
 
67
+ def test_update
68
+ endpoint = stub_request(:put, 'http://sushi.com/recipes/1').with(body: { recipe: { title: 'Sushi' } }).to_return_json(result: { id: 1, title: 'Sushi (saved)' })
69
+
70
+ recipe = Recipe.new(id: 1, title: 'Sashimi')
71
+ recipe.update(title: 'Sushi')
72
+
73
+ assert_equal 'Sushi (saved)', recipe.title
74
+ assert_requested endpoint
75
+ end
76
+
73
77
  def test_create
74
78
  endpoint = stub_request(:post, 'http://sushi.com/recipes').with(body: { recipe: { title: 'Sushi' } }).to_return_json(result: { id: 1, title: 'Sushi' })
75
79
 
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: 3.1.5
4
+ version: 4.0.0
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-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport