cortex-client 0.2.5 → 0.2.6

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: 1924b4d0bb93e904774f038ad782b6cea0bbe81e
4
- data.tar.gz: 3d6acf30a4ecd16adc9f5659dc040e504f8db1bd
3
+ metadata.gz: dbc7f3a571dbb32fcc37a005ab162f65e71e9053
4
+ data.tar.gz: 51eee03bbaa63c4e1cf897e1dbcc73f377f13a96
5
5
  SHA512:
6
- metadata.gz: 74f73137d6c06cccab2c14e8618ca0f2e3456616b7f26b725bd3d4cfb5e9e3e4b26321f30a2b492b1638a5d872cbb597ff1fefa33d82c290c504e0a707c01494
7
- data.tar.gz: f6e92c5d3a706491f230588d63e74afe20814c10b2bc6f87e0ebf1c0840ce6c40e1f5493c3d85f81a9cd81ad78bef726c89e82d86888141f20997d2b9b2166f8
6
+ metadata.gz: 9ffec12c8de2a7314b695f961cdc6d7d62fb395f5b832a6b39456f6f4d673c831585fa05b6f5c81842fdf022fa2a951950e3c10ea1e4219bbe62dc35d22102d9
7
+ data.tar.gz: c5025876bc24781fbb062dd54911098c57cb6511f3ead7f5802357aafb674bfa1db21306f5ad085791b85cc2b6ee1f58556bae2c27b1c37d12bef96d1162d9d4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cortex-client (0.1.0)
4
+ cortex-client (0.2.5)
5
5
  faraday (~> 0.9)
6
6
  faraday_middleware (~> 0.9.0)
7
7
  oauth2 (~> 0.9)
@@ -25,20 +25,24 @@ GEM
25
25
  multi_xml (~> 0.5)
26
26
  rack (~> 1.2)
27
27
  rack (1.5.2)
28
- rake (10.2.2)
29
- rspec (2.14.1)
30
- rspec-core (~> 2.14.0)
31
- rspec-expectations (~> 2.14.0)
32
- rspec-mocks (~> 2.14.0)
33
- rspec-core (2.14.8)
34
- rspec-expectations (2.14.5)
35
- diff-lcs (>= 1.1.3, < 2.0)
36
- rspec-mocks (2.14.6)
28
+ rake (10.3.2)
29
+ rspec (3.0.0)
30
+ rspec-core (~> 3.0.0)
31
+ rspec-expectations (~> 3.0.0)
32
+ rspec-mocks (~> 3.0.0)
33
+ rspec-core (3.0.3)
34
+ rspec-support (~> 3.0.0)
35
+ rspec-expectations (3.0.3)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.0.0)
38
+ rspec-mocks (3.0.3)
39
+ rspec-support (~> 3.0.0)
40
+ rspec-support (3.0.3)
37
41
 
38
42
  PLATFORMS
39
43
  ruby
40
44
 
41
45
  DEPENDENCIES
42
46
  cortex-client!
43
- rake
44
- rspec
47
+ rake (~> 10.3.2)
48
+ rspec (~> 3.0)
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
14
14
  s.require_paths = ['lib']
15
15
 
16
- s.add_development_dependency 'rake'
17
- s.add_development_dependency 'rspec'
16
+ s.add_development_dependency 'rake', '~> 10.3.2'
17
+ s.add_development_dependency 'rspec', '~> 3.0'
18
18
 
19
19
  s.add_dependency 'faraday', '~> 0.9'
20
20
  s.add_dependency 'faraday_middleware', '~> 0.9.0'
@@ -50,9 +50,9 @@ module Cortex
50
50
 
51
51
  def parse_response(response)
52
52
  if response.status < 300 || (response.body.kind_of?(Hash) && response.body['error'])
53
- OpenStruct.new({body: response.body, headers: response.headers.select { |k| ['content-range', 'x-total-items'].include? k } })
53
+ OpenStruct.new({body: response.body, headers: { status: response.status }.merge(response.headers.select { |k| ['content-range', 'x-total-items'].include? k }) })
54
54
  else
