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.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/.rubocop.yml +1291 -0
- data/.travis.yml +1 -0
- data/README.md +6 -0
- data/UPGRADE.md +1 -1
- data/her.gemspec +3 -5
- data/lib/her/model/associations/association_proxy.rb +1 -2
- data/lib/her/model/orm.rb +7 -3
- data/lib/her/version.rb +1 -1
- data/spec/api_spec.rb +34 -31
- data/spec/collection_spec.rb +25 -10
- data/spec/json_api/model_spec.rb +75 -72
- data/spec/middleware/accept_json_spec.rb +1 -1
- data/spec/middleware/first_level_parse_json_spec.rb +20 -20
- data/spec/middleware/json_api_parser_spec.rb +6 -7
- data/spec/middleware/second_level_parse_json_spec.rb +8 -9
- data/spec/model/associations/association_proxy_spec.rb +2 -5
- data/spec/model/associations_spec.rb +199 -158
- data/spec/model/attributes_spec.rb +98 -99
- data/spec/model/callbacks_spec.rb +58 -26
- data/spec/model/dirty_spec.rb +30 -29
- data/spec/model/http_spec.rb +67 -35
- data/spec/model/introspection_spec.rb +26 -22
- data/spec/model/nested_attributes_spec.rb +31 -31
- data/spec/model/orm_spec.rb +183 -146
- data/spec/model/parse_spec.rb +77 -77
- data/spec/model/paths_spec.rb +109 -109
- data/spec/model/relation_spec.rb +68 -68
- data/spec/model/validations_spec.rb +6 -6
- data/spec/model_spec.rb +24 -11
- data/spec/spec_helper.rb +2 -3
- data/spec/support/macros/model_macros.rb +2 -2
- metadata +10 -37
@@ -8,28 +8,27 @@ describe Her::Middleware::SecondLevelParseJSON do
|
|
8
8
|
let(:body) { "{\"data\": 1, \"errors\": 2, \"metadata\": 3}" }
|
9
9
|
it "parses body as json" do
|
10
10
|
subject.parse(body).tap do |json|
|
11
|
-
json[:data].
|
12
|
-
json[:errors].
|
13
|
-
json[:metadata].
|
11
|
+
expect(json[:data]).to eq(1)
|
12
|
+
expect(json[:errors]).to eq(2)
|
13
|
+
expect(json[:metadata]).to eq(3)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it "parses :body key as json in the env hash" do
|
18
|
-
env = { :
|
18
|
+
env = { body: body }
|
19
19
|
subject.on_complete(env)
|
20
20
|
env[:body].tap do |json|
|
21
|
-
json[:data].
|
22
|
-
json[:errors].
|
23
|
-
json[:metadata].
|
21
|
+
expect(json[:data]).to eq(1)
|
22
|
+
expect(json[:errors]).to eq(2)
|
23
|
+
expect(json[:metadata]).to eq(3)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context "with invalid JSON body" do
|
29
29
|
let(:body) { '"foo"' }
|
30
|
-
it
|
30
|
+
it "ensures that invalid JSON throws an exception" do
|
31
31
|
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\"")')
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
@@ -8,8 +8,8 @@ describe Her::Model::Associations::AssociationProxy do
|
|
8
8
|
builder.use Her::Middleware::FirstLevelParseJSON
|
9
9
|
builder.use Faraday::Request::UrlEncoded
|
10
10
|
builder.adapter :test do |stub|
|
11
|
-
stub.get("/users/1") {
|
12
|
-
stub.get("/users/1/fish") {
|
11
|
+
stub.get("/users/1") { [200, {}, { id: 1, name: "Tobias Fünke" }.to_json] }
|
12
|
+
stub.get("/users/1/fish") { [200, {}, { id: 1, name: "Tobias's Fish" }.to_json] }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
spawn_model "User" do
|
@@ -26,6 +26,3 @@ describe Her::Model::Associations::AssociationProxy do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|