izi_json_ld 1.0.3 → 1.0.4

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,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe ArticleEntity do
4
+ let(:item) do
5
+ described_class.new(
6
+ headline: 'Test Article Title',
7
+ mainEntityOfPage: {
8
+ web_page: 'https://exampla.com/blog/page'
9
+ }
10
+ )
11
+ end
12
+
13
+ it 'should be searializable as hash' do
14
+ expect(item.as_json).to be_present
15
+ end
16
+
17
+ it 'should have @type' do
18
+ expect(item.as_json).to have_key '@type'
19
+ expect(item.as_json['@type']).to be_present
20
+ expect(item.as_json['@type']).to eq 'Article'
21
+ end
22
+
23
+ it 'should have @context at root entity' do
24
+ expect(item.as_json).to have_key '@context'
25
+ expect(item.as_json['@context']).to be_present
26
+ expect(item.as_json['@context']).to include 'schema.org'
27
+ end
28
+
29
+ it 'possible to set mainEntityOfPage as URL' do
30
+ custom = described_class.new(headline: 'Title', mainEntityOfPage: 'https://exampla.com/blog/page')
31
+ expect(custom.as_json.dig('mainEntityOfPage')).to be_present
32
+ expect(custom.as_json.dig('mainEntityOfPage')).to eq 'https://exampla.com/blog/page'
33
+ end
34
+
35
+ context 'filled Article' do
36
+ let(:item) do
37
+ described_class.new(
38
+ mainEntityOfPage: {
39
+ web_page: 'https://exampla.com/blog/page'
40
+ },
41
+ headline: 'Test Article Title',
42
+ description: 'Test Article Description',
43
+ image: 'https://exampla.com/blog/page.png',
44
+ author: { name: 'TestUser' },
45
+ publisher: {
46
+ name: 'TestInc',
47
+ logo: { url: 'https://exampla.com/logo.png' }
48
+ },
49
+ datePublished: 1.week.ago,
50
+ dateModified: 2.days.ago
51
+ )
52
+ end
53
+
54
+ it 'should not fail' do
55
+ expect do
56
+ item.dump
57
+ item.as_json
58
+ item.to_json
59
+ end.not_to raise_exception
60
+ end
61
+
62
+ [
63
+ ['Publisher name', %w[publisher name], 'TestInc'],
64
+ ['Main Entity id', %w[mainEntityOfPage @id], 'https://exampla.com/blog/page'],
65
+ ['Publisher type', %w[publisher @type], 'Organization'],
66
+ ['Publisher logo type', %w[publisher logo @type], 'ImageObject'],
67
+ ['Publisher logo', %w[publisher logo url], 'https://exampla.com/logo.png'],
68
+ ['Post image', %w[image], 'https://exampla.com/blog/page.png'],
69
+ ['Author name', %w[author name], 'TestUser']
70
+ ].each do |(desc, path, val)|
71
+ it "should render #{desc}[#{path.join('.')}]" do
72
+ expect(item.as_json.dig(*path)).to be_present
73
+ expect(item.as_json.dig(*path)).to eq val
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe BreadcrumbListEntity do
4
+ let(:item) { described_class.new(itemListElement: []) }
5
+
6
+ it 'should be searializable as hash' do
7
+ expect(item.as_json).to be_present
8
+ end
9
+
10
+ it 'should have @type' do
11
+ expect(item.as_json).to have_key '@type'
12
+ expect(item.as_json['@type']).to be_present
13
+ expect(item.as_json['@type']).to eq 'BreadcrumbList'
14
+ end
15
+
16
+ it 'should have @context at root entity' do
17
+ expect(item.as_json).to have_key '@context'
18
+ expect(item.as_json['@context']).to be_present
19
+ expect(item.as_json['@context']).to include 'schema.org'
20
+ end
21
+
22
+ context 'with simple item' do
23
+ let(:item) do
24
+ described_class.new(itemListElement: { name: 'Home', position: 0, item: 'https://example.com' })
25
+ end
26
+
27
+ it 'should not fail' do
28
+ expect do
29
+ item.dump
30
+ item.as_json
31
+ item.to_json
32
+ end.not_to raise_exception
33
+ end
34
+ end
35
+
36
+ context 'with multiple items' do
37
+ let(:item) do
38
+ described_class.new(
39
+ itemListElement: [
40
+ { name: 'Home', position: 0, item: 'https://example.com' },
41
+ { name: 'Blog', position: 1, item: 'https://example.com/blog' },
42
+ { name: 'Post', position: 2, item: 'https://example.com/blog/post' },
43
+ ]
44
+ )
45
+ end
46
+
47
+ it 'should not fail' do
48
+ expect do
49
+ item.dump
50
+ item.as_json
51
+ item.to_json
52
+ end.not_to raise_exception
53
+ end
54
+ end
55
+ end
data/spec/rails_helper.rb CHANGED
@@ -22,25 +22,9 @@ require 'rspec/rails'
22
22
  #
23
23
  # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
24
24
 
25
- # Checks for pending migrations and applies them before tests are run.
26
- # If you are not using ActiveRecord, you can remove these lines.
27
- begin
28
- ActiveRecord::Migration.maintain_test_schema!
29
- rescue ActiveRecord::PendingMigrationError => e
30
- puts e.to_s.strip
31
- exit 1
32
- end
33
25
  RSpec.configure do |config|
34
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
36
-
37
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
38
- # examples within a transaction, remove the following line or assign false
39
- # instead of true.
40
- config.use_transactional_fixtures = true
41
-
42
26
  # You can uncomment this line to turn off ActiveRecord support entirely.
43
- # config.use_active_record = false
27
+ config.use_active_record = false
44
28
 
45
29
  # RSpec Rails can automatically mix in different behaviours to your tests
46
30
  # based on their file location, for example enabling you to call `get` and
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.3
4
+ version: 1.0.4
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-15 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -49,30 +49,29 @@ files:
49
49
  - README.rdoc
50
50
  - app/entities/aggregate_rating_entity.rb
51
51
  - app/entities/application_entity.rb
52
+ - app/entities/article_entity.rb
53
+ - app/entities/breadcrumb_list_entity.rb
54
+ - app/entities/image_object_entity.rb
55
+ - app/entities/list_item_entity.rb
52
56
  - app/entities/offer_entity.rb
57
+ - app/entities/organization_entity.rb
53
58
  - app/entities/product_entity.rb
54
59
  - app/entities/rating_entity.rb
55
60
  - app/entities/review_entity.rb
61
+ - app/entities/web_page_entity.rb
56
62
  - app/helpers/json_ld_helper.rb
57
63
  - lib/izi_json_ld.rb
58
64
  - lib/izi_json_ld/engine.rb
59
65
  - lib/izi_json_ld/extentions/autoload_paths.rb
60
66
  - lib/izi_json_ld/types.rb
67
+ - lib/izi_json_ld/types/date_time.rb
68
+ - lib/izi_json_ld/types/one_or_more.rb
61
69
  - lib/izi_json_ld/version.rb
62
- - spec/dummy/Gemfile
63
- - spec/dummy/Gemfile.lock
64
70
  - spec/dummy/Rakefile
65
71
  - spec/dummy/app/assets/config/manifest.js
66
72
  - spec/dummy/app/controllers/application_controller.rb
67
73
  - spec/dummy/app/helpers/application_helper.rb
68
- - spec/dummy/app/models/application_record.rb
69
74
  - spec/dummy/app/views/layouts/application.html.erb
70
- - spec/dummy/bin/_guard-core
71
- - spec/dummy/bin/guard
72
- - spec/dummy/bin/rails
73
- - spec/dummy/bin/rake
74
- - spec/dummy/bin/rspec
75
- - spec/dummy/bin/setup
76
75
  - spec/dummy/config.ru
77
76
  - spec/dummy/config/application.rb
78
77
  - spec/dummy/config/boot.rb
@@ -88,11 +87,14 @@ files:
88
87
  - spec/dummy/config/initializers/wrap_parameters.rb
89
88
  - spec/dummy/config/puma.rb
90
89
  - spec/dummy/config/routes.rb
90
+ - spec/dummy/db/development.sqlite3
91
91
  - spec/dummy/db/test.sqlite3