55
- OpenStruct.new({:error => response.body, :status => response.status, :original => response})
55
+ OpenStruct.new({body: {error: response.body, status: response.status, original: response}, headers: { status: response.status }})
56
56
  end
57
57
  end
58
58
  end
@@ -1,3 +1,3 @@
1
1
  module Cortex
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -9,7 +9,7 @@ describe Cortex::Client do
9
9
  end
10
10
 
11
11
  it 'should preserve settings' do
12
- client.access_token.should == access_token
13
- client.base_url.should == base_url
12
+ expect(client.access_token).to eq(access_token)
13
+ expect(client.base_url).to eq(base_url)
14
14
  end
15
15
  end
data/spec/posts_spec.rb CHANGED
@@ -6,20 +6,20 @@ describe Cortex::Posts do
6
6
 
7
7
  describe :get do
8
8
  it 'should correctly make the request' do
9
- client.should_receive(:get).with('/posts/1').and_return('response')
10
- client.posts.get(1).should == 'response'
9
+ expect(client).to receive(:get).with('/posts/1').and_return('response')
10
+ expect(client.posts.get(1)).to eq('response')
11
11
  end
12
12
  end
13
13
 
14
14
  describe :feed do
15
15
  it 'should correctly make the request' do
16
- client.should_receive(:get).with('/posts/feed', nil).and_return('response')
17
- client.posts.feed().should == 'response'
16
+ expect(client).to receive(:get).with('/posts/feed', nil).and_return('response')
17
+ expect(client.posts.feed()).to eq('response')
18
18
  end
19
19
 
20
20
  it 'should accept parameters and send them with the request' do
21
- client.should_receive(:get).with('/posts/feed', {q: "Test*"}).and_return('success')
22
- client.posts.feed(q: 'Test*').should == 'success'
21
+ expect(client).to receive(:get).with('/posts/feed', {q: "Test*"}).and_return('success')
22
+ expect(client.posts.feed(q: 'Test*')).to eq('success')
23
23
  end
24
24
  end
25
25
 
@@ -27,38 +27,38 @@ describe Cortex::Posts do
27
27
  context 'with an existing post' do
28
28
  it 'should correctly make the request' do
29
29
  post = {:id => 1, :title => 'Post'}
30
- client.should_receive(:put).with('/posts/1', post).and_return('response')
31
- client.posts.save(post).should == 'response'
30
+ expect(client).to receive(:put).with('/posts/1', post).and_return('response')
31
+ expect(client.posts.save(post)).to eq('response')
32
32
  end
33
33
  end
34
34
 
35
35
  context 'with a new post' do
36
36
  it 'should correctly make the request' do
37
37
  post = {:title => 'Post'}
38
- client.should_receive(:post).with('/posts', post).and_return('response')
39
- client.posts.save(post).should == 'response'
38
+ expect(client).to receive(:post).with('/posts', post).and_return('response')
39
+ expect(client.posts.save(post)).to eq('response')
40
40
  end
41
41
  end
42
42
  end
43
43
 
44
44
  describe :filters do
45
45
  it 'should correctly make the request' do
46
- client.should_receive(:get).with('/posts/filters').and_return('success')
47
- client.posts.filters().should == 'success'
46
+ expect(client).to receive(:get).with('/posts/filters').and_return('success')
47
+ expect(client.posts.filters()).to eq('success')
48
48
  end
49
49
  end
50
50
 
51
51
  describe :related do
52
52
  it 'should correctly make the request' do
53
- client.should_receive(:get).with('/posts/feed/1/related', nil).and_return('success')
54
- client.posts.related(1).should == 'success'
53
+ expect(client).to receive(:get).with('/posts/feed/1/related', nil).and_return('success')
54
+ expect(client.posts.related(1)).to eq('success')
55
55
  end
56
56
  end
57
57
 
58
58
  describe :authors do
59
59
  it 'should correctly make the request' do
60
- client.should_receive(:get).with('/posts/feed/authors').and_return('success')
61
- client.posts.authors.should == 'success'
60
+ expect(client).to receive(:get).with('/posts/feed/authors').and_return('success')
61
+ expect(client.posts.authors).to eq('success')
62
62
  end
