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.
@@ -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(:item) do
6
- described_class.new(
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
- it 'should allow set datePublished as datetime' do
32
- i2 = described_class.new(datePublished: time)
33
- obj = JSON.parse(i2.to_json)
34
- newTime = Time.zone.parse(obj['datePublished'])
35
- expect(newTime).to be_within(1.second).of(time)
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
- it 'should allow set datePublished as iso8601' do
39
- i2 = described_class.new(datePublished: time.iso8601)
40
- obj = JSON.parse(i2.to_json)
41
- newTime = Time.zone.parse(obj['datePublished'])
42
- expect(newTime).to be_within(1.second).of(time)
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.8
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-05-26 00:00:00.000000000 Z
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
-  (0.1ms) SELECT sqlite_version(*)
2
- ↳ bin/rails:4
3
-  (1.2ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
4
- ↳ bin/rails:4
5
-  (1.2ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
6
- ↳ bin/rails:4
7
- ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
8
- ↳ bin/rails:4
9
-  (0.1ms) begin transaction
10
- ↳ bin/rails:4
11
- ActiveRecord::InternalMetadata Create (0.4ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["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
-  (0.7ms) commit transaction
14
- ↳ bin/rails:4
15
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
16
- ↳ bin/rails:4