rspeckled 2.0.1 → 2.1.0
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
- checksums.yaml.gz.sig +0 -0
- data/lib/rspeckled/helpers/factories.rb +8 -2
- data/lib/rspeckled/helpers/filepaths.rb +30 -22
- data/lib/rspeckled/helpers/null_objects.rb +8 -2
- data/lib/rspeckled/helpers/patterns.rb +75 -41
- data/lib/rspeckled/helpers/responses.rb +8 -2
- data/lib/rspeckled/patches.rb +8 -6
- data/lib/rspeckled/plugins/configuration/capybara_screenshot.rb +5 -4
- data/lib/rspeckled/plugins/configuration/carrier_wave.rb +1 -1
- data/lib/rspeckled/plugins/configuration/devise.rb +4 -4
- data/lib/rspeckled/plugins/configuration/dox.rb +4 -4
- data/lib/rspeckled/plugins/configuration/email_spec.rb +3 -3
- data/lib/rspeckled/plugins/configuration/factory_bot.rb +2 -2
- data/lib/rspeckled/plugins/configuration/shoulda.rb +2 -2
- data/lib/rspeckled/plugins/configuration/vcr.rb +6 -4
- data/lib/rspeckled/plugins/configuration/warden.rb +3 -2
- data/lib/rspeckled/plugins/extensions/awesome_print.rb +20 -7
- data/lib/rspeckled/plugins/extensions/capybara.rb +16 -6
- data/lib/rspeckled/plugins/extensions/faraday/middleware/curl_logger.rb +10 -3
- data/lib/rspeckled/plugins/extensions/faraday.rb +2 -1
- data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/ebay.rb +1 -1
- data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/facebook.rb +1 -1
- data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/twitter.rb +1 -1
- data/lib/rspeckled/plugins/extensions/omniauth.rb +6 -3
- data/lib/rspeckled/plugins/extensions/ruby/deferred_garbage_collection.rb +3 -1
- data/lib/rspeckled/plugins/extensions/selenium/drivers/chrome.rb +6 -6
- data/lib/rspeckled/plugins/extensions/selenium/drivers/firefox.rb +14 -3
- data/lib/rspeckled/plugins/extensions/strong_parameters.rb +2 -1
- data/lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb +3 -1
- data/lib/rspeckled/plugins/extensions/vcr.rb +8 -4
- data/lib/rspeckled/plugins/hooks/action_mailer.rb +2 -2
- data/lib/rspeckled/plugins/hooks/authentication.rb +87 -61
- data/lib/rspeckled/plugins/hooks/bullet.rb +3 -1
- data/lib/rspeckled/plugins/hooks/capybara.rb +2 -2
- data/lib/rspeckled/plugins/hooks/carrier_wave.rb +2 -2
- data/lib/rspeckled/plugins/hooks/database_cleaner.rb +2 -2
- data/lib/rspeckled/plugins/hooks/devise.rb +1 -1
- data/lib/rspeckled/plugins/hooks/dox.rb +1 -1
- data/lib/rspeckled/plugins/hooks/elasticsearch.rb +13 -9
- data/lib/rspeckled/plugins/hooks/factory_bot.rb +1 -1
- data/lib/rspeckled/plugins/hooks/foreign_keys.rb +21 -13
- data/lib/rspeckled/plugins/hooks/garbage_collection.rb +1 -1
- data/lib/rspeckled/plugins/hooks/rails.rb +5 -3
- data/lib/rspeckled/plugins/hooks/redis.rb +3 -3
- data/lib/rspeckled/plugins/hooks/referehencible.rb +2 -2
- data/lib/rspeckled/plugins/hooks/request.rb +1 -1
- data/lib/rspeckled/plugins/hooks/rspec_mocks.rb +8 -4
- data/lib/rspeckled/plugins/hooks/selenium_webdriver.rb +2 -2
- data/lib/rspeckled/plugins/hooks/sidekiq.rb +14 -12
- data/lib/rspeckled/plugins/hooks/singletons.rb +2 -2
- data/lib/rspeckled/plugins/hooks/stripe.rb +5 -3
- data/lib/rspeckled/plugins/hooks/timecop.rb +3 -3
- data/lib/rspeckled/plugins/hooks/vcr.rb +2 -2
- data/lib/rspeckled/plugins/hooks/warden.rb +3 -3
- data/lib/rspeckled/plugins/hooks/webmock.rb +3 -3
- data/lib/rspeckled/plugins.rb +22 -19
- data/lib/rspeckled/reporting/example.rb +10 -8
- data/lib/rspeckled/reporting/outputs/csv.rb +2 -0
- data/lib/rspeckled/reporting/outputs/text.rb +17 -15
- data/lib/rspeckled/reporting/runner.rb +26 -24
- data/lib/rspeckled/spec_helpers/active_record_connection_setup.rb +13 -9
- data/lib/rspeckled/spec_helpers/rails_engine.rb +2 -2
- data/lib/rspeckled/spec_helpers/rspeckled.rb +17 -1
- data/lib/rspeckled/support.rb +26 -24
- data/lib/rspeckled/tasks/documentation.rake +28 -8
- data/lib/rspeckled/version.rb +3 -1
- data.tar.gz.sig +0 -0
- metadata +29 -28
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e484c27875d11ad339323acb0fddce0149da40599a29a0bdc681b516cd23c30d
|
4
|
+
data.tar.gz: 96bdd424872fd1ce9d902f058c6dc265ec57a27f41c5a984546735d0c67db27d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f852e036ef89d0677db67f9a1c4932704b2f649346902f18c38da5925dc0787d087f6d33529abc6ba6cbdb35c702ca39f557294851d9e6c849f17a16fc5182fe
|
7
|
+
data.tar.gz: bbc31cc93b5a8bd243283a47bb6a2b398f2966766644f7fbdcd10deca6c03577a68b9575ffda476629354b3d1e5a9418f2ce11bd67697ae01ff18a09363f1995
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,32 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Rspeckled
|
4
|
+
module Helpers
|
5
|
+
module Filepaths
|
6
|
+
def root_filepath
|
7
|
+
@root_filepath ||= begin
|
8
|
+
current_directory = ::Dir.pwd
|
6
9
|
|
7
|
-
|
10
|
+
until ::Dir.exist?("#{current_directory}/spec")
|
11
|
+
current_directory += '/..'
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
14
|
+
::File.expand_path(current_directory)
|
15
|
+
end
|
16
|
+
end
|
12
17
|
|
13
|
-
def fixture_filepath(filepath)
|
14
|
-
|
15
|
-
end
|
18
|
+
def fixture_filepath(filepath)
|
19
|
+
"#{root_filepath}/spec/fixtures/#{filepath}"
|
20
|
+
end
|
16
21
|
|
17
|
-
def read_fixture(filepath)
|
18
|
-
|
19
|
-
end
|
22
|
+
def read_fixture(filepath)
|
23
|
+
::File.read(fixture_filepath(filepath))
|
24
|
+
end
|
20
25
|
|
21
|
-
def parse_fixture(filepath)
|
22
|
-
|
26
|
+
def parse_fixture(filepath)
|
27
|
+
contents = read_fixture(filepath)
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
case filepath[/\.\w+\z/]
|
30
|
+
when '.json'
|
31
|
+
::JSON.parse(contents)
|
32
|
+
when '.eml'
|
33
|
+
::Mail.new(contents)
|
34
|
+
else
|
35
|
+
fail ::ArgumentError, "I don't know how to parse #{filepath}."
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Rspeckled
|
4
|
+
module Helpers
|
5
|
+
module NullObjects
|
6
|
+
def null_described_class
|
7
|
+
"Null#{described_class.name}".constantize
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
5
11
|
end
|
@@ -1,55 +1,89 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Rspeckled
|
4
|
+
module Helpers
|
5
|
+
module Patterns
|
6
|
+
def uuid_regex
|
7
|
+
/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i
|
8
|
+
end
|
6
9
|
|
7
|
-
def iso8601_regex
|
8
|
-
|
9
|
-
|
10
|
+
def iso8601_regex
|
11
|
+
/
|
12
|
+
(
|
13
|
+
-?
|
14
|
+
(?:
|
15
|
+
[1-9][0-9]*
|
16
|
+
)?
|
17
|
+
[0-9]{4}
|
18
|
+
)
|
19
|
+
-
|
20
|
+
(1[0-2]|0[1-9])
|
21
|
+
-
|
22
|
+
(3[01]|0[1-9]|[12][0-9])
|
23
|
+
T
|
24
|
+
(2[0-3]|[01][0-9])
|
25
|
+
:
|
26
|
+
([0-5][0-9])
|
27
|
+
:
|
28
|
+
([0-5][0-9])
|
29
|
+
(\.[0-9]+)?
|
30
|
+
(
|
31
|
+
(?:
|
32
|
+
[+\-]
|
33
|
+
\d{2}
|
34
|
+
:
|
35
|
+
\d{2})
|
36
|
+
|
|
37
|
+
Z
|
38
|
+
)?
|
39
|
+
/x
|
40
|
+
end
|
10
41
|
|
11
|
-
def base64_digit_regex
|
12
|
-
|
13
|
-
end
|
42
|
+
def base64_digit_regex
|
43
|
+
%r{[a-z0-9+/=]}i
|
44
|
+
end
|
14
45
|
|
15
|
-
def hex_digit_regex
|
16
|
-
|
17
|
-
end
|
46
|
+
def hex_digit_regex
|
47
|
+
/[a-f0-9]/i
|
48
|
+
end
|
18
49
|
|
19
|
-
def guid_regex
|
20
|
-
|
21
|
-
end
|
50
|
+
def guid_regex
|
51
|
+
/[a-f0-9]{32}/i
|
52
|
+
end
|
22
53
|
|
23
|
-
def md5_regex
|
24
|
-
|
25
|
-
end
|
54
|
+
def md5_regex
|
55
|
+
/[a-f0-9]{32}/i
|
56
|
+
end
|
26
57
|
|
27
|
-
def sha_regex
|
28
|
-
|
29
|
-
end
|
58
|
+
def sha_regex
|
59
|
+
/[a-f0-9]{64}/i
|
60
|
+
end
|
30
61
|
|
31
|
-
def test_email_regex
|
32
|
-
|
33
|
-
end
|
62
|
+
def test_email_regex
|
63
|
+
/user\d+@example.com/
|
64
|
+
end
|
34
65
|
|
35
|
-
def test_username_regex
|
36
|
-
|
37
|
-
end
|
66
|
+
def test_username_regex
|
67
|
+
/username\d+/
|
68
|
+
end
|
38
69
|
|
39
|
-
def json_web_token_base64_regex
|
40
|
-
|
41
|
-
end
|
70
|
+
def json_web_token_base64_regex
|
71
|
+
%r{[A-Za-z0-9_/+=\-]}
|
72
|
+
end
|
42
73
|
|
43
|
-
def json_web_token_regex
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
74
|
+
def json_web_token_regex
|
75
|
+
/
|
76
|
+
(#{json_web_token_base64_regex}+?\.){2}
|
77
|
+
#{json_web_token_base64_regex}+?
|
78
|
+
/x
|
79
|
+
end
|
49
80
|
|
50
|
-
def encrypted_json_web_token_regex
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
81
|
+
def encrypted_json_web_token_regex
|
82
|
+
/
|
83
|
+
(#{json_web_token_base64_regex}+?\.){4}
|
84
|
+
#{json_web_token_base64_regex}+?
|
85
|
+
/x
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
55
89
|
end
|
data/lib/rspeckled/patches.rb
CHANGED
@@ -5,12 +5,14 @@ begin
|
|
5
5
|
rescue LoadError
|
6
6
|
end
|
7
7
|
|
8
|
-
RSpec.configure do |config|
|
9
|
-
if defined?(::RSpec::Rails)
|
10
|
-
|
11
|
-
|
8
|
+
::RSpec.configure do |config|
|
9
|
+
if defined?(::RSpec::Rails) && ::Pathname.pwd.join('spec',
|
10
|
+
'dummy',
|
11
|
+
'config',
|
12
|
+
'environment.rb').exist?
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
require 'rspeckled/patches/rails/namespaced_engine_controller_route_fix'
|
15
|
+
|
16
|
+
config.include Rspeckled::NamespacedEngineControllerRouteFix, type: :controller
|
15
17
|
end
|
16
18
|
end
|
@@ -11,7 +11,8 @@ require 'capybara-screenshot/rspec'
|
|
11
11
|
example.full_description.downcase.tr(' ', '-').gsub(%r{^.*/spec/}, '')
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
::Capybara::Screenshot.register_driver(
|
16
|
-
|
17
|
-
|
14
|
+
%i{chrome headless_chrome firefox headless_firefox}.each do |browser|
|
15
|
+
::Capybara::Screenshot.register_driver(browser) do |driver, path|
|
16
|
+
driver.browser.save_screenshot(path)
|
17
|
+
end
|
18
|
+
end
|
@@ -5,14 +5,14 @@
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
# ::Devise < 4.2.0
|
7
7
|
defined?(::Devise::TestHelpers) &&
|
8
|
-
config.include(::Devise::TestHelpers, :
|
8
|
+
config.include(::Devise::TestHelpers, type: :controller)
|
9
9
|
|
10
10
|
# ::Devise >= 4.2.0
|
11
11
|
defined?(::Devise::Test::ControllerHelpers) &&
|
12
|
-
config.include(::Devise::Test::ControllerHelpers, :
|
12
|
+
config.include(::Devise::Test::ControllerHelpers, type: :controller)
|
13
13
|
|
14
|
-
|
14
|
+
%i{system feature request}.each do |type|
|
15
15
|
defined?(::Devise::Test::IntegrationHelpers) &&
|
16
|
-
config.include(::Devise::Test::IntegrationHelpers, :
|
16
|
+
config.include(::Devise::Test::IntegrationHelpers, type: type)
|
17
17
|
end
|
18
18
|
end
|
@@ -22,15 +22,15 @@ begin
|
|
22
22
|
http_settings_file = Pathname.pwd.join('config', 'settings', 'http.yml')
|
23
23
|
|
24
24
|
host = if http_settings_file.exist?
|
25
|
-
|
25
|
+
http_settings = YAML.unsafe_load(http_settings_file.read)
|
26
26
|
|
27
|
-
|
27
|
+
http_settings['production']['http']['base_url']
|
28
28
|
else
|
29
|
-
|
29
|
+
'http://api.lvh.me:5000'
|
30
30
|
end
|
31
31
|
|
32
32
|
unless api_docs_header.exist?
|
33
|
-
api_docs_header.write(<<~HEREDOC, :
|
33
|
+
api_docs_header.write(<<~HEREDOC, mode: 'w')
|
34
34
|
FORMAT: 1A
|
35
35
|
HOST: #{host}
|
36
36
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
-
config.include ::EmailSpec::Helpers, :
|
5
|
-
config.include ::EmailSpec::Matchers, :
|
6
|
-
config.include ::EmailSpec::MailerDeliveries, :
|
4
|
+
config.include ::EmailSpec::Helpers, email: true
|
5
|
+
config.include ::EmailSpec::Matchers, email: true
|
6
|
+
config.include ::EmailSpec::MailerDeliveries, email: true
|
7
7
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
::FactoryBot.definition_file_paths << './spec/factories'
|
4
4
|
|
5
|
-
if ::FactoryBot.
|
6
|
-
::Rails.application.class.name.
|
5
|
+
if ::FactoryBot.factories.count == 0 &&
|
6
|
+
::Rails.application.class.name.include?('Dummy')
|
7
7
|
|
8
8
|
::FactoryBot.find_definitions
|
9
9
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
-
config.include(::Shoulda::Matchers::ActiveModel, :
|
5
|
-
config.include(::Shoulda::Matchers::ActiveRecord, :
|
4
|
+
config.include(::Shoulda::Matchers::ActiveModel, type: :model)
|
5
|
+
config.include(::Shoulda::Matchers::ActiveRecord, type: :model)
|
6
6
|
end
|
7
7
|
|
8
8
|
::Shoulda::Matchers.configure do |config|
|
@@ -13,18 +13,20 @@ if defined?(::Faraday)
|
|
13
13
|
end
|
14
14
|
|
15
15
|
::VCR.configure do |config|
|
16
|
-
|
16
|
+
cassette_path = ::File.expand_path('./tmp/vcr_cassettes')
|
17
|
+
|
18
|
+
config.ignore_hosts 'lvh.me', 'localhost', '127.0.0.1', '0.0.0.0'
|
17
19
|
|
18
20
|
# So that the Code Climate coverage reporter (if installed) can send reports
|
19
21
|
# even though VCR is enabled.
|
20
22
|
config.ignore_hosts 'codeclimate.com'
|
21
23
|
|
22
|
-
config.cassette_library_dir =
|
24
|
+
config.cassette_library_dir = cassette_path
|
23
25
|
config.allow_http_connections_when_no_cassette = true
|
24
26
|
|
25
27
|
config.default_cassette_options = {
|
26
|
-
:
|
27
|
-
:
|
28
|
+
record: :once,
|
29
|
+
re_record_interval: 7_776_000,
|
28
30
|
}
|
29
31
|
|
30
32
|
config.configure_rspec_metadata!
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
-
|
5
|
-
defined?(::Warden::Test::Helpers) && config.include(::Warden::Test::Helpers,
|
4
|
+
%i{system feature request}.each do |type|
|
5
|
+
defined?(::Warden::Test::Helpers) && config.include(::Warden::Test::Helpers,
|
6
|
+
type: type)
|
6
7
|
end
|
7
8
|
end
|
@@ -7,8 +7,11 @@ rescue LoadError
|
|
7
7
|
end
|
8
8
|
|
9
9
|
# rubocop:disable Metrics/AbcSize
|
10
|
-
# rubocop:disable Metrics/
|
10
|
+
# rubocop:disable Metrics/BlockLength
|
11
|
+
# rubocop:disable Metrics/BlockNesting
|
11
12
|
# rubocop:disable Metrics/CyclomaticComplexity
|
13
|
+
# rubocop:disable Metrics/MethodLength
|
14
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
12
15
|
module Kernel
|
13
16
|
def sap(*messages)
|
14
17
|
columns = if ::IO.console
|
@@ -48,7 +51,9 @@ module Kernel
|
|
48
51
|
if message.respond_to?(:class)
|
49
52
|
print "\e[32m"
|
50
53
|
|
51
|
-
if defined?(::ActiveRecord::Base) &&
|
54
|
+
if defined?(::ActiveRecord::Base) &&
|
55
|
+
message.class.ancestors.include?(::ActiveRecord::Base)
|
56
|
+
|
52
57
|
ap(message.class)
|
53
58
|
else
|
54
59
|
puts "Class: #{message.class}"
|
@@ -60,14 +65,19 @@ module Kernel
|
|
60
65
|
end
|
61
66
|
|
62
67
|
if defined?(::ActiveRecord::Base) && message.is_a?(::ActiveRecord::Base)
|
63
|
-
ap(message.attributes, :
|
68
|
+
ap(message.attributes, raw: true)
|
64
69
|
else
|
65
|
-
ap(message, :
|
70
|
+
ap(message, raw: true)
|
66
71
|
end
|
67
72
|
|
68
73
|
puts
|
69
74
|
|
70
|
-
if %w{
|
75
|
+
if %w{
|
76
|
+
String
|
77
|
+
ActionView::OutputBuffer
|
78
|
+
ActiveSupport::SafeBuffer
|
79
|
+
}.include?(message.class.name)
|
80
|
+
|
71
81
|
print "\e[1;35m"
|
72
82
|
print ' RAW STRING '.center(columns, '-')
|
73
83
|
print "\e[0m\n"
|
@@ -83,7 +93,7 @@ module Kernel
|
|
83
93
|
ascii = 0
|
84
94
|
total = 0
|
85
95
|
|
86
|
-
message.read(1024).each_byte
|
96
|
+
message.read(1024).each_byte do |byte|
|
87
97
|
total += 1
|
88
98
|
ascii += 1 if byte >= 128 || byte == 0
|
89
99
|
end
|
@@ -108,6 +118,9 @@ module Kernel
|
|
108
118
|
end
|
109
119
|
end
|
110
120
|
end
|
111
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
112
121
|
# rubocop:enable Metrics/PerceivedComplexity
|
122
|
+
# rubocop:enable Metrics/MethodLength
|
123
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
124
|
+
# rubocop:enable Metrics/BlockNesting
|
125
|
+
# rubocop:enable Metrics/BlockLength
|
113
126
|
# rubocop:enable Metrics/AbcSize
|
@@ -8,10 +8,18 @@ require 'rspeckled/plugins/extensions/selenium/drivers/firefox'
|
|
8
8
|
::Capybara.register_server :puma do |app, _port, _host|
|
9
9
|
require 'rack/handler/puma'
|
10
10
|
|
11
|
-
host = (defined?(::Chamber) && ::Chamber.env.http.url_components.host) ||
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
host = (defined?(::Chamber) && ::Chamber.env.http.url_components.host) ||
|
12
|
+
ENV['HOST'] ||
|
13
|
+
'lvh.me'
|
14
|
+
port = (defined?(::Chamber) && ::Chamber.env.http.url_components.port) ||
|
15
|
+
ENV['PORT'] ||
|
16
|
+
'3000'
|
17
|
+
|
18
|
+
::Rack::Handler::Puma.run(app,
|
19
|
+
Host: host,
|
20
|
+
Port: port,
|
21
|
+
Threads: '0:1',
|
22
|
+
Silent: true)
|
15
23
|
end
|
16
24
|
|
17
25
|
::Capybara.server = :puma
|
@@ -19,8 +27,10 @@ end
|
|
19
27
|
# Configure Browser Drivers
|
20
28
|
|
21
29
|
downloads_directory = "#{Dir.pwd}/tmp/downloads/"
|
22
|
-
chrome_driver = ::Rspeckled::Selenium::Drivers::Chrome
|
23
|
-
|
30
|
+
chrome_driver = ::Rspeckled::Selenium::Drivers::Chrome
|
31
|
+
.new(downloads_directory: downloads_directory)
|
32
|
+
firefox_driver = ::Rspeckled::Selenium::Drivers::Firefox
|
33
|
+
.new(downloads_directory: downloads_directory)
|
24
34
|
|
25
35
|
::Capybara.register_driver(:chrome) { |app| chrome_driver.driver(app) }
|
26
36
|
::Capybara.register_driver(:headless_chrome) { |app| chrome_driver.headless(app) }
|
@@ -7,7 +7,7 @@ class CurlLogger < ::Faraday::Response::Middleware
|
|
7
7
|
def self.default_logger
|
8
8
|
require 'logger'
|
9
9
|
|
10
|
-
::Logger.new(
|
10
|
+
::Logger.new($stdout)
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(app, logger = nil, program_name = nil)
|
@@ -18,13 +18,20 @@ class CurlLogger < ::Faraday::Response::Middleware
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def call(env)
|
21
|
-
@logger.info(@program_name)
|
21
|
+
@logger.info(@program_name) do
|
22
|
+
curl_output('request',
|
23
|
+
"#{env[:method].upcase} #{env[:url]}",
|
24
|
+
env[:request_headers],
|
25
|
+
env[:body])
|
26
|
+
end
|
22
27
|
|
23
28
|
super
|
24
29
|
end
|
25
30
|
|
26
31
|
def on_complete(env)
|
27
|
-
@logger.info(@program_name)
|
32
|
+
@logger.info(@program_name) do
|
33
|
+
curl_output('response', "HTTP #{env[:status]}", env[:response_headers], env[:body])
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
private
|
@@ -2,4 +2,5 @@
|
|
2
2
|
|
3
3
|
require 'rspeckled/plugins/extensions/faraday/middleware/curl_logger'
|
4
4
|
|
5
|
-
::Faraday::Response
|
5
|
+
::Faraday::Response
|
6
|
+
.register_middleware(curl_logger: Rspeckled::Faraday::Middleware::CurlLogger)
|
@@ -6,7 +6,10 @@ require 'rspeckled/plugins/extensions/omniauth/mock_authentications/twitter'
|
|
6
6
|
|
7
7
|
::OmniAuth.configure do |config|
|
8
8
|
# Setup Mocks for Common Services
|
9
|
-
config.mock_auth[:facebook] =
|
10
|
-
|
11
|
-
config.mock_auth[:
|
9
|
+
config.mock_auth[:facebook] =
|
10
|
+
::Rspeckled::OmniAuth::MockAuthentications::Facebook.authentication
|
11
|
+
config.mock_auth[:twitter] =
|
12
|
+
::Rspeckled::OmniAuth::MockAuthentications::Twitter.authentication
|
13
|
+
config.mock_auth[:ebay] =
|
14
|
+
::Rspeckled::OmniAuth::MockAuthentications::Ebay.authentication
|
12
15
|
end
|
@@ -8,6 +8,8 @@ module Ruby
|
|
8
8
|
class DeferredGarbageCollection
|
9
9
|
THRESHOLD = (ENV['DEFER_GC'] || 20.0).to_f
|
10
10
|
|
11
|
+
private_constant :THRESHOLD
|
12
|
+
|
11
13
|
@garbage_last_collected_at = nil
|
12
14
|
|
13
15
|
def self.start
|
@@ -33,7 +35,7 @@ class DeferredGarbageCollection
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def self.enabled?
|
36
|
-
THRESHOLD
|
38
|
+
THRESHOLD > 0
|
37
39
|
end
|
38
40
|
|
39
41
|
def self.time_since_garbage_last_collected
|
@@ -13,16 +13,16 @@ class Chrome
|
|
13
13
|
def driver(app)
|
14
14
|
::Capybara::Selenium::Driver.new(
|
15
15
|
app,
|
16
|
-
:
|
17
|
-
:
|
16
|
+
browser: :chrome,
|
17
|
+
options: options,
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
21
|
def headless(app)
|
22
22
|
::Capybara::Selenium::Driver.new(
|
23
23
|
app,
|
24
|
-
:
|
25
|
-
:
|
24
|
+
browser: :chrome,
|
25
|
+
options: headless_options,
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
@@ -36,8 +36,8 @@ class Chrome
|
|
36
36
|
|
37
37
|
def options
|
38
38
|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
|
39
|
-
browser_options.add_preference(:profile, :
|
40
|
-
browser_options.add_preference(:download, :
|
39
|
+
browser_options.add_preference(:profile, prompt_for_download: { popups: 0 })
|
40
|
+
browser_options.add_preference(:download, default_directory: downloads_directory)
|
41
41
|
browser_options.add_argument('--window-size=1920,1200')
|
42
42
|
browser_options
|
43
43
|
end
|