63
63
  end
64
64
  end
data/spec/request_spec.rb CHANGED
@@ -6,27 +6,28 @@ describe Cortex::Request do
6
6
  context 'with a cortex error response' do
7
7
  it 'should return the error object' do
8
8
  body = {'error' => 'Validation error or something'}
9
- response = OpenStruct.new(:status => 422, :body => body, :headers => { :whatever => "Whatever"})
10
- client.parse_response(response).to_h.should == { :body => body, :headers => {}}
9
+ response = OpenStruct.new(status: 422, body: body, headers: { :whatever => "Whatever"})
10
+ expect(client.parse_response(response).to_h).to eq({ :body => body, :headers => {status: 422}})
11
11
  end
12
12
  end
13
13
 
14
14
  context 'with a non-cortex error response' do
15
15
  it 'should return a wrapped response' do
16
16
  body = 'Catastrophic error'
17
- response = OpenStruct.new(:status => 500, :body => body, :headers => { :whatever => "Whatever" })
17
+ response = OpenStruct.new(status: 500, body: body, headers: { whatever: "Whatever", status: 500 } )
18
18
  parsed = client.parse_response(response)
19
- parsed.error.should == body
20
- parsed.status.should == 500
21
- parsed.original.should == response
19
+ expect(parsed.body[:error]).to eq(body)
20
+ expect(parsed.body[:status]).to eq(500)
21
+ expect(parsed.body[:original]).to eq(response)
22
+ expect(parsed.headers[:status]).to eq(500)
22
23
  end
23
24
  end
24
25
 
25
26
  context 'with a successful response' do
26
27
  it 'should return the parsed body' do
27
28
  body = {:id => 1, title: 'A post'}
28
- response = OpenStruct.new(:status => 200, :body => body, :headers => { :whatever => "Whatever" })
29
- client.parse_response(response).to_h.should == { :body => body, :headers => {}}
29
+ response = OpenStruct.new(status: 200, body: body, headers: { :whatever => "Whatever" })
30
+ expect(client.parse_response(response).to_h).to eq({ body: body, headers: {status: 200}})
30
31
  end
31
32
  end
32
33
  end
data/spec/users_spec.rb CHANGED
@@ -6,16 +6,16 @@ describe Cortex::Users do
6
6
 
7
7
  describe :me do
8
8
  it 'should correctly make the request' do
9
- client.should_receive(:get).with('/users/me').and_return('response')
9
+ expect(client).to receive(:get).with('/users/me').and_return('response')
10
10
  response = client.users.me
11
- response.should == 'response'
11
+ expect(response).to eq('response')
12
12
  end
13
13
  end
14
14
 
15
15
  describe :get do
16
16
  it 'should correctly make the request' do
17
- client.should_receive(:get).with('/users/1').and_return('response')
18
- client.users.get(1).should == 'response'
17
+ expect(client).to receive(:get).with('/users/1').and_return('response')
18
+ expect(client.users.get(1)).to eq('response')
19
19
  end
20
20
  end
21
21
 
@@ -23,18 +23,18 @@ describe Cortex::Users do
23
23
  context 'with an existing user' do
24
24
  it 'should correctly make the request' do
25
25
  user = {:id => 1, :email => 'user@cbcortex.com'}
26
- client.should_receive(:put).with('/users/1', user).and_return('response')
26
+ expect(client).to receive(:put).with('/users/1', user).and_return('response')
27
27
  response = client.users.save(user)
28
- response.should == 'response'
28
+ expect(response).to eq('response')
29
29
  end
30
30
  end
31
31
 
32
32
  context 'with a new user' do
33
33
  it 'should correctly make the request' do
34
34
  user = {:email => 'user@cbcortex.com'}
35
- client.should_receive(:post).with('/users', user).and_return('response')
35
+ expect(client).to receive(:post).with('/users', user).and_return('response')
36
36
  response = client.users.save(user)
37
- response.should == 'response'
37
+ expect(response).to eq('response')
38
38
  end
39
39
  end
40
40
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bennett Goble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 10.3.2
20
20
  type: :development
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'
26
+ version: 10.3.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement