izi_json_ld 1.0.5 → 1.0.6

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.
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe FaqPageEntity do
4
+ let(:item) { described_class.new(mainEntity: []) }
5
+
6
+ it 'should be searializable as hash' do
7
+ expect(item.as_json).to be_present
8
+ end
9
+
10
+ it 'should be searializable as string' do
11
+ expect(item.to_json).to be_present
12
+ end
13
+
14
+ it 'should return html_safe string' do
15
+ expect(item.to_json).to be_html_safe
16
+ end
17
+
18
+ it 'should have @type' do
19
+ expect(item.as_json).to have_key '@type'
20
+ expect(item.as_json['@type']).to be_present
21
+ expect(item.as_json['@type']).to eq 'FAQPage'
22
+ end
23
+
24
+ context 'filled' do
25
+ let(:item) do
26
+ described_class.new(
27
+ mainEntity: [
28
+ { name: 'Question 1', acceptedAnswer: { text: 'Test answer 1' } },
29
+ { name: 'Question 2', acceptedAnswer: { text: 'Test answer 2' } },
30
+ { name: 'Question 3', acceptedAnswer: { text: 'Test answer 3' } }
31
+ ]
32
+ )
33
+ end
34
+ let(:singular) do
35
+ described_class.new(
36
+ mainEntity: {
37
+ name: 'Sing-Question', acceptedAnswer: { text: 'Sing-Answer' }
38
+ }
39
+ )
40
+ end
41
+ let(:shortland) do
42
+ described_class.new(
43
+ mainEntity: [
44
+ { name: 'ShortQuestion', answer: 'ShortAnswer' }
45
+ ]
46
+ )
47
+ end
48
+
49
+ it 'should render items' do
50
+ expect(item.as_json).to have_key 'mainEntity'
51
+ expect(item.as_json['mainEntity']).to be_present
52
+ expect(item.as_json['mainEntity'].size).to eq 3
53
+ end
54
+
55
+ it 'should render answer properly' do
56
+ answer = item.as_json.dig('mainEntity', 0)
57
+ expect(answer['name']).to eq 'Question 1'
58
+ expect(answer.dig('acceptedAnswer', 'text')).to eq 'Test answer 1'
59
+ end
60
+
61
+ it 'should render singular' do
62
+ answer = singular.as_json['mainEntity']
63
+ expect(answer['name']).to eq 'Sing-Question'
64
+ expect(answer.dig('acceptedAnswer', 'text')).to eq 'Sing-Answer'
65
+ end
66
+
67
+ it 'should accept name/answer shortland items' do
68
+ answer = shortland.as_json.dig('mainEntity', 0)
69
+
70
+ expect(answer).to be_present
71
+ expect(answer['name']).to eq 'ShortQuestion'
72
+ expect(answer.dig('acceptedAnswer', 'text')).to eq 'ShortAnswer'
73
+ end
74
+ end
75
+ 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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - IzikAJ
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2021-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -48,15 +48,18 @@ extra_rdoc_files: []
48
48
  files:
49
49
  - README.rdoc
50
50
  - app/entities/aggregate_rating_entity.rb
51
+ - app/entities/answer_entity.rb
51
52
  - app/entities/application_entity.rb
52
53
  - app/entities/article_entity.rb
53
54
  - app/entities/breadcrumb_list_entity.rb
55
+ - app/entities/faq_page_entity.rb
54
56
  - app/entities/image_object_entity.rb
55
57
  - app/entities/list_item_entity.rb
56
58
  - app/entities/offer_entity.rb
57
59
  - app/entities/organization_entity.rb
58
60
  - app/entities/person_entity.rb
59
61
  - app/entities/product_entity.rb
62
+ - app/entities/question_entity.rb
60
63
  - app/entities/rating_entity.rb
61
64
  - app/entities/review_entity.rb
62
65
  - app/entities/web_page_entity.rb
@@ -96,6 +99,7 @@ files:
96
99
  - spec/entities/aggregate_rating_entity_spec.rb
97
100
  - spec/entities/article_entity_spec.rb
98
101
  - spec/entities/breadcrumb_list_entity_spec.rb
102
+ - spec/entities/faq_page_entity_spec.rb
99
103
  - spec/entities/offer_entity_spec.rb
100
104
  - spec/entities/product_entity_spec.rb
101
105
  - spec/entities/rating_entity_spec.rb
@@ -121,7 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
125
  - !ruby/object:Gem::Version
122
126
  version: '0'
123
127
  requirements: []
124
- rubygems_version: 3.1.2
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.14.4
125
130
  signing_key:
126
131
  specification_version: 4
127
132
  summary: Izi Lightup
@@ -156,6 +161,7 @@ test_files:
156
161
  - spec/entities/aggregate_rating_entity_spec.rb
157
162
  - spec/entities/review_entity_spec.rb
158
163
  - spec/entities/breadcrumb_list_entity_spec.rb
164
+ - spec/entities/faq_page_entity_spec.rb
159
165
  - spec/entities/rating_entity_spec.rb
160
166
  - spec/entities/offer_entity_spec.rb
161
167
  - spec/entities/article_entity_spec.rb