frenetic 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in frenetic.gemspec
4
4
  gemspec
5
5
 
6
- gem "awesome_print"
7
- gem "fakefs", '~> 0.4.0', :require => false
6
+ gem 'awesome_print'
7
+ gem 'fakefs', '~> 0.4.0', require: false
@@ -18,13 +18,12 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency 'faraday', '~> 0.8.1'
19
19
  gem.add_dependency 'faraday_middleware', '~> 0.8.7'
20
20
  gem.add_dependency 'rack-cache', '~> 1.1'
21
- gem.add_dependency 'addressable', '~> 2.2.8'
21
+ gem.add_dependency 'addressable', '~> 2.3.0'
22
22
  gem.add_dependency 'patron', '~> 0.4.18'
23
23
 
24
- gem.add_development_dependency 'guard-spork', '~> 0.7.1'
25
- gem.add_development_dependency 'guard-rspec', '~> 1.0.1'
24
+ gem.add_development_dependency 'guard-spork', '~> 1.2.0'
25
+ gem.add_development_dependency 'guard-rspec', '~> 1.2.1'
26
26
  gem.add_development_dependency 'rspec', '~> 2.11.0'
27
- gem.add_development_dependency 'bourne', '~> 1.1.2'
28
- gem.add_development_dependency 'webmock', '~> 1.8.7'
29
- gem.add_development_dependency 'vcr', '~> 2.2.2'
27
+ gem.add_development_dependency 'webmock', '~> 1.8.10'
28
+ gem.add_development_dependency 'vcr', '~> 2.2.5'
30
29
  end
@@ -5,8 +5,8 @@ require 'frenetic/hal_json/response_wrapper'
5
5
  class Frenetic
6
6
 
7
7
  class HalJson < Faraday::Middleware
8
- def call( env )
9
- @app.call(env).on_complete { |env| on_complete(env) }
8
+ def call( environment )
9
+ @app.call(environment).on_complete { |env| on_complete(env) }
10
10
  end
11
11
 
12
12
  def on_complete( env )
@@ -7,7 +7,7 @@ class Frenetic
7
7
  if attributes.is_a? Hash
8
8
  load attributes.keys, attributes
9
9
 
10
- @links = []
10
+ @links = {}
11
11
  else
12
12
  load self.class.schema, attributes
13
13
 
@@ -1,3 +1,3 @@
1
1
  class Frenetic
2
- VERSION = "0.0.3"
2
+ VERSION = '0.0.4'
3
3
  end
@@ -81,7 +81,7 @@ describe Frenetic::Configuration do
81
81
  end
82
82
 
83
83
  context "which includes incorrect cache settings" do
84
- before { Frenetic::Configuration.any_instance.stubs(:configure_cache).returns(nil) }
84
+ before { Frenetic::Configuration.any_instance.stub(:configure_cache).and_return nil }
85
85
 
86
86
  it "should raise a configuration error for a missing :metastore" do
87
87
  expect {
@@ -1,31 +1,29 @@
1
1
  describe Frenetic::HalJson do
2
- let(:hal_json) { Frenetic::HalJson.new }
2
+ let(:hal_json) { described_class.new }
3
+
3
4
  let(:app_callbacks_stub) do
4
- stub('FaradayCallbackStubs').tap do |cb_stub|
5
- cb_stub.stubs('on_complete').yields env
5
+ double('FaradayCallbackStubs').tap do |cb|
6
+ cb.stub(:on_complete).and_yield env
6
7
  end
7
8
  end
9
+
8
10
  let(:app_stub) do
9
- stub('FaradayAppStub').tap do |app_stub|
10
- app_stub.stubs(call: app_callbacks_stub)
11
+ double('FaradayAppStub').tap do |app|
12
+ app.stub(:call).and_return app_callbacks_stub
11
13
  end
12
14
  end
13
15
 
14
- before { hal_json.instance_variable_set("@app", app_stub) }
16
+ before { hal_json.instance_variable_set '@app', app_stub }
15
17
 
16
18
  subject { hal_json }
17
19
 
18
20
  describe "#call" do
19
- let(:env) { Hash.new(:status => 200) }
20
-
21
- before do
22
- hal_json.stubs(:on_complete)
23
-
24
- hal_json.call(env)
25
- end
21
+ let(:env) { { status:200 } }
26
22
 
27
23
  it "should execute the on_complete callback" do
28
- hal_json.should have_received(:on_complete).with(env)
24
+ hal_json.should_receive( :on_complete ).with env
25
+
26
+ hal_json.call env
29
27
  end
30
28
  end
31
29
 
@@ -1,8 +1,9 @@
1
1
  describe Frenetic::Resource do
2
2
 
3
- @client = Frenetic.new('url' => 'http://example.org')
3
+ let(:client) { Frenetic.new('url' => 'http://example.org') }
4
+
5
+ let(:resource) { described_class.new }
4
6
 
5
- let(:resource) { Frenetic::Resource.new }
6
7
  let(:description_stub) do
7
8
  Frenetic::HalJson::ResponseWrapper.new('resources' => { 'schema' => { 'resource' =>
8
9
  { 'properties' => { 'foo' => 2 } }
@@ -12,9 +13,10 @@ describe Frenetic::Resource do
12
13
  subject { resource }
13
14
 
14
15
  context "created from a Hash" do
15
- let(:resource) { Frenetic::Resource.new( foo: 'bar' ) }
16
+ let(:resource) { described_class.new( foo: 'bar' ) }
16
17
 
17
18
  it { should respond_to(:foo) }
19
+ its(:links) { should be_a Hash }
18
20
  its(:links) { should be_empty }
19
21
  end
20
22
 
@@ -31,15 +33,15 @@ describe Frenetic::Resource do
31
33
  let(:wrapped_response) do
32
34
  Frenetic::HalJson::ResponseWrapper.new(api_response)
33
35
  end
34
- let(:resource_a) { Frenetic::Resource.new( wrapped_response ) }
35
- let(:resource_b) { Frenetic::Resource.new }
36
+ let(:resource_a) { described_class.new( wrapped_response ) }
37
+ let(:resource_b) { described_class.new }
36
38
 
37
39
  before do
38
- @client.stubs(:description).returns( description_stub )
40
+ client.stub(:description).and_return description_stub
39
41
 
40
- Frenetic::Resource.stubs(:api).returns( @client )
42
+ described_class.stub(:api).and_return client
41
43
 
42
- resource_a and resource_b
44
+ resource_a && resource_b
43
45
  end
44
46
 
45
47
  context "initialized with data" do
@@ -49,6 +51,7 @@ describe Frenetic::Resource do
49
51
  it { should_not respond_to(:bar) }
50
52
  its(:links) { should_not be_empty }
51
53
  end
54
+
52
55
  context "intiailized in sequence without data" do
53
56
  subject { resource_b }
54
57
 
@@ -56,6 +59,7 @@ describe Frenetic::Resource do
56
59
  it { should_not respond_to(:bar) }
57
60
  its(:links) { should be_empty }
58
61
  end
62
+
59
63
  context "with embedded resources" do
60
64
  let(:api_response) do
61
65
  {
@@ -77,18 +81,18 @@ describe Frenetic::Resource do
77
81
 
78
82
  describe ".api_client" do
79
83
  context "with a block" do
80
- before { resource.class.api_client { @client } }
84
+ before { resource.class.api_client { client } }
81
85
 
82
86
  it "should reference the defined API client" do
83
- subject.class.api.should == @client
87
+ subject.class.api.should == client
84
88
  end
85
89
  end
86
90
 
87
91
  context "with an argument" do
88
- before { resource.class.api_client @client }
92
+ before { resource.class.api_client client }
89
93
 
90
94
  it "should reference the defined API client" do
91
- subject.class.api.should == @client
95
+ subject.class.api.should == client
92
96
  end
93
97
  end
94
98
  end
@@ -98,9 +102,9 @@ describe Frenetic::Resource do
98
102
 
99
103
  context "with a defined API Client" do
100
104
  before do
101
- @client.stubs(:description).returns( description_stub )
105
+ client.stub(:description).and_return description_stub
102
106
 
103
- resource.class.api_client @client
107
+ resource.class.api_client client
104
108
  end
105
109
 
106
110
  it "should return the schema for the specific resource" do
@@ -109,7 +113,7 @@ describe Frenetic::Resource do
109
113
  end
110
114
 
111
115
  context "without a defined API Client" do
112
- before { Frenetic::Resource.stubs(:respond_to?).with(:api).returns( false ) }
116
+ before { described_class.stub(:respond_to?).with(:api).and_return false }
113
117
 
114
118
  it "should raise an error" do
115
119
  expect { subject }.to raise_error(Frenetic::MissingAPIReference)
@@ -8,7 +8,7 @@ describe Frenetic do
8
8
  response: {}
9
9
  } }
10
10
 
11
- before { Frenetic::Configuration.stubs(:new).returns(config) }
11
+ before { Frenetic::Configuration.stub(:new).and_return config }
12
12
 
13
13
  subject { client }
14
14
 
@@ -36,14 +36,11 @@ describe Frenetic do
36
36
  it { should be_a Faraday::Connection }
37
37
 
38
38
  it "should be created" do
39
- faraday_stub = Faraday.new
40
- Faraday.stubs(:new).returns( faraday_stub )
39
+ Faraday.should_receive( :new ).with do |cfg|
40
+ cfg.has_key? :url
41
+ end
41
42
 
42
43
  client
43
-
44
- Faraday.should have_received(:new).with() { |config|
45
- config.has_key? :url
46
- }
47
44
  end
48
45
 
49
46
  describe 'logger configuration' do
@@ -9,14 +9,12 @@ Spork.prefork do
9
9
  require 'rspec'
10
10
  require 'fakefs/spec_helpers'
11
11
  require 'awesome_print'
12
- require 'bourne'
13
12
  require 'vcr'
14
13
 
15
14
  RSpec.configure do |config|
16
- config.filter_run :focus => true
15
+ config.filter_run focus:true
17
16
  config.run_all_when_everything_filtered = true
18
17
  config.treat_symbols_as_metadata_keys_with_true_values = true
19
- config.mock_with :mocha
20
18
  end
21
19
 
22
20
  VCR.configure do |c|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frenetic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-21 00:00:00.000000000 Z
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
- requirement: &2164705080 !ruby/object:Gem::Requirement
16
+ requirement: &2152993480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164705080
24
+ version_requirements: *2152993480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday_middleware
27
- requirement: &2164719480 !ruby/object:Gem::Requirement
27
+ requirement: &2152992980 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2164719480
35
+ version_requirements: *2152992980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack-cache
38
- requirement: &2164717740 !ruby/object:Gem::Requirement
38
+ requirement: &2152992520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,21 +43,21 @@ dependencies:
43
43
  version: '1.1'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2164717740
46
+ version_requirements: *2152992520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: addressable
49
- requirement: &2164716900 !ruby/object:Gem::Requirement
49
+ requirement: &2152992060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.2.8
54
+ version: 2.3.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2164716900
57
+ version_requirements: *2152992060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: patron
60
- requirement: &2164716220 !ruby/object:Gem::Requirement
60
+ requirement: &2152991560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,32 +65,32 @@ dependencies:
65
65
  version: 0.4.18
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2164716220
68
+ version_requirements: *2152991560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-spork
71
- requirement: &2164715380 !ruby/object:Gem::Requirement
71
+ requirement: &2153009100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: 0.7.1
76
+ version: 1.2.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2164715380
79
+ version_requirements: *2153009100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: guard-rspec
82
- requirement: &2164714260 !ruby/object:Gem::Requirement
82
+ requirement: &2153008360 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
- version: 1.0.1
87
+ version: 1.2.1
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2164714260
90
+ version_requirements: *2153008360
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &2164725920 !ruby/object:Gem::Requirement
93
+ requirement: &2153007440 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,40 +98,29 @@ dependencies:
98
98
  version: 2.11.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2164725920
102
- - !ruby/object:Gem::Dependency
103
- name: bourne
104
- requirement: &2164724580 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 1.1.2
110
- type: :development
111
- prerelease: false
112
- version_requirements: *2164724580
101
+ version_requirements: *2153007440
113
102
  - !ruby/object:Gem::Dependency
114
103
  name: webmock
115
- requirement: &2164722520 !ruby/object:Gem::Requirement
104
+ requirement: &2153006720 !ruby/object:Gem::Requirement
116
105
  none: false
117
106
  requirements:
118
107
  - - ~>
119
108
  - !ruby/object:Gem::Version
120
- version: 1.8.7
109
+ version: 1.8.10
121
110
  type: :development
122
111
  prerelease: false
123
- version_requirements: *2164722520
112
+ version_requirements: *2153006720
124
113
  - !ruby/object:Gem::Dependency
125
114
  name: vcr
126
- requirement: &2164736740 !ruby/object:Gem::Requirement
115
+ requirement: &2153005480 !ruby/object:Gem::Requirement
127
116
  none: false
128
117
  requirements:
129
118
  - - ~>
130
119
  - !ruby/object:Gem::Version
131
- version: 2.2.2
120
+ version: 2.2.5
132
121
  type: :development
133
122
  prerelease: false
134
- version_requirements: *2164736740
123
+ version_requirements: *2153005480
135
124
  description: An opinionated Ruby-based Hypermedia API client.
136
125
  email:
137
126
  - dlindahl@customink.com