releaf 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/releaf/rspec.rb +1 -0
- data/lib/releaf/rspec/features_matchers.rb +3 -9
- data/lib/releaf/rspec/helpers.rb +37 -11
- data/lib/releaf/rspec/matchers/have_number_of_resources.rb +13 -0
- data/lib/releaf/version.rb +1 -1
- metadata +12 -49
- data/spec/factories/author.rb +0 -6
- data/spec/factories/banner_page.rb +0 -5
- data/spec/factories/book.rb +0 -5
- data/spec/factories/chapter.rb +0 -7
- data/spec/factories/common.rb +0 -5
- data/spec/factories/home_page.rb +0 -5
- data/spec/factories/node.rb +0 -50
- data/spec/factories/node_route.rb +0 -7
- data/spec/factories/publisher.rb +0 -5
- data/spec/factories/role.rb +0 -21
- data/spec/factories/text_page.rb +0 -5
- data/spec/factories/user.rb +0 -22
- data/spec/rails_helper.rb +0 -129
- data/spec/spec_helper.rb +0 -86
- data/spec/support/capybra_actions.rb +0 -6
- data/spec/support/controller_macros.rb +0 -8
- data/spec/support/excel_helpers.rb +0 -63
- data/spec/support/shared/service_includer.rb +0 -9
- data/spec/support/wait_steps.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddeaddff4115dcc5b7363553c560cb62559f2e8c6af8cd20c76fd539b2133b82
|
4
|
+
data.tar.gz: b5b91942067292a368826a87389b78dff00b32b38ab78b9580f4b6fd36fdb13c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fc01fd41f51a76f9d9e67ba2baec603e7aa365d5a677bd972c1749178611e07bf8272fa90aa3be88db5f6235270bdd75682edfbf7d68f41b66333be042fd5be
|
7
|
+
data.tar.gz: b89582b373249a004397f46b5750788cb1c2e6e6b9a46b57aa8429e4be0efa1c2a28f01d7f09751a7cdca6456719531a8b5fdf9505f11d98a7c95a0ced27c3e1
|
data/lib/releaf/rspec.rb
CHANGED
@@ -20,12 +20,6 @@ module Capybara
|
|
20
20
|
has_no_css?("#{primary_header_css_rule} h1", *args)
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
def has_number_of_resources?(count)
|
25
|
-
has_css?("#{primary_header_css_rule} .totals", text: "#{count} resources found")
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
23
|
# Allows to match againg validation errors within forms
|
30
24
|
# Support either model specific (base) errors with:
|
31
25
|
# expect(page).to have_error('Global form error message')
|
@@ -40,7 +34,7 @@ module Capybara
|
|
40
34
|
error_found = false
|
41
35
|
if options[:field]
|
42
36
|
first('.field.has-error', minimum: 1) # wait for any errors to come from validation
|
43
|
-
all(".field.has-error").each do |field_container|
|
37
|
+
all(".field.has-error", wait: false).each do |field_container|
|
44
38
|
if !error_found
|
45
39
|
within(field_container) do
|
46
40
|
if has_field?(options[:field], wait: false) && has_css?(".error", text: error_message, wait: false)
|
@@ -50,7 +44,7 @@ module Capybara
|
|
50
44
|
end
|
51
45
|
end
|
52
46
|
else
|
53
|
-
if first(".form-error-box .error", text: error_message)
|
47
|
+
if first(".form-error-box .error", text: error_message, minimum: 0)
|
54
48
|
error_found = true
|
55
49
|
end
|
56
50
|
end
|
@@ -74,7 +68,7 @@ module Capybara
|
|
74
68
|
|
75
69
|
def has_notification?(text, type="success")
|
76
70
|
result = has_css?(".notifications .notification[data-type='#{type}']", text: text)
|
77
|
-
if first(".notifications button.close")
|
71
|
+
if first(".notifications button.close", minimum: 0)
|
78
72
|
find(".notifications .notification[data-type='#{type}'] button.close").click
|
79
73
|
has_no_css?(".notifications .notification[data-type='#{type}'] button.close")
|
80
74
|
end
|
data/lib/releaf/rspec/helpers.rb
CHANGED
@@ -89,11 +89,17 @@ module Releaf::Test
|
|
89
89
|
def wait_for_all_richtexts
|
90
90
|
# wait for all ckeditors to fully initialize before moving on.
|
91
91
|
# otherwise the page sometimes produces random js errors in fast tests
|
92
|
-
number_of_normal_richtexts = page.all('.field.type-richtext:not(.i18n)', wait:
|
93
|
-
number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', wait:
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
number_of_normal_richtexts = page.all('.field.type-richtext:not(.i18n)', wait: false).length
|
93
|
+
number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', wait: false, visible: false).length
|
94
|
+
|
95
|
+
# some richtexts may have been inside nested association items that have been removed (they actually only get hidden).
|
96
|
+
# they must be included in the count because they retain their 'ckeditor-initialized' class even after the editor has been unloaded
|
97
|
+
number_of_removed_normal_richtexts = page.all('fieldset.item.type-association.removed .field.type-richtext:not(.i18n)', wait: false, visible: false).length
|
98
|
+
|
99
|
+
number_of_initialized_richtexts = number_of_normal_richtexts + number_of_localized_richtexts + number_of_removed_normal_richtexts
|
100
|
+
if number_of_initialized_richtexts > 0
|
101
|
+
# expect _at least_ that many richtexts. others may have been initialized and hidden by some custom code
|
102
|
+
expect(page).to have_css(".ckeditor-initialized", visible: false, minimum: number_of_initialized_richtexts)
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
@@ -119,13 +125,27 @@ module Releaf::Test
|
|
119
125
|
wait_for_all_richtexts
|
120
126
|
end
|
121
127
|
|
122
|
-
def
|
128
|
+
def close_all_notifications
|
129
|
+
page.all('body > .notifications .notification[data-id="resource_status"]', wait: false).each do |notification|
|
130
|
+
within(notification) { find('button.close').click }
|
131
|
+
end
|
132
|
+
expect(page).to have_no_css('body > .notifications .notification[data-id="resource_status"]')
|
133
|
+
end
|
134
|
+
|
135
|
+
def save_and_check_response(status_text, button_text = "Save")
|
123
136
|
wait_for_all_richtexts
|
124
|
-
|
125
|
-
|
137
|
+
# close any existing notifications
|
138
|
+
close_all_notifications
|
139
|
+
within page.document.find("form[data-remote-validation-initialized='true']") do
|
140
|
+
click_button button_text
|
141
|
+
end
|
142
|
+
notification = find('body > .notifications .notification[data-id="resource_status"][data-type="success"]', text: status_text)
|
143
|
+
within(notification) { find('button.close').click }
|
144
|
+
expect(page).to have_no_css('body > .notifications .notification[data-id="resource_status"]')
|
126
145
|
wait_for_all_richtexts
|
127
146
|
end
|
128
147
|
|
148
|
+
|
129
149
|
# As there is no visual UI for settings update being successful
|
130
150
|
# do check against database
|
131
151
|
def wait_for_settings_update(key, value = true)
|
@@ -206,7 +226,7 @@ module Releaf::Test
|
|
206
226
|
|
207
227
|
# locate possibly hidden textarea among active/visible richtext fields ignoring hidden localization versions
|
208
228
|
textareas = []
|
209
|
-
richtext_boxes = all(".field.type-richtext:not(.i18n), .field.type-richtext.i18n .localization.active")
|
229
|
+
richtext_boxes = all(".field.type-richtext:not(.i18n), .field.type-richtext.i18n .localization.active", wait: false)
|
210
230
|
richtext_boxes.each do |richtext_box|
|
211
231
|
textarea = richtext_box.first(:field, locator, visible: false, minimum: 0)
|
212
232
|
textareas << textarea if textarea.present?
|
@@ -231,16 +251,22 @@ module Releaf::Test
|
|
231
251
|
|
232
252
|
def add_nested_item(block_name, expected_item_index)
|
233
253
|
scroll_to_bottom_of_page
|
234
|
-
all('button', text: 'Add item').last.click # use last button in case of multiple nested items
|
254
|
+
all('button', text: 'Add item', wait: false).last.click # use last button in case of multiple nested items
|
235
255
|
wait_for_nested_item block_name, expected_item_index
|
236
256
|
|
237
257
|
if block_given?
|
238
|
-
|
258
|
+
within_nested_item block_name, expected_item_index do
|
239
259
|
yield
|
240
260
|
end
|
241
261
|
end
|
242
262
|
end
|
243
263
|
|
264
|
+
def within_nested_item block_name, item_index
|
265
|
+
within(".item[data-name='#{block_name}'][data-index='#{item_index}']") do
|
266
|
+
yield
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
244
270
|
def remove_nested_item(block_name, item_index)
|
245
271
|
base_selector = ".item[data-name=\"#{block_name}\"][data-index=\"#{item_index}\"]"
|
246
272
|
page.find("#{base_selector} > .remove-item-box button.remove-nested-item").click
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec::Matchers.define :have_number_of_resources do |number_of_resources|
|
2
|
+
|
3
|
+
match do |subject|
|
4
|
+
@text = "#{number_of_resources} resources found"
|
5
|
+
@node = find "main > section header .totals"
|
6
|
+
@node.has_text? @text, exact: true
|
7
|
+
end
|
8
|
+
|
9
|
+
failure_message do |subject|
|
10
|
+
"expected #{@node.text.inspect} to match #{@text.inspect}"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/lib/releaf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: releaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: releaf-core
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.
|
19
|
+
version: 2.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.
|
26
|
+
version: 2.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: releaf-i18n_database
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.
|
33
|
+
version: 2.0.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0.
|
40
|
+
version: 2.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: releaf-permissions
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0.
|
47
|
+
version: 2.0.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.0.
|
54
|
+
version: 2.0.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: releaf-content
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0.
|
61
|
+
version: 2.0.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.0.
|
68
|
+
version: 2.0.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,28 +332,10 @@ files:
|
|
332
332
|
- lib/releaf/rspec/features_matchers.rb
|
333
333
|
- lib/releaf/rspec/helpers.rb
|
334
334
|
- lib/releaf/rspec/matchers/cache_instance_method.rb
|
335
|
+
- lib/releaf/rspec/matchers/have_number_of_resources.rb
|
335
336
|
- lib/releaf/rspec/matchers/match_html.rb
|
336
337
|
- lib/releaf/test.rb
|
337
338
|
- lib/releaf/version.rb
|
338
|
-
- spec/factories/author.rb
|
339
|
-
- spec/factories/banner_page.rb
|
340
|
-
- spec/factories/book.rb
|
341
|
-
- spec/factories/chapter.rb
|
342
|
-
- spec/factories/common.rb
|
343
|
-
- spec/factories/home_page.rb
|
344
|
-
- spec/factories/node.rb
|
345
|
-
- spec/factories/node_route.rb
|
346
|
-
- spec/factories/publisher.rb
|
347
|
-
- spec/factories/role.rb
|
348
|
-
- spec/factories/text_page.rb
|
349
|
-
- spec/factories/user.rb
|
350
|
-
- spec/rails_helper.rb
|
351
|
-
- spec/spec_helper.rb
|
352
|
-
- spec/support/capybra_actions.rb
|
353
|
-
- spec/support/controller_macros.rb
|
354
|
-
- spec/support/excel_helpers.rb
|
355
|
-
- spec/support/shared/service_includer.rb
|
356
|
-
- spec/support/wait_steps.rb
|
357
339
|
homepage: https://github.com/cubesystems/releaf
|
358
340
|
licenses:
|
359
341
|
- MIT
|
@@ -377,23 +359,4 @@ rubygems_version: 3.0.8
|
|
377
359
|
signing_key:
|
378
360
|
specification_version: 4
|
379
361
|
summary: Administration interface for Ruby on Rails
|
380
|
-
test_files:
|
381
|
-
- spec/factories/node_route.rb
|
382
|
-
- spec/factories/publisher.rb
|
383
|
-
- spec/factories/node.rb
|
384
|
-
- spec/factories/banner_page.rb
|
385
|
-
- spec/factories/book.rb
|
386
|
-
- spec/factories/common.rb
|
387
|
-
- spec/factories/home_page.rb
|
388
|
-
- spec/factories/author.rb
|
389
|
-
- spec/factories/role.rb
|
390
|
-
- spec/factories/text_page.rb
|
391
|
-
- spec/factories/user.rb
|
392
|
-
- spec/factories/chapter.rb
|
393
|
-
- spec/support/wait_steps.rb
|
394
|
-
- spec/support/controller_macros.rb
|
395
|
-
- spec/support/excel_helpers.rb
|
396
|
-
- spec/support/capybra_actions.rb
|
397
|
-
- spec/support/shared/service_includer.rb
|
398
|
-
- spec/spec_helper.rb
|
399
|
-
- spec/rails_helper.rb
|
362
|
+
test_files: []
|
data/spec/factories/author.rb
DELETED
data/spec/factories/book.rb
DELETED
data/spec/factories/chapter.rb
DELETED
data/spec/factories/common.rb
DELETED
data/spec/factories/home_page.rb
DELETED
data/spec/factories/node.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :node, class: ::Node do
|
3
|
-
sequence(:name) {|n| "node #{n}"}
|
4
|
-
sequence(:slug) {|n| "node-#{n}"}
|
5
|
-
content_type { "HomePage" }
|
6
|
-
end
|
7
|
-
|
8
|
-
factory :other_node, class: ::OtherSite::OtherNode do
|
9
|
-
sequence(:name) {|n| "node #{n}"}
|
10
|
-
sequence(:slug) {|n| "node-#{n}"}
|
11
|
-
content_type { "HomePage" }
|
12
|
-
end
|
13
|
-
|
14
|
-
factory :home_page_node, class: ::Node do
|
15
|
-
sequence(:name) {|n| "node #{n}"}
|
16
|
-
sequence(:slug) {|n| "node-#{n}"}
|
17
|
-
content_type { "HomePage" }
|
18
|
-
content_attributes {{ intro_text_html: "some <strong>STRRRONG</strong> text" }}
|
19
|
-
end
|
20
|
-
|
21
|
-
factory :other_home_page_node, class: ::OtherSite::OtherNode do
|
22
|
-
sequence(:name) {|n| "node #{n}"}
|
23
|
-
sequence(:slug) {|n| "node-#{n}"}
|
24
|
-
content_type { "HomePage" }
|
25
|
-
content_attributes {{ intro_text_html: "some <strong>STRRRONG</strong> text" }}
|
26
|
-
end
|
27
|
-
|
28
|
-
factory :text_page_node, class: ::Node do
|
29
|
-
sequence(:name) {|n| "node #{n}"}
|
30
|
-
sequence(:slug) {|n| "node-#{n}"}
|
31
|
-
content_type { "TextPage" }
|
32
|
-
content_attributes {{ text_html: "some <strong>STRIONG</strong> text" }}
|
33
|
-
end
|
34
|
-
|
35
|
-
factory :other_text_page_node, class: ::OtherSite::OtherNode do
|
36
|
-
sequence(:name) {|n| "node #{n}"}
|
37
|
-
sequence(:slug) {|n| "node-#{n}"}
|
38
|
-
content_type { "TextPage" }
|
39
|
-
content_attributes {{ text_html: "some <strong>STRIONG</strong> text" }}
|
40
|
-
end
|
41
|
-
|
42
|
-
factory :banner_page_node, class: ::Node do
|
43
|
-
sequence(:name) {|n| "node #{n}"}
|
44
|
-
sequence(:slug) {|n| "node-#{n}"}
|
45
|
-
content_type { "BannerPage" }
|
46
|
-
content_attributes {{}}
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
end
|
data/spec/factories/publisher.rb
DELETED
data/spec/factories/role.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :roles, :class => Releaf::Permissions::Role do
|
3
|
-
sequence(:name) {|n| "role #{n}"}
|
4
|
-
|
5
|
-
factory :admin_role do
|
6
|
-
default_controller { "releaf/permissions/users" }
|
7
|
-
after(:create) do |role|
|
8
|
-
Releaf.application.config.available_controllers.each do|controller|
|
9
|
-
role.permissions.create!(permission: "controller.#{controller}")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
factory :content_role do
|
15
|
-
default_controller { "admin/nodes" }
|
16
|
-
after(:create) do |role|
|
17
|
-
role.permissions.create!(permission: "controller.admin/nodes")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/spec/factories/text_page.rb
DELETED
data/spec/factories/user.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :users, class: Releaf::Permissions::User do
|
3
|
-
trait :user_basic do
|
4
|
-
email
|
5
|
-
name
|
6
|
-
surname
|
7
|
-
locale { 'en' }
|
8
|
-
password { 'password' }
|
9
|
-
password_confirmation { 'password' }
|
10
|
-
end
|
11
|
-
|
12
|
-
factory :user do
|
13
|
-
user_basic
|
14
|
-
association :role, factory: :admin_role
|
15
|
-
end
|
16
|
-
|
17
|
-
factory :content_user do
|
18
|
-
user_basic
|
19
|
-
association :role, factory: :content_role
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/spec/rails_helper.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'simplecov-rcov'
|
3
|
-
require 'coveralls'
|
4
|
-
require 'pry'
|
5
|
-
SimpleCov.command_name 'rspec'
|
6
|
-
|
7
|
-
Coveralls.wear!('rails')
|
8
|
-
|
9
|
-
if ENV["COVERAGE"]
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
11
|
-
SimpleCov::Formatter::HTMLFormatter,
|
12
|
-
SimpleCov::Formatter::RcovFormatter,
|
13
|
-
Coveralls::SimpleCov::Formatter
|
14
|
-
])
|
15
|
-
SimpleCov.start do
|
16
|
-
add_filter '/lib/releaf/rspec'
|
17
|
-
add_filter '/spec/'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
ENV["RAILS_ENV"] ||= 'test'
|
22
|
-
require 'spec_helper'
|
23
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
24
|
-
require 'rspec/rails'
|
25
|
-
require 'rails-controller-testing'
|
26
|
-
require 'factory_bot'
|
27
|
-
require "shoulda-matchers"
|
28
|
-
require 'db-query-matchers'
|
29
|
-
require 'selenium/webdriver'
|
30
|
-
require 'with_model'
|
31
|
-
require 'timecop'
|
32
|
-
require 'with_model'
|
33
|
-
require 'database_cleaner'
|
34
|
-
require 'releaf/rspec'
|
35
|
-
|
36
|
-
Rails.backtrace_cleaner.remove_silencers!
|
37
|
-
# Load support files
|
38
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
39
|
-
|
40
|
-
# for devise testing
|
41
|
-
include Warden::Test::Helpers
|
42
|
-
|
43
|
-
Capybara.register_driver(:chrome) do |app|
|
44
|
-
options = ::Selenium::WebDriver::Chrome::Options.new
|
45
|
-
options.add_argument('--headless')
|
46
|
-
options.add_argument('--window-size=1400,900')
|
47
|
-
|
48
|
-
if ENV['CI']
|
49
|
-
options.add_argument('--no-sandbox')
|
50
|
-
options.add_argument('--disable-dev-shm-usage')
|
51
|
-
end
|
52
|
-
|
53
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
54
|
-
end
|
55
|
-
|
56
|
-
Capybara.javascript_driver = :chrome
|
57
|
-
|
58
|
-
Capybara.default_set_options = { clear: :backspace } # needed for 'fill_in "Foo", with: ""' to work
|
59
|
-
|
60
|
-
RSpec.configure do |config|
|
61
|
-
config.use_transactional_fixtures = false
|
62
|
-
config.infer_base_class_for_anonymous_controllers = false
|
63
|
-
config.order = "random"
|
64
|
-
config.infer_spec_type_from_file_location!
|
65
|
-
|
66
|
-
config.include Shoulda::Matchers::ActiveModel, type: :model
|
67
|
-
config.include Shoulda::Matchers::ActiveRecord, type: :model
|
68
|
-
config.include Shoulda::Matchers::Independent
|
69
|
-
|
70
|
-
config.color = true
|
71
|
-
|
72
|
-
if ENV['COVERAGE']
|
73
|
-
config.add_formatter(:progress)
|
74
|
-
end
|
75
|
-
|
76
|
-
config.include Releaf::Test::Helpers
|
77
|
-
config.include CapybaraActions, type: :feature
|
78
|
-
config.include WaitSteps
|
79
|
-
config.include ExcelHelpers
|
80
|
-
config.extend WithModel
|
81
|
-
|
82
|
-
config.include Rails.application.routes.url_helpers
|
83
|
-
|
84
|
-
# DEVISE
|
85
|
-
config.include Devise::Test::ControllerHelpers, type: :controller
|
86
|
-
config.extend ControllerMacros, type: :controller
|
87
|
-
config.include Devise::Test::ControllerHelpers, type: :helper
|
88
|
-
config.extend ControllerMacros, type: :helper
|
89
|
-
|
90
|
-
|
91
|
-
[:controller, :view, :request].each do |type|
|
92
|
-
config.include ::Rails::Controller::Testing::TestProcess, type: type
|
93
|
-
config.include ::Rails::Controller::Testing::TemplateAssertions, type: type
|
94
|
-
config.include ::Rails::Controller::Testing::Integration, type: type
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
config.include FactoryBot::Syntax::Methods
|
99
|
-
|
100
|
-
Capybara.default_normalize_ws = true
|
101
|
-
|
102
|
-
# disable empty translation creation
|
103
|
-
|
104
|
-
config.before(:each) do |example|
|
105
|
-
Rails.cache.clear
|
106
|
-
allow( Releaf.application.config.i18n_database ).to receive(:translation_auto_creation).and_return(false)
|
107
|
-
|
108
|
-
if example.metadata[:db_strategy]
|
109
|
-
DatabaseCleaner.strategy = example.metadata[:db_strategy]
|
110
|
-
elsif Capybara.current_driver == :rack_test
|
111
|
-
DatabaseCleaner.strategy = :transaction
|
112
|
-
else
|
113
|
-
DatabaseCleaner.strategy = :truncation
|
114
|
-
end
|
115
|
-
|
116
|
-
DatabaseCleaner.start
|
117
|
-
# set settings
|
118
|
-
I18n.locale = Releaf.application.config.available_locales.first
|
119
|
-
I18n.default_locale = Releaf.application.config.available_locales.first
|
120
|
-
end
|
121
|
-
|
122
|
-
config.after do
|
123
|
-
Timecop.return
|
124
|
-
DatabaseCleaner.clean
|
125
|
-
Releaf::Test.reset!
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each { |f| require f }
|
data/spec/spec_helper.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
-
#
|
6
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
-
# a separate helper file that requires the additional dependencies and performs
|
11
|
-
# the additional setup, and require it from the spec files that actually need it.
|
12
|
-
#
|
13
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
-
# users commonly want.
|
15
|
-
#
|
16
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
-
RSpec.configure do |config|
|
18
|
-
# rspec-expectations config goes here. You can use an alternate
|
19
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
-
# assertions if you prefer.
|
21
|
-
config.expect_with :rspec do |expectations|
|
22
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
-
# and `failure_message` of custom matchers include text for helper methods
|
24
|
-
# defined using `chain`, e.g.:
|
25
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
-
# # => "be bigger than 2 and smaller than 4"
|
27
|
-
# ...rather than:
|
28
|
-
# # => "be bigger than 2"
|
29
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
-
end
|
31
|
-
|
32
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
-
config.mock_with :rspec do |mocks|
|
35
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
-
# a real object. This is generally recommended, and will default to
|
37
|
-
# `true` in RSpec 4.
|
38
|
-
mocks.verify_partial_doubles = true
|
39
|
-
end
|
40
|
-
|
41
|
-
# The settings below are suggested to provide a good initial experience
|
42
|
-
# with RSpec, but feel free to customize to your heart's content.
|
43
|
-
=begin
|
44
|
-
# These two settings work together to allow you to limit a spec run
|
45
|
-
# to individual examples or groups you care about by tagging them with
|
46
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
-
# get run.
|
48
|
-
config.filter_run :focus
|
49
|
-
config.run_all_when_everything_filtered = true
|
50
|
-
|
51
|
-
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
-
# For more details, see:
|
53
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
-
config.disable_monkey_patching!
|
57
|
-
|
58
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
59
|
-
# file, and it's useful to allow more verbose output when running an
|
60
|
-
# individual spec file.
|
61
|
-
if config.files_to_run.one?
|
62
|
-
# Use the documentation formatter for detailed output,
|
63
|
-
# unless a formatter has already been configured
|
64
|
-
# (e.g. via a command-line flag).
|
65
|
-
config.default_formatter = 'doc'
|
66
|
-
end
|
67
|
-
|
68
|
-
# Print the 10 slowest examples and example groups at the
|
69
|
-
# end of the spec run, to help surface which specs are running
|
70
|
-
# particularly slow.
|
71
|
-
config.profile_examples = 10
|
72
|
-
|
73
|
-
# Run specs in random order to surface order dependencies. If you find an
|
74
|
-
# order dependency and want to debug it, you can fix the order by providing
|
75
|
-
# the seed, which is printed after each run.
|
76
|
-
# --seed 1234
|
77
|
-
config.order = :random
|
78
|
-
|
79
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
80
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
81
|
-
# test failures related to randomization by passing the same `--seed` value
|
82
|
-
# as the one that triggered the failure.
|
83
|
-
Kernel.srand config.seed
|
84
|
-
=end
|
85
|
-
end
|
86
|
-
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module ExcelHelpers
|
2
|
-
class ExcelMatcher
|
3
|
-
require 'roo'
|
4
|
-
|
5
|
-
def initialize(fixture_path)
|
6
|
-
@fixture_path = fixture_path
|
7
|
-
@errors = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def matches?(actual_path)
|
11
|
-
match_excel(actual_path)
|
12
|
-
|
13
|
-
@errors.empty?
|
14
|
-
end
|
15
|
-
|
16
|
-
def failure_message
|
17
|
-
"Following cells differ from expected: #{error_messages}"
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def error_messages
|
23
|
-
messages = []
|
24
|
-
@errors.each do |error|
|
25
|
-
messages << "#{error[:cell]} (expect: #{error[:fixture_value]} was: #{error[:actual_value]})"
|
26
|
-
end
|
27
|
-
|
28
|
-
messages.join(', ')
|
29
|
-
end
|
30
|
-
|
31
|
-
def match_excel actual_path
|
32
|
-
fixture = Roo::Spreadsheet.open(@fixture_path)
|
33
|
-
fixture.default_sheet = fixture.sheets.first
|
34
|
-
|
35
|
-
actual = Roo::Spreadsheet.open(actual_path)
|
36
|
-
actual.default_sheet = actual.sheets.first
|
37
|
-
|
38
|
-
match_sheet(actual, fixture)
|
39
|
-
end
|
40
|
-
|
41
|
-
def match_sheet actual, fixture
|
42
|
-
rows = fixture.first_row..fixture.last_row
|
43
|
-
columns = fixture.first_column..fixture.last_column
|
44
|
-
for row in rows
|
45
|
-
for column in columns
|
46
|
-
fixture_value = fixture.cell(row, column)
|
47
|
-
actual_value = actual.cell(row, column)
|
48
|
-
if fixture_value.to_s != actual_value.to_s
|
49
|
-
@errors << {
|
50
|
-
cell: "#{Roo::Utils.number_to_letter(column)}#{row}",
|
51
|
-
fixture_value: fixture_value,
|
52
|
-
actual_value: actual_value
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def match_excel(fixture_path)
|
61
|
-
ExcelMatcher.new(fixture_path)
|
62
|
-
end
|
63
|
-
end
|
data/spec/support/wait_steps.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require "timeout"
|
2
|
-
|
3
|
-
module WaitSteps
|
4
|
-
extend RSpec::Matchers::DSL
|
5
|
-
|
6
|
-
matcher :become_true do
|
7
|
-
match do |block|
|
8
|
-
begin
|
9
|
-
Timeout.timeout(Capybara.default_max_wait_time) do
|
10
|
-
sleep(0.1) until value = block.call
|
11
|
-
sleep(0.2)
|
12
|
-
value
|
13
|
-
end
|
14
|
-
rescue TimeoutError
|
15
|
-
false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def supports_block_expectations?
|
20
|
-
true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|