92
92
  - spec/dummy/log/development.log
93
93
  - spec/dummy/log/test.log
94
94
  - spec/dummy/tmp/development_secret.txt
95
95
  - spec/entities/aggregate_rating_entity_spec.rb
96
+ - spec/entities/article_entity_spec.rb
97
+ - spec/entities/breadcrumb_list_entity_spec.rb
96
98
  - spec/entities/offer_entity_spec.rb
97
99
  - spec/entities/product_entity_spec.rb
98
100
  - spec/entities/rating_entity_spec.rb
@@ -118,23 +120,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  - !ruby/object:Gem::Version
119
121
  version: '0'
120
122
  requirements: []
121
- rubygems_version: 3.1.2
123
+ rubyforge_project:
124
+ rubygems_version: 2.5.2.3
122
125
  signing_key:
123
126
  specification_version: 4
124
127
  summary: Izi Lightup
125
128
  test_files:
126
129
  - spec/spec_helper.rb
127
- - spec/dummy/app/models/application_record.rb
128
130
  - spec/dummy/app/controllers/application_controller.rb
129
131
  - spec/dummy/app/views/layouts/application.html.erb
130
132
  - spec/dummy/app/assets/config/manifest.js
131
133
  - spec/dummy/app/helpers/application_helper.rb
132
- - spec/dummy/bin/rake
133
- - spec/dummy/bin/setup
134
- - spec/dummy/bin/_guard-core
135
- - spec/dummy/bin/guard
136
- - spec/dummy/bin/rspec
137
- - spec/dummy/bin/rails
138
134
  - spec/dummy/config/routes.rb
139
135
  - spec/dummy/config/environments/production.rb
140
136
  - spec/dummy/config/environments/development.rb
@@ -152,14 +148,15 @@ test_files:
152
148
  - spec/dummy/config.ru
153
149
  - spec/dummy/Rakefile
154
150
  - spec/dummy/db/test.sqlite3
155
- - spec/dummy/Gemfile
151
+ - spec/dummy/db/development.sqlite3
156
152
  - spec/dummy/log/test.log
157
153
  - spec/dummy/log/development.log
158
- - spec/dummy/Gemfile.lock
159
154
  - spec/dummy/tmp/development_secret.txt
160
155
  - spec/rails_helper.rb
161
156
  - spec/entities/aggregate_rating_entity_spec.rb
162
157
  - spec/entities/review_entity_spec.rb
158
+ - spec/entities/breadcrumb_list_entity_spec.rb
163
159
  - spec/entities/rating_entity_spec.rb
164
160
  - spec/entities/offer_entity_spec.rb
161
+ - spec/entities/article_entity_spec.rb
165
162
  - spec/entities/product_entity_spec.rb
data/spec/dummy/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'byebug'
4
- gem 'dry-struct'
5
- gem 'faker'
6
- gem 'rails'
7
- gem 'sqlite3'
8
-
9
- group :test do
10
- gem 'guard', require: false
11
- gem 'guard-rspec', require: false
12
- gem 'rspec'
13
- gem 'rspec-rails'
14
- end
@@ -1,229 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- actioncable (6.1.3)
5
- actionpack (= 6.1.3)
6
- activesupport (= 6.1.3)
7
- nio4r (~> 2.0)
8
- websocket-driver (>= 0.6.1)
9
- actionmailbox (6.1.3)
10
- actionpack (= 6.1.3)
11
- activejob (= 6.1.3)
12
- activerecord (= 6.1.3)
13
- activestorage (= 6.1.3)
14
- activesupport (= 6.1.3)
15
- mail (>= 2.7.1)
16
- actionmailer (6.1.3)
17
- actionpack (= 6.1.3)
18
- actionview (= 6.1.3)
19
- activejob (= 6.1.3)
20
- activesupport (= 6.1.3)
21
- mail (~> 2.5, >= 2.5.4)
22
- rails-dom-testing (~> 2.0)
23
- actionpack (6.1.3)
24
- actionview (= 6.1.3)
25
- activesupport (= 6.1.3)
26
- rack (~> 2.0, >= 2.0.9)
27
- rack-test (>= 0.6.3)
28
- rails-dom-testing (~> 2.0)
29
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
30
- actiontext (6.1.3)
31
- actionpack (= 6.1.3)
32
- activerecord (= 6.1.3)
33
- activestorage (= 6.1.3)
34
- activesupport (= 6.1.3)
35
- nokogiri (>= 1.8.5)
36
- actionview (6.1.3)
37
- activesupport (= 6.1.3)
38
- builder (~> 3.1)
39
- erubi (~> 1.4)
40
- rails-dom-testing (~> 2.0)
41
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
42
- activejob (6.1.3)
43
- activesupport (= 6.1.3)
44
- globalid (>= 0.3.6)
45
- activemodel (6.1.3)
46
- activesupport (= 6.1.3)
47
- activerecord (6.1.3)
48
- activemodel (= 6.1.3)
49
- activesupport (= 6.1.3)
50
- activestorage (6.1.3)
51
- actionpack (= 6.1.3)
52
- activejob (= 6.1.3)
53
- activerecord (= 6.1.3)
54
- activesupport (= 6.1.3)
55
- marcel (~> 0.3.1)
56
- mimemagic (~> 0.3.2)
57
- activesupport (6.1.3)
58
- concurrent-ruby (~> 1.0, >= 1.0.2)
59
- i18n (>= 1.6, < 2)
60
- minitest (>= 5.1)
61
- tzinfo (~> 2.0)
62
- zeitwerk (~> 2.3)
63
- builder (3.2.4)
64
- byebug (11.1.3)
65
- coderay (1.1.3)
66
- concurrent-ruby (1.1.8)
67
- crass (1.0.6)
68
- diff-lcs (1.4.4)
69
- dry-configurable (0.12.1)
70
- concurrent-ruby (~> 1.0)
71
- dry-core (~> 0.5, >= 0.5.0)
72
- dry-container (0.7.2)
73
- concurrent-ruby (~> 1.0)
74
- dry-configurable (~> 0.1, >= 0.1.3)
75
- dry-core (0.5.0)
76
- concurrent-ruby (~> 1.0)
77
- dry-inflector (0.2.0)
78
- dry-logic (1.1.0)
79
- concurrent-ruby (~> 1.0)
80
- dry-core (~> 0.5, >= 0.5)
81
- dry-struct (1.4.0)
82
- dry-core (~> 0.5, >= 0.5)
83
- dry-types (~> 1.5)
84
- ice_nine (~> 0.11)
85
- dry-types (1.5.1)
86
- concurrent-ruby (~> 1.0)
87
- dry-container (~> 0.3)
88
- dry-core (~> 0.5, >= 0.5)
89
- dry-inflector (~> 0.1, >= 0.1.2)
90
- dry-logic (~> 1.0, >= 1.0.2)
91
- erubi (1.10.0)
92
- faker (2.17.0)
93
- i18n (>= 1.6, < 2)
94
- ffi (1.15.0)
95
- formatador (0.2.5)
96
- globalid (0.4.2)
97
- activesupport (>= 4.2.0)
98
- guard (2.16.2)
99
- formatador (>= 0.2.4)
100
- listen (>= 2.7, < 4.0)
101
- lumberjack (>= 1.0.12, < 2.0)
102
- nenv (~> 0.1)
103
- notiffany (~> 0.0)
104
- pry (>= 0.9.12)
105
- shellany (~> 0.0)
106
- thor (>= 0.18.1)
107
- guard-compat (1.2.1)
108
- guard-rspec (4.7.3)
109
- guard (~> 2.1)
110
- guard-compat (~> 1.1)
111
- rspec (>= 2.99.0, < 4.0)
112
- i18n (1.8.9)
113
- concurrent-ruby (~> 1.0)
114
- ice_nine (0.11.2)
115
- listen (3.4.1)
116
- rb-fsevent (~> 0.10, >= 0.10.3)
117
- rb-inotify (~> 0.9, >= 0.9.10)
118
- loofah (2.9.0)
119
- crass (~> 1.0.2)
120
- nokogiri (>= 1.5.9)
121
- lumberjack (1.2.8)
122
- mail (2.7.1)
123
- mini_mime (>= 0.1.1)
124
- marcel (0.3.3)
125
- mimemagic (~> 0.3.2)
126
- method_source (1.0.0)
127
- mimemagic (0.3.5)
128
- mini_mime (1.0.2)
129
- mini_portile2 (2.5.0)
130
- minitest (5.14.4)
131
- nenv (0.3.0)
132
- nio4r (2.5.7)
133
- nokogiri (1.11.2)
134
- mini_portile2 (~> 2.5.0)
135
- racc (~> 1.4)
136
- notiffany (0.1.3)
137
- nenv (~> 0.1)
138
- shellany (~> 0.0)
139
- pry (0.14.0)
140
- coderay (~> 1.1)
141
- method_source (~> 1.0)
142
- racc (1.5.2)
143
- rack (2.2.3)
144
- rack-test (1.1.0)
145
- rack (>= 1.0, < 3)
146
- rails (6.1.3)
147
- actioncable (= 6.1.3)
148
- actionmailbox (= 6.1.3)
149
- actionmailer (= 6.1.3)
150
- actionpack (= 6.1.3)
151
- actiontext (= 6.1.3)
152
- actionview (= 6.1.3)
153
- activejob (= 6.1.3)
154
- activemodel (= 6.1.3)
155
- activerecord (= 6.1.3)
156
- activestorage (= 6.1.3)
157
- activesupport (= 6.1.3)
158
- bundler (>= 1.15.0)
159
- railties (= 6.1.3)
160
- sprockets-rails (>= 2.0.0)
161
- rails-dom-testing (2.0.3)
162
- activesupport (>= 4.2.0)
163
- nokogiri (>= 1.6)
164
- rails-html-sanitizer (1.3.0)
165
- loofah (~> 2.3)
166
- railties (6.1.3)
167
- actionpack (= 6.1.3)
168
- activesupport (= 6.1.3)
169
- method_source
170
- rake (>= 0.8.7)
171
- thor (~> 1.0)
172
- rake (13.0.3)
173
- rb-fsevent (0.10.4)
174
- rb-inotify (0.10.1)
175
- ffi (~> 1.0)
176
- rspec (3.10.0)
177
- rspec-core (~> 3.10.0)
178
- rspec-expectations (~> 3.10.0)
179
- rspec-mocks (~> 3.10.0)
180
- rspec-core (3.10.1)
181
- rspec-support (~> 3.10.0)
182
- rspec-expectations (3.10.1)
183
- diff-lcs (>= 1.2.0, < 2.0)
184
- rspec-support (~> 3.10.0)
185
- rspec-mocks (3.10.2)
186
- diff-lcs (>= 1.2.0, < 2.0)
187
- rspec-support (~> 3.10.0)
188
- rspec-rails (5.0.0)
189
- actionpack (>= 5.2)
190
- activesupport (>= 5.2)
191
- railties (>= 5.2)
192
- rspec-core (~> 3.10)
193
- rspec-expectations (~> 3.10)
194
- rspec-mocks (~> 3.10)
195
- rspec-support (~> 3.10)
196
- rspec-support (3.10.2)
197
- shellany (0.0.1)
198
- sprockets (4.0.2)
199
- concurrent-ruby (~> 1.0)
200
- rack (> 1, < 3)
201
- sprockets-rails (3.2.2)
202
- actionpack (>= 4.0)
203
- activesupport (>= 4.0)
204
- sprockets (>= 3.0.0)
205
- sqlite3 (1.4.2)
206
- thor (1.1.0)
207
- tzinfo (2.0.4)
208
- concurrent-ruby (~> 1.0)
209
- websocket-driver (0.7.3)
210
- websocket-extensions (>= 0.1.0)
211
- websocket-extensions (0.1.5)
212
- zeitwerk (2.4.2)
213
-
214
- PLATFORMS
215
- ruby
216
-
217
- DEPENDENCIES
218
- byebug
219
- dry-struct
220
- faker
221
- guard
222
- guard-rspec
223
- rails
224
- rspec
225
- rspec-rails
226
- sqlite3
227
-
228
- BUNDLED WITH
229
- 2.1.4