izi_json_ld 1.0.8 → 1.0.9
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/app/entities/person_entity.rb +4 -0
- data/app/entities/review_entity.rb +15 -1
- data/lib/izi_json_ld/version.rb +1 -1
- data/spec/dummy/log/test.log +1015 -23097
- data/spec/entities/person_entity_spec.rb +6 -0
- data/spec/entities/review_entity_spec.rb +43 -13
- metadata +2 -4
- data/spec/dummy/log/development.log +0 -16
@@ -7,6 +7,12 @@ RSpec.describe PersonEntity do
|
|
7
7
|
expect(item.to_json).to be_present
|
8
8
|
end
|
9
9
|
|
10
|
+
it 'should have @context' do
|
11
|
+
expect(item.as_json).to have_key '@context'
|
12
|
+
expect(item.as_json['@context']).to be_present
|
13
|
+
expect(item.as_json['@context']).to include 'schema.org'
|
14
|
+
end
|
15
|
+
|
10
16
|
it 'should have @type' do
|
11
17
|
expect(item.as_json).to have_key '@type'
|
12
18
|
expect(item.as_json['@type']).to be_present
|
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
RSpec.describe ReviewEntity do
|
4
4
|
let(:time) { 1.week.ago }
|
5
|
-
let(:
|
6
|
-
|
5
|
+
let(:item_data) do
|
6
|
+
{
|
7
7
|
author: 'John',
|
8
8
|
description: 'TODO',
|
9
9
|
reviewRating: { ratingValue: 3 }
|
10
|
-
|
10
|
+
}
|
11
11
|
end
|
12
|
+
let(:item) { described_class.new(item_data) }
|
12
13
|
|
13
14
|
it 'should be searializable as hash' do
|
14
15
|
expect(item.as_json).to be_present
|
@@ -28,17 +29,46 @@ RSpec.describe ReviewEntity do
|
|
28
29
|
expect(item.as_json['@type']).to eq 'Review'
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
context 'datePublished' do
|
33
|
+
it 'should allow set datePublished as datetime' do
|
34
|
+
i2 = described_class.new(datePublished: time)
|
35
|
+
obj = JSON.parse(i2.to_json)
|
36
|
+
|
37
|
+
new_time = Time.zone.parse(obj['datePublished'])
|
38
|
+
expect(new_time).to be_within(1.second).of(time)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should allow set datePublished as iso8601' do
|
42
|
+
i2 = described_class.new(datePublished: time.iso8601)
|
43
|
+
obj = JSON.parse(i2.to_json)
|
44
|
+
|
45
|
+
new_time = Time.zone.parse(obj['datePublished'])
|
46
|
+
expect(new_time).to be_within(1.second).of(time)
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
context 'author' do
|
51
|
+
it 'should parse author name as person' do
|
52
|
+
author = item.as_json['author']
|
53
|
+
expect(author).to be_a Hash
|
54
|
+
expect(author['@type']).to eq 'Person'
|
55
|
+
expect(author['name']).to eq item.author
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should allow to pass author hash' do
|
59
|
+
raw = described_class.new(item_data.merge(author: { person_name: 'Kenny' }))
|
60
|
+
author = raw.as_json['author']
|
61
|
+
expect(author).to be_a Hash
|
62
|
+
expect(author['@type']).to eq 'Person'
|
63
|
+
expect(author['name']).to eq raw.author.name
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should allow to pass author hash (Organization)' do
|
67
|
+
raw = described_class.new(item_data.merge(author: { name: 'Kenny' }))
|
68
|
+
author = raw.as_json['author']
|
69
|
+
expect(author).to be_a Hash
|
70
|
+
expect(author['@type']).to eq 'Organization'
|
71
|
+
expect(author['name']).to eq raw.author.name
|
72
|
+
end
|
43
73
|
end
|
44
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: izi_json_ld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IzikAJ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- spec/dummy/config/routes.rb
|
94
94
|
- spec/dummy/db/development.sqlite3
|
95
95
|
- spec/dummy/db/test.sqlite3
|
96
|
-
- spec/dummy/log/development.log
|
97
96
|
- spec/dummy/log/test.log
|
98
97
|
- spec/dummy/tmp/development_secret.txt
|
99
98
|
- spec/entities/aggregate_rating_entity_spec.rb
|
@@ -156,7 +155,6 @@ test_files:
|
|
156
155
|
- spec/dummy/db/test.sqlite3
|
157
156
|
- spec/dummy/db/development.sqlite3
|
158
157
|
- spec/dummy/log/test.log
|
159
|
-
- spec/dummy/log/development.log
|
160
158
|
- spec/dummy/tmp/development_secret.txt
|
161
159
|
- spec/rails_helper.rb
|
162
160
|
- spec/entities/aggregate_rating_entity_spec.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
2
|
-
↳ bin/rails:4
|
3
|
-
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
4
|
-
↳ bin/rails:4
|
5
|
-
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)[0m
|
6
|
-
↳ bin/rails:4
|
7
|
-
[1m[36mActiveRecord::InternalMetadata Load (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
8
|
-
↳ bin/rails:4
|
9
|
-
[1m[35m (0.1ms)[0m [1m[36mbegin transaction[0m
|
10
|
-
↳ bin/rails:4
|
11
|
-
[1m[36mActiveRecord::InternalMetadata Create (0.4ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "development"], ["created_at", "2021-03-17 08:43:32.839496"], ["updated_at", "2021-03-17 08:43:32.839496"]]
|
12
|
-
↳ bin/rails:4
|
13
|
-
[1m[35m (0.7ms)[0m [1m[36mcommit transaction[0m
|
14
|
-
↳ bin/rails:4
|
15
|
-
[1m[35m (0.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
16
|
-
↳ bin/rails:4
|