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 +2 -2
- data/frenetic.gemspec +5 -6
- data/lib/frenetic/hal_json.rb +2 -2
- data/lib/frenetic/resource.rb +1 -1
- data/lib/frenetic/version.rb +1 -1
- data/spec/lib/frenetic/configuration_spec.rb +1 -1
- data/spec/lib/frenetic/hal_json_spec.rb +12 -14
- data/spec/lib/frenetic/resource_spec.rb +19 -15
- data/spec/lib/frenetic_spec.rb +4 -7
- data/spec/spec_helper.rb +1 -3
- metadata +27 -38
data/Gemfile
CHANGED
data/frenetic.gemspec
CHANGED
@@ -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.
|
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', '~>
|
25
|
-
gem.add_development_dependency 'guard-rspec', '~> 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 '
|
28
|
-
gem.add_development_dependency '
|
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
|
data/lib/frenetic/hal_json.rb
CHANGED
@@ -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(
|
9
|
-
@app.call(
|
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 )
|
data/lib/frenetic/resource.rb
CHANGED
data/lib/frenetic/version.rb
CHANGED
@@ -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.
|
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) {
|
2
|
+
let(:hal_json) { described_class.new }
|
3
|
+
|
3
4
|
let(:app_callbacks_stub) do
|
4
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
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
|
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) {
|
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.
|
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
|
-
|
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) {
|
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) {
|
35
|
-
let(:resource_b) {
|
36
|
+
let(:resource_a) { described_class.new( wrapped_response ) }
|
37
|
+
let(:resource_b) { described_class.new }
|
36
38
|
|
37
39
|
before do
|
38
|
-
|
40
|
+
client.stub(:description).and_return description_stub
|
39
41
|
|
40
|
-
|
42
|
+
described_class.stub(:api).and_return client
|
41
43
|
|
42
|
-
resource_a
|
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 {
|
84
|
+
before { resource.class.api_client { client } }
|
81
85
|
|
82
86
|
it "should reference the defined API client" do
|
83
|
-
subject.class.api.should ==
|
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
|
92
|
+
before { resource.class.api_client client }
|
89
93
|
|
90
94
|
it "should reference the defined API client" do
|
91
|
-
subject.class.api.should ==
|
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
|
-
|
105
|
+
client.stub(:description).and_return description_stub
|
102
106
|
|
103
|
-
resource.class.api_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 {
|
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)
|
data/spec/lib/frenetic_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Frenetic do
|
|
8
8
|
response: {}
|
9
9
|
} }
|
10
10
|
|
11
|
-
before { Frenetic::Configuration.
|
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
|
-
|
40
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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 :
|
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *2152993480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: faraday_middleware
|
27
|
-
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: *
|
35
|
+
version_requirements: *2152992980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack-cache
|
38
|
-
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: *
|
46
|
+
version_requirements: *2152992520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: addressable
|
49
|
-
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.
|
54
|
+
version: 2.3.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152992060
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: patron
|
60
|
-
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: *
|
68
|
+
version_requirements: *2152991560
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-spork
|
71
|
-
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:
|
76
|
+
version: 1.2.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153009100
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-rspec
|
82
|
-
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.
|
87
|
+
version: 1.2.1
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153008360
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rspec
|
93
|
-
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: *
|
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: &
|
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.
|
109
|
+
version: 1.8.10
|
121
110
|
type: :development
|
122
111
|
prerelease: false
|
123
|
-
version_requirements: *
|
112
|
+
version_requirements: *2153006720
|
124
113
|
- !ruby/object:Gem::Dependency
|
125
114
|
name: vcr
|
126
|
-
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.
|
120
|
+
version: 2.2.5
|
132
121
|
type: :development
|
133
122
|
prerelease: false
|
134
|
-
version_requirements: *
|
123
|
+
version_requirements: *2153005480
|
135
124
|
description: An opinionated Ruby-based Hypermedia API client.
|
136
125
|
email:
|
137
126
|
- dlindahl@customink.com
|