her 0.8.1 → 0.8.3

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.
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ language: ruby
3
3
  sudo: false
4
4
 
5
5
  rvm:
6
+ - 2.3.1
6
7
  - 2.2.2
7
8
  - 2.1.6
8
9
  - 2.0.0
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ # Maintenance Update 29th Sept 2016
2
+ Hi folks, [@edtjones](https://github.com/edtjones) here. Rémi has handed me the keys to Her and [@foxpaul](https://github.com/foxpaul) and I will be trying to do the library justice with the help of the community. There's loads to do; we'll get in touch with everyone who's raised a PR as soon as possible and figure out a plan of action.
3
+
4
+ # Rails 5 support
5
+ If you need Rails 5 support, version 0.8.2 is for you!
6
+
1
7
  <p align="center">
2
8
  <a href="https://github.com/remiprev/her">
3
9
  <img src="http://i.imgur.com/43KEchq.png" alt="Her" />
data/UPGRADE.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Here is a list of notable changes by release. Her follows the [Semantic Versioning](http://semver.org/) system.
4
4
 
5
- ## 0.8.0
5
+ ## 0.8.1 (Note: 0.8.0 yanked)
6
6
 
7
7
  - Initial support for JSONAPI [link](https://github.com/remiprev/her/pull/347)
8
8
  - Fix for has_one association parsing [link](https://github.com/remiprev/her/pull/352)
data/her.gemspec CHANGED
@@ -18,13 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_development_dependency "rake", "~> 10.0"
21
- s.add_development_dependency "rspec", "~> 2.13"
22
- s.add_development_dependency "rspec-its", "~> 1.0"
23
- s.add_development_dependency "fivemat", "~> 1.2"
21
+ s.add_development_dependency "rspec", "~> 3.5"
24
22
  s.add_development_dependency "json", "~> 1.8"
25
23
 
26
- s.add_runtime_dependency "activemodel", ">= 3.0.0", "<= 4.3.0"
27
- s.add_runtime_dependency "activesupport", ">= 3.0.0", "<= 4.3.0"
24
+ s.add_runtime_dependency "activemodel", ">= 3.0.0", "<= 6.0.0"
25
+ s.add_runtime_dependency "activesupport", ">= 3.0.0", "<= 6.0.0"
28
26
  s.add_runtime_dependency "faraday", ">= 0.8", "< 1.0"
29
27
  s.add_runtime_dependency "multi_json", "~> 1.7"
30
28
  end
@@ -33,8 +33,7 @@ module Her
33
33
  end
34
34
 
35
35
  # create a proxy to the fetched object's method
36
- metaclass = (class << self; self; end)
37
- metaclass.install_proxy_methods 'association.fetch', name
36
+ AssociationProxy.install_proxy_methods 'association.fetch', name
38
37
 
39
38
  # resend message to fetched object
40
39
  __send__(name, *args, &block)
data/lib/her/model/orm.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  module Her
2
3
  module Model
3
4
  # This module adds ORM-like capabilities to the model
@@ -72,10 +73,10 @@ module Her
72
73
  # @user = User.find(1)
73
74
  # @user.destroy
74
75
  # # Called via DELETE "/users/1"
75
- def destroy
76
+ def destroy(params = {})
76
77
  method = self.class.method_for(:destroy)
77
78
  run_callbacks :destroy do
78
- self.class.request(:_method => method, :_path => request_path) do |parsed_data, response|
79
+ self.class.request(params.merge(:_method => method, :_path => request_path)) do |parsed_data, response|
79
80
  assign_attributes(self.class.parse(parsed_data[:data])) if parsed_data[:data].any?
80
81
  @metadata = parsed_data[:metadata]
81
82
  @response_errors = parsed_data[:errors]
@@ -159,7 +160,10 @@ module Her
159
160
  # # Called via DELETE "/users/1"
160
161
  def destroy_existing(id, params={})
161
162
  request(params.merge(:_method => method_for(:destroy), :_path => build_request_path(params.merge(primary_key => id)))) do |parsed_data, response|
162
- new(parse(parsed_data[:data]).merge(:_destroyed => true))
163
+ data = parse(parsed_data[:data])
164
+ metadata = parsed_data[:metadata]
165
+ response_errors = parsed_data[:errors]
166
+ new(data.merge(:_destroyed => true, :metadata => metadata, :response_errors => response_errors))
163
167
  end
164
168
  end
165
169
 
data/lib/her/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.3"
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -8,21 +8,24 @@ describe Her::API do
8
8
  describe "#setup" do
9
9
  context "when setting custom middleware" do
10
10
  before do
11
- class Foo; end;
12
- class Bar; end;
11
+ class Foo; end
12
+ class Bar; end
13
13
 
14
- subject.setup :url => "https://api.example.com" do |connection|
14
+ subject.setup url: "https://api.example.com" do |connection|
15
15
  connection.use Foo
16
16
  connection.use Bar
17
17
  end
18
18
  end
19
19
 
20
- specify { subject.connection.builder.handlers.should == [Foo, Bar] }
20
+ specify { expect(subject.connection.builder.handlers).to eq([Foo, Bar]) }
21
21
  end
22
22
 
23
23
  context "when setting custom options" do
24
- before { subject.setup :foo => { :bar => "baz" }, :url => "https://api.example.com" }
25
- its(:options) { should == { :foo => { :bar => "baz" }, :url => "https://api.example.com" } }
24
+ before { subject.setup foo: { bar: "baz" }, url: "https://api.example.com" }
25
+
26
+ describe "#options" do
27
+ it { expect(subject.options).to eq(foo: { bar: "baz" }, url: "https://api.example.com") }
28
+ end
26
29
  end
27
30
  end
28
31
 
@@ -30,83 +33,83 @@ describe Her::API do
30
33
  before do
31
34
  class SimpleParser < Faraday::Response::Middleware
32
35
  def on_complete(env)
33
- env[:body] = { :data => env[:body] }
36
+ env[:body] = { data: env[:body] }
34
37
  end
35
38
  end
36
39
  end
37
40
 
38
41
  context "making HTTP requests" do
39
- let(:parsed_data) { subject.request(:_method => :get, :_path => "/foo")[:parsed_data] }
42
+ let(:parsed_data) { subject.request(_method: :get, _path: "/foo")[:parsed_data] }
40
43
  before do
41
- subject.setup :url => "https://api.example.com" do |builder|
44
+ subject.setup url: "https://api.example.com" do |builder|
42
45
  builder.use SimpleParser
43
- builder.adapter(:test) { |stub| stub.get("/foo") { |env| [200, {}, "Foo, it is."] } }
46
+ builder.adapter(:test) { |stub| stub.get("/foo") { [200, {}, "Foo, it is."] } }
44
47
  end
45
48
  end
46
49
 
47
- specify { parsed_data[:data].should == "Foo, it is." }
50
+ specify { expect(parsed_data[:data]).to eq("Foo, it is.") }
48
51
  end
49
52
 
50
53
  context "making HTTP requests while specifying custom HTTP headers" do
51
- let(:parsed_data) { subject.request(:_method => :get, :_path => "/foo", :_headers => { "X-Page" => 2 })[:parsed_data] }
54
+ let(:parsed_data) { subject.request(_method: :get, _path: "/foo", _headers: { "X-Page" => 2 })[:parsed_data] }
52
55
 
53
56
  before do
54
- subject.setup :url => "https://api.example.com" do |builder|
57
+ subject.setup url: "https://api.example.com" do |builder|
55
58
  builder.use SimpleParser
56
- builder.adapter(:test) { |stub| stub.get("/foo") { |env| [200, {}, "Foo, it is page #{env[:request_headers]["X-Page"]}."] } }
59
+ builder.adapter(:test) { |stub| stub.get("/foo") { |env| [200, {}, "Foo, it is page #{env[:request_headers]['X-Page']}."] } }
57
60
  end
58
61
  end
59
62
 
60
- specify { parsed_data[:data].should == "Foo, it is page 2." }
63
+ specify { expect(parsed_data[:data]).to eq("Foo, it is page 2.") }
61
64
  end
62
65
 
63
66
  context "parsing a request with the default parser" do
64
- let(:parsed_data) { subject.request(:_method => :get, :_path => "users/1")[:parsed_data] }
67
+ let(:parsed_data) { subject.request(_method: :get, _path: "users/1")[:parsed_data] }
65
68
  before do
66
- subject.setup :url => "https://api.example.com" do |builder|
69
+ subject.setup url: "https://api.example.com" do |builder|
67
70
  builder.use Her::Middleware::FirstLevelParseJSON
68
71
  builder.adapter :test do |stub|
69
- stub.get("/users/1") { |env| [200, {}, MultiJson.dump({ :id => 1, :name => "George Michael Bluth", :errors => ["This is a single error"], :metadata => { :page => 1, :per_page => 10 } })] }
72
+ stub.get("/users/1") { [200, {}, MultiJson.dump(id: 1, name: "George Michael Bluth", errors: ["This is a single error"], metadata: { page: 1, per_page: 10 })] }
70
73
  end
71
74
  end
72
75
  end
73
76
 
74
77
  specify do
75
- parsed_data[:data].should == { :id => 1, :name => "George Michael Bluth" }
76
- parsed_data[:errors].should == ["This is a single error"]
77
- parsed_data[:metadata].should == { :page => 1, :per_page => 10 }
78
+ expect(parsed_data[:data]).to eq(id: 1, name: "George Michael Bluth")
79
+ expect(parsed_data[:errors]).to eq(["This is a single error"])
80
+ expect(parsed_data[:metadata]).to eq(page: 1, per_page: 10)
78
81
  end
79
82
  end
80
83
 
81
84
  context "parsing a request with a custom parser" do
82
- let(:parsed_data) { subject.request(:_method => :get, :_path => "users/1")[:parsed_data] }
85
+ let(:parsed_data) { subject.request(_method: :get, _path: "users/1")[:parsed_data] }
83
86
  before do
84
87
  class CustomParser < Faraday::Response::Middleware
85
88
  def on_complete(env)
86
- json = MultiJson.load(env[:body], :symbolize_keys => true)
89
+ json = MultiJson.load(env[:body], symbolize_keys: true)
87
90
  errors = json.delete(:errors) || []
88
91
  metadata = json.delete(:metadata) || {}
89
92
  env[:body] = {
90
- :data => json,
91
- :errors => errors,
92
- :metadata => metadata,
93
+ data: json,
94
+ errors: errors,
95
+ metadata: metadata
93
96
  }
94
97
  end
95
98
  end
96
99
 
97
- subject.setup :url => "https://api.example.com" do |builder|
100
+ subject.setup url: "https://api.example.com" do |builder|
98
101
  builder.use CustomParser
99
102
  builder.use Faraday::Request::UrlEncoded
100
103
  builder.adapter :test do |stub|
101
- stub.get("/users/1") { |env| [200, {}, MultiJson.dump(:id => 1, :name => "George Michael Bluth")] }
104
+ stub.get("/users/1") { [200, {}, MultiJson.dump(id: 1, name: "George Michael Bluth")] }
102
105
  end
103
106
  end
104
107
  end
105
108
 
106
109
  specify do
107
- parsed_data[:data].should == { :id => 1, :name => "George Michael Bluth" }
108
- parsed_data[:errors].should == []
109
- parsed_data[:metadata].should == {}
110
+ expect(parsed_data[:data]).to eq(id: 1, name: "George Michael Bluth")
111
+ expect(parsed_data[:errors]).to eq([])
112
+ expect(parsed_data[:metadata]).to eq({})
110
113
  end
111
114
  end
112
115
  end
@@ -1,26 +1,41 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Her::Collection do
4
-
5
4
  let(:items) { [1, 2, 3, 4] }
6
- let(:metadata) { { :name => 'Testname' } }
7
- let(:errors) { { :name => ['not_present'] } }
5
+ let(:metadata) { { name: "Testname" } }
6
+ let(:errors) { { name: ["not_present"] } }
8
7
 
9
8
  describe "#new" do
10
9
  context "without parameters" do
11
10
  subject { Her::Collection.new }
12
11
 
13
- it { should eq([]) }
14
- its(:metadata) { should eq({}) }
15
- its(:errors) { should eq({}) }
12
+ it { is_expected.to eq([]) }
13
+
14
+ describe "#metadata" do
15
+ subject { super().metadata }
16
+ it { is_expected.to eq({}) }
17
+ end
18
+
19
+ describe "#errors" do
20
+ subject { super().errors }
21
+ it { is_expected.to eq({}) }
22
+ end
16
23
  end
17
24
 
18
25
  context "with parameters" do
19
26
  subject { Her::Collection.new(items, metadata, errors) }
20
27
 
21
- it { should eq([1,2,3,4]) }
22
- its(:metadata) { should eq({ :name => 'Testname' }) }
23
- its(:errors) { should eq({ :name => ['not_present'] }) }
28
+ it { is_expected.to eq([1, 2, 3, 4]) }
29
+
30
+ describe "#metadata" do
31
+ subject { super().metadata }
32
+ it { is_expected.to eq(name: "Testname") }
33
+ end
34
+
35
+ describe "#errors" do
36
+ subject { super().errors }
37
+ it { is_expected.to eq(name: ["not_present"]) }
38
+ end
24
39
  end
25
40
  end
26
41
  end
@@ -1,163 +1,166 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Her::JsonApi::Model do
4
4
  before do
5
- Her::API.setup :url => "https://api.example.com" do |connection|
5
+ Her::API.setup url: "https://api.example.com" do |connection|
6
6
  connection.use Her::Middleware::JsonApiParser
7
7
  connection.adapter :test do |stub|
8
- stub.get("/users/1") do |env|
9
- [
8
+ stub.get("/users/1") do
9
+ [
10
10
  200,
11
11
  {},
12
12
  {
13
13
  data: {
14
14
  id: 1,
15
- type: 'users',
15
+ type: "users",
16
16
  attributes: {
17
- name: "Roger Federer",
18
- },
17
+ name: "Roger Federer"
18
+ }
19
19
  }
20
-
20
+
21
21
  }.to_json
22
- ]
22
+ ]
23
23
  end
24
24
 
25
- stub.get("/users") do |env|
26
- [
25
+ stub.get("/users") do
26
+ [
27
27
  200,
28
28
  {},
29
29
  {
30
30
  data: [
31
31
  {
32
32
  id: 1,
33
- type: 'users',
33
+ type: "users",
34
34
  attributes: {
35
- name: "Roger Federer",
36
- },
37
- },
35
+ name: "Roger Federer"
36
+ }
37
+ },
38
38
  {
39
39
  id: 2,
40
- type: 'users',
40
+ type: "users",
41
41
  attributes: {
42
- name: "Kei Nishikori",
43
- },
42
+ name: "Kei Nishikori"
43
+ }
44
44
  }
45
45
  ]
46
46
  }.to_json
47
- ]
47
+ ]
48
48
  end
49
49
 
50
- stub.post("/users", data: {
51
- type: 'users',
50
+ stub.post("/users", data:
51
+ {
52
+ type: "users",
52
53
  attributes: {
53
- name: "Jeremy Lin",
54
- },
55
- }) do |env|
56
- [
54
+ name: "Jeremy Lin"
55
+ }
56
+ }) do
57
+ [
57
58
  201,
58
59
  {},
59
60
  {
60
61
  data: {
61
62
  id: 3,
62
- type: 'users',
63
+ type: "users",
63
64
  attributes: {
64
- name: 'Jeremy Lin',
65
- },
65
+ name: "Jeremy Lin"
66
+ }
66
67
  }
67
-
68
+
68
69
  }.to_json
69
- ]
70
+ ]
70
71
  end
71
72
 
72
- stub.patch("/users/1", data: {
73
- type: 'users',
73
+ stub.patch("/users/1", data:
74
+ {
75
+ type: "users",
74
76
  id: 1,
75
77
  attributes: {
76
- name: "Fed GOAT",
77
- },
78
- }) do |env|
79
- [
78
+ name: "Fed GOAT"
79
+ }
80
+ }) do
81
+ [
80
82
  200,
81
83
  {},
82
84
  {
83
85
  data: {
84
86
  id: 1,
85
- type: 'users',
87
+ type: "users",
86
88
  attributes: {
87
- name: 'Fed GOAT',
88
- },
89
+ name: "Fed GOAT"
90
+ }
89
91
  }
90
-
92
+
91
93
  }.to_json
92
- ]
94
+ ]
93
95
  end
94
96
 
95
- stub.delete("/users/1") { |env|
96
- [ 204, {}, {}, ]
97
- }
97
+ stub.delete("/users/1") do
98
+ [204, {}, {}]
99
+ end
98
100
  end
99
-
100
101
  end
101
102
 
102
103
  spawn_model("Foo::User", type: Her::JsonApi::Model)
103
104
  end
104
105
 
105
- it 'allows configuration of type' do
106
+ it "allows configuration of type" do
106
107
  spawn_model("Foo::Bar", type: Her::JsonApi::Model) do
107
108
  type :foobars
108
109
  end
109
110
 
110
- expect(Foo::Bar.instance_variable_get('@type')).to eql('foobars')
111
+ expect(Foo::Bar.instance_variable_get("@type")).to eql("foobars")
111
112
  end
112
113
 
113
- it 'finds models by id' do
114
+ it "finds models by id" do
114
115
  user = Foo::User.find(1)
115
116
  expect(user.attributes).to eql(
116
- 'id' => 1,
117
- 'name' => 'Roger Federer',
117
+ "id" => 1,
118
+ "name" => "Roger Federer"
118
119
  )
119
120
  end
120
121
 
121
- it 'finds a collection of models' do
122
+ it "finds a collection of models" do
122
123
  users = Foo::User.all
123
- expect(users.map(&:attributes)).to match_array([
124
- {
125
- 'id' => 1,
126
- 'name' => 'Roger Federer',
127
- },
128
- {
129
- 'id' => 2,
130
- 'name' => 'Kei Nishikori',
131
- }
132
- ])
124
+ expect(users.map(&:attributes)).to match_array(
125
+ [
126
+ {
127
+ "id" => 1,
128
+ "name" => "Roger Federer"
129
+ },
130
+ {
131
+ "id" => 2,
132
+ "name" => "Kei Nishikori"
133
+ }
134
+ ]
135
+ )
133
136
  end
134
137
 
135
- it 'creates a Foo::User' do
136
- user = Foo::User.new(name: 'Jeremy Lin')
138
+ it "creates a Foo::User" do
139
+ user = Foo::User.new(name: "Jeremy Lin")
137
140
  user.save
138
141
  expect(user.attributes).to eql(
139
- 'id' => 3,
140
- 'name' => 'Jeremy Lin',
142
+ "id" => 3,
143
+ "name" => "Jeremy Lin"
141
144
  )
142
145
  end
143
146
 
144
- it 'updates a Foo::User' do
147
+ it "updates a Foo::User" do
145
148
  user = Foo::User.find(1)
146
- user.name = 'Fed GOAT'
149
+ user.name = "Fed GOAT"
147
150
  user.save
148
151
  expect(user.attributes).to eql(
149
- 'id' => 1,
150
- 'name' => 'Fed GOAT',
152
+ "id" => 1,
153
+ "name" => "Fed GOAT"
151
154
  )
152
155
  end
153
156
 
154
- it 'destroys a Foo::User' do
157
+ it "destroys a Foo::User" do
155
158
  user = Foo::User.find(1)
156
159
  expect(user.destroy).to be_destroyed
157
160
  end
158
161
 
159
- context 'undefined methods' do
160
- it 'removes methods that are not compatible with json api' do
162
+ context "undefined methods" do
163
+ it "removes methods that are not compatible with json api" do
161
164
  [:parse_root_in_json, :include_root_in_json, :root_element, :primary_key].each do |method|
162
165
  expect { Foo::User.new.send(method, :foo) }.to raise_error NoMethodError, "Her::JsonApi::Model does not support the #{method} configuration option"
163
166
  end
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
  describe Her::Middleware::AcceptJSON do
5
5
  it "adds an Accept header" do
6
6
  described_class.new.add_header({}).tap do |headers|
7
- headers["Accept"].should == "application/json"
7
+ expect(headers["Accept"]).to eq("application/json")
8
8
  end
9
9
  end
10
10
  end
@@ -7,55 +7,55 @@ describe Her::Middleware::FirstLevelParseJSON do
7
7
  let(:body_with_errors) { "{\"id\": 1, \"name\": \"Tobias Fünke\", \"errors\": { \"name\": [ \"not_valid\", \"should_be_present\" ] }, \"metadata\": 3}" }
8
8
  let(:body_with_malformed_json) { "wut." }
9
9
  let(:body_with_invalid_json) { "true" }
10
- let(:empty_body) { '' }
10
+ let(:empty_body) { "" }
11
11
  let(:nil_body) { nil }
12
12
 
13
13
  it "parses body as json" do
14
14
  subject.parse(body_without_errors).tap do |json|
15
- json[:data].should == { :id => 1, :name => "Tobias Fünke" }
16
- json[:metadata].should == 3
15
+ expect(json[:data]).to eq(id: 1, name: "Tobias Fünke")
16
+ expect(json[:metadata]).to eq(3)
17
17
  end
18
18
  end
19
19
 
20
20
  it "parses :body key as json in the env hash" do
21
- env = { :body => body_without_errors }
21
+ env = { body: body_without_errors }
22
22
  subject.on_complete(env)
23
23
  env[:body].tap do |json|
24
- json[:data].should == { :id => 1, :name => "Tobias Fünke" }
25
- json[:metadata].should == 3
24
+ expect(json[:data]).to eq(id: 1, name: "Tobias Fünke")
25
+ expect(json[:metadata]).to eq(3)
26
26
  end
27
27
  end
28
28
 
29
- it 'ensures the errors are a hash if there are no errors' do
30
- subject.parse(body_without_errors)[:errors].should eq({})
29
+ it "ensures the errors are a hash if there are no errors" do
30
+ expect(subject.parse(body_without_errors)[:errors]).to eq({})
31
31
  end
32
32
 
33
- it 'ensures the errors are a hash if there are no errors' do
34
- subject.parse(body_with_errors)[:errors].should eq({:name => [ 'not_valid', 'should_be_present']})
33
+ it "ensures the errors are a hash if there are no errors" do
34
+ expect(subject.parse(body_with_errors)[:errors]).to eq(name: %w(not_valid should_be_present))
35
35
  end
36
36
 
37
- it 'ensures that malformed JSON throws an exception' do
37
+ it "ensures that malformed JSON throws an exception" do
38
38
  expect { subject.parse(body_with_malformed_json) }.to raise_error(Her::Errors::ParseError, 'Response from the API must behave like a Hash or an Array (last JSON response was "wut.")')
39
39
  end
40
40
 
41
- it 'ensures that invalid JSON throws an exception' do
41
+ it "ensures that invalid JSON throws an exception" do
42
42
  expect { subject.parse(body_with_invalid_json) }.to raise_error(Her::Errors::ParseError, 'Response from the API must behave like a Hash or an Array (last JSON response was "true")')
43
43
  end
44
44
 
45
- it 'ensures that a nil response returns an empty hash' do
46
- subject.parse(nil_body)[:data].should eq({})
45
+ it "ensures that a nil response returns an empty hash" do
46
+ expect(subject.parse(nil_body)[:data]).to eq({})
47
47
  end
48
48
 
49
- it 'ensures that an empty response returns an empty hash' do
50
- subject.parse(empty_body)[:data].should eq({})
49
+ it "ensures that an empty response returns an empty hash" do
50
+ expect(subject.parse(empty_body)[:data]).to eq({})
51
51
  end
52
52
 
53
- context 'with status code 204' do
54
- it 'returns an empty body' do
55
- env = { :status => 204 }
53
+ context "with status code 204" do
54
+ it "returns an empty body" do
55
+ env = { status: 204 }
56
56
  subject.on_complete(env)
57
57
  env[:body].tap do |json|
58
- json[:data].should == { }
58
+ expect(json[:data]).to eq({})
59
59
  end
60
60
  end
61
61
  end
@@ -12,21 +12,20 @@ describe Her::Middleware::JsonApiParser do
12
12
  subject.on_complete(env)
13
13
  env.fetch(:body).tap do |json|
14
14
  expect(json[:data]).to eql(
15
- :type => "foo",
16
- :id => "bar",
17
- :attributes => { :baz => "qux" }
15
+ type: "foo",
16
+ id: "bar",
17
+ attributes: { baz: "qux" }
18
18
  )
19
19
  expect(json[:errors]).to eql([])
20
- expect(json[:metadata]).to eql(:api => "json api")
20
+ expect(json[:metadata]).to eql(api: "json api")
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
- #context "with invalid JSON body" do
25
+ # context "with invalid JSON body" do
26
26
  # let(:body) { '"foo"' }
27
27
  # it 'ensures that invalid JSON throws an exception' do
28
28
  # expect { subject.parse(body) }.to raise_error(Her::Errors::ParseError, 'Response from the API must behave like a Hash or an Array (last JSON response was "\"foo\"")')
29
29
  # end
30
- #end
31
-
30
+ # end
32
31
  end