rspeckled 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rspeckled/helpers/factories.rb +8 -2
  4. data/lib/rspeckled/helpers/filepaths.rb +30 -22
  5. data/lib/rspeckled/helpers/null_objects.rb +8 -2
  6. data/lib/rspeckled/helpers/patterns.rb +75 -41
  7. data/lib/rspeckled/helpers/responses.rb +8 -2
  8. data/lib/rspeckled/patches.rb +8 -6
  9. data/lib/rspeckled/plugins/configuration/capybara_screenshot.rb +5 -4
  10. data/lib/rspeckled/plugins/configuration/carrier_wave.rb +1 -1
  11. data/lib/rspeckled/plugins/configuration/devise.rb +4 -4
  12. data/lib/rspeckled/plugins/configuration/dox.rb +4 -4
  13. data/lib/rspeckled/plugins/configuration/email_spec.rb +3 -3
  14. data/lib/rspeckled/plugins/configuration/factory_bot.rb +2 -2
  15. data/lib/rspeckled/plugins/configuration/shoulda.rb +2 -2
  16. data/lib/rspeckled/plugins/configuration/vcr.rb +6 -4
  17. data/lib/rspeckled/plugins/configuration/warden.rb +3 -2
  18. data/lib/rspeckled/plugins/extensions/awesome_print.rb +20 -7
  19. data/lib/rspeckled/plugins/extensions/capybara.rb +16 -6
  20. data/lib/rspeckled/plugins/extensions/faraday/middleware/curl_logger.rb +10 -3
  21. data/lib/rspeckled/plugins/extensions/faraday.rb +2 -1
  22. data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/ebay.rb +1 -1
  23. data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/facebook.rb +1 -1
  24. data/lib/rspeckled/plugins/extensions/omniauth/mock_authentications/twitter.rb +1 -1
  25. data/lib/rspeckled/plugins/extensions/omniauth.rb +6 -3
  26. data/lib/rspeckled/plugins/extensions/ruby/deferred_garbage_collection.rb +3 -1
  27. data/lib/rspeckled/plugins/extensions/selenium/drivers/chrome.rb +6 -6
  28. data/lib/rspeckled/plugins/extensions/selenium/drivers/firefox.rb +14 -3
  29. data/lib/rspeckled/plugins/extensions/strong_parameters.rb +2 -1
  30. data/lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb +3 -1
  31. data/lib/rspeckled/plugins/extensions/vcr.rb +8 -4
  32. data/lib/rspeckled/plugins/hooks/action_mailer.rb +2 -2
  33. data/lib/rspeckled/plugins/hooks/authentication.rb +87 -61
  34. data/lib/rspeckled/plugins/hooks/bullet.rb +3 -1
  35. data/lib/rspeckled/plugins/hooks/capybara.rb +2 -2
  36. data/lib/rspeckled/plugins/hooks/carrier_wave.rb +2 -2
  37. data/lib/rspeckled/plugins/hooks/database_cleaner.rb +2 -2
  38. data/lib/rspeckled/plugins/hooks/devise.rb +1 -1
  39. data/lib/rspeckled/plugins/hooks/dox.rb +1 -1
  40. data/lib/rspeckled/plugins/hooks/elasticsearch.rb +13 -9
  41. data/lib/rspeckled/plugins/hooks/factory_bot.rb +1 -1
  42. data/lib/rspeckled/plugins/hooks/foreign_keys.rb +21 -13
  43. data/lib/rspeckled/plugins/hooks/garbage_collection.rb +1 -1
  44. data/lib/rspeckled/plugins/hooks/rails.rb +5 -3
  45. data/lib/rspeckled/plugins/hooks/redis.rb +3 -3
  46. data/lib/rspeckled/plugins/hooks/referehencible.rb +2 -2
  47. data/lib/rspeckled/plugins/hooks/request.rb +1 -1
  48. data/lib/rspeckled/plugins/hooks/rspec_mocks.rb +8 -4
  49. data/lib/rspeckled/plugins/hooks/selenium_webdriver.rb +2 -2
  50. data/lib/rspeckled/plugins/hooks/sidekiq.rb +14 -12
  51. data/lib/rspeckled/plugins/hooks/singletons.rb +2 -2
  52. data/lib/rspeckled/plugins/hooks/stripe.rb +5 -3
  53. data/lib/rspeckled/plugins/hooks/timecop.rb +3 -3
  54. data/lib/rspeckled/plugins/hooks/vcr.rb +2 -2
  55. data/lib/rspeckled/plugins/hooks/warden.rb +3 -3
  56. data/lib/rspeckled/plugins/hooks/webmock.rb +3 -3
  57. data/lib/rspeckled/plugins.rb +22 -19
  58. data/lib/rspeckled/reporting/example.rb +10 -8
  59. data/lib/rspeckled/reporting/outputs/csv.rb +2 -0
  60. data/lib/rspeckled/reporting/outputs/text.rb +17 -15
  61. data/lib/rspeckled/reporting/runner.rb +26 -24
  62. data/lib/rspeckled/spec_helpers/active_record_connection_setup.rb +13 -9
  63. data/lib/rspeckled/spec_helpers/rails_engine.rb +2 -2
  64. data/lib/rspeckled/spec_helpers/rspeckled.rb +17 -1
  65. data/lib/rspeckled/support.rb +26 -24
  66. data/lib/rspeckled/tasks/documentation.rake +28 -8
  67. data/lib/rspeckled/version.rb +3 -1
  68. data.tar.gz.sig +0 -0
  69. metadata +29 -28
  70. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3b8cccd497ccd83e6f4b27a8fad8b56075f200b125ac8ed1997414c03b43c12
4
- data.tar.gz: b77e539983d78932cfaa985dc6afe76bd1a96afda5f82ecf79bd16a5a3b1646b
3
+ metadata.gz: e484c27875d11ad339323acb0fddce0149da40599a29a0bdc681b516cd23c30d
4
+ data.tar.gz: 96bdd424872fd1ce9d902f058c6dc265ec57a27f41c5a984546735d0c67db27d
5
5
  SHA512:
6
- metadata.gz: 4fb53c317f05daa7d0a931f2ed64d94f64980d9fd3464007d322a46b0f74a1b3b346d5e4869ff22644d730d47d73dc6b386f2289c5d6baa380487266aee8844e
7
- data.tar.gz: aba403188f34e8b5b42f2c75ce83b2432abb250db9b38339ed09eb02d0b8e2edeb49a39750bdf0cc25355263cfadc4a69d6b413cc56da4fd6d33c550a570f847
6
+ metadata.gz: f852e036ef89d0677db67f9a1c4932704b2f649346902f18c38da5925dc0787d087f6d33529abc6ba6cbdb35c702ca39f557294851d9e6c849f17a16fc5182fe
7
+ data.tar.gz: bbc31cc93b5a8bd243283a47bb6a2b398f2966766644f7fbdcd10deca6c03577a68b9575ffda476629354b3d1e5a9418f2ce11bd67697ae01ff18a09363f1995
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- def factory_name
4
- described_class.name.underscore
3
+ module Rspeckled
4
+ module Helpers
5
+ module Factories
6
+ def factory_name
7
+ described_class.name.underscore
8
+ end
9
+ end
10
+ end
5
11
  end
@@ -1,32 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- def root_filepath
4
- @root_filepath ||= begin
5
- current_directory = Dir.pwd
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
- current_directory += '/..' until Dir.exist?(current_directory + '/spec')
10
+ until ::Dir.exist?("#{current_directory}/spec")
11
+ current_directory += '/..'
12
+ end
8
13
 
9
- File.expand_path(current_directory)
10
- end
11
- end
14
+ ::File.expand_path(current_directory)
15
+ end
16
+ end
12
17
 
13
- def fixture_filepath(filepath)
14
- "#{root_filepath}/spec/fixtures/#{filepath}"
15
- end
18
+ def fixture_filepath(filepath)
19
+ "#{root_filepath}/spec/fixtures/#{filepath}"
20
+ end
16
21
 
17
- def read_fixture(filepath)
18
- ::File.read(fixture_filepath(filepath))
19
- end
22
+ def read_fixture(filepath)
23
+ ::File.read(fixture_filepath(filepath))
24
+ end
20
25
 
21
- def parse_fixture(filepath)
22
- contents = read_fixture(filepath)
26
+ def parse_fixture(filepath)
27
+ contents = read_fixture(filepath)
23
28
 
24
- case filepath[/\.\w+\z/]
25
- when '.json'
26
- ::JSON.parse(contents)
27
- when '.eml'
28
- ::Mail.new(contents)
29
- else
30
- fail ArgumentError, "I don't know how to parse #{filepath}."
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
- def null_described_class
4
- "Null#{described_class.name}".constantize
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
- def uuid_regex
4
- /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i
5
- end
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
- /(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?((?:[\+\-]\d{2}:\d{2})|Z)?/
9
- end
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
- %r{[a-z0-9\+/=]}i
13
- end
42
+ def base64_digit_regex
43
+ %r{[a-z0-9+/=]}i
44
+ end
14
45
 
15
- def hex_digit_regex
16
- /[a-f0-9]/i
17
- end
46
+ def hex_digit_regex
47
+ /[a-f0-9]/i
48
+ end
18
49
 
19
- def guid_regex
20
- /[a-f0-9]{32}/i
21
- end
50
+ def guid_regex
51
+ /[a-f0-9]{32}/i
52
+ end
22
53
 
23
- def md5_regex
24
- /[a-f0-9]{32}/i
25
- end
54
+ def md5_regex
55
+ /[a-f0-9]{32}/i
56
+ end
26
57
 
27
- def sha_regex
28
- /[a-f0-9]{64}/i
29
- end
58
+ def sha_regex
59
+ /[a-f0-9]{64}/i
60
+ end
30
61
 
31
- def test_email_regex
32
- /user\d+@example.com/
33
- end
62
+ def test_email_regex
63
+ /user\d+@example.com/
64
+ end
34
65
 
35
- def test_username_regex
36
- /username\d+/
37
- end
66
+ def test_username_regex
67
+ /username\d+/
68
+ end
38
69
 
39
- def json_web_token_base64_regex
40
- %r{[A-Za-z0-9_/\+\=\-]}
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
- (#{json_web_token_base64_regex}+?\.){2}
46
- #{json_web_token_base64_regex}+?
47
- /x
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
- (#{json_web_token_base64_regex}+?\.){4}
53
- #{json_web_token_base64_regex}+?
54
- /x
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
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- def json_response
4
- JSON.load(response.body) # rubocop:disable Security/JSONLoad
3
+ module Rspeckled
4
+ module Helpers
5
+ module Responses
6
+ def json_response
7
+ JSON.parse(response.body)
8
+ end
9
+ end
10
+ end
5
11
  end
@@ -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
- if ::Pathname.pwd.join('spec', 'dummy', 'config', 'environment.rb').exist?
11
- require 'rspeckled/patches/rails/namespaced_engine_controller_route_fix'
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
- config.include Rspeckled::NamespacedEngineControllerRouteFix, :type => :controller
14
- end
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
- ::Capybara::Screenshot.register_driver(:chrome) { |driver, path| driver.browser.save_screenshot(path) }
15
- ::Capybara::Screenshot.register_driver(:headless_chrome) { |driver, path| driver.browser.save_screenshot(path) }
16
- ::Capybara::Screenshot.register_driver(:firefox) { |driver, path| driver.browser.save_screenshot(path) }
17
- ::Capybara::Screenshot.register_driver(:headless_firefox) { |driver, path| driver.browser.save_screenshot(path) }
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
@@ -9,5 +9,5 @@ require 'carrierwave/test/matchers'
9
9
  end
10
10
 
11
11
  RSpec.configure do |config|
12
- config.include ::CarrierWave::Test::Matchers, :file_attachment => true
12
+ config.include ::CarrierWave::Test::Matchers, file_attachment: true
13
13
  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, :type => :controller)
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, :type => :controller)
12
+ config.include(::Devise::Test::ControllerHelpers, type: :controller)
13
13
 
14
- [:system, :feature, :request].each do |type|
14
+ %i{system feature request}.each do |type|
15
15
  defined?(::Devise::Test::IntegrationHelpers) &&
16
- config.include(::Devise::Test::IntegrationHelpers, :type => type)
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
- http_settings = YAML.load(http_settings_file.read) # rubocop:disable Security/YAMLLoad
25
+ http_settings = YAML.unsafe_load(http_settings_file.read)
26
26
 
27
- http_settings['production']['http']['base_url']
27
+ http_settings['production']['http']['base_url']
28
28
  else
29
- 'http://api.lvh.me:5000'
29
+ 'http://api.lvh.me:5000'
30
30
  end
31
31
 
32
32
  unless api_docs_header.exist?
33
- api_docs_header.write(<<~HEREDOC, :mode => 'w')
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, :email => true
5
- config.include ::EmailSpec::Matchers, :email => true
6
- config.include ::EmailSpec::MailerDeliveries, :email => true
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.configuration.factories.count.zero? &&
6
- ::Rails.application.class.name.match(/Dummy/)
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, :type => :model)
5
- config.include(::Shoulda::Matchers::ActiveRecord, :type => :model)
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
- config.ignore_hosts 'lvh.me', 'localhost', '127.0.0.1', '0.0.0.0' # rubocop:disable Style/IpAddresses
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 = ::File.expand_path('./tmp/vcr_cassettes')
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
- :record => :once,
27
- :re_record_interval => 7_776_000,
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
- [:system, :feature, :request].each do |type|
5
- defined?(::Warden::Test::Helpers) && config.include(::Warden::Test::Helpers, :type => type)
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/PerceivedComplexity
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) && message.class.ancestors.include?(::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, :raw => true)
68
+ ap(message.attributes, raw: true)
64
69
  else
65
- ap(message, :raw => true)
70
+ ap(message, raw: true)
66
71
  end
67
72
 
68
73
  puts
69
74
 
70
- if %w{String ActionView::OutputBuffer ActiveSupport::SafeBuffer}.include?(message.class.name)
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 do |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) || ENV['HOST'] || 'lvh.me'
12
- port = (defined?(::Chamber) && ::Chamber.env.http.url_components.port) || ENV['PORT'] || '3000'
13
-
14
- ::Rack::Handler::Puma.run(app, :Host => host, :Port => port, :Threads => '0:1', :Silent => true)
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.new(:downloads_directory => downloads_directory)
23
- firefox_driver = ::Rspeckled::Selenium::Drivers::Firefox.new(:downloads_directory => downloads_directory)
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(STDOUT)
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) { curl_output('request', "#{env[:method].upcase} #{env[:url]}", env[:request_headers], env[:body]) }
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) { curl_output('response', "HTTP #{env[:status]}", env[:response_headers], env[:body]) }
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.register_middleware(:curl_logger => Rspeckled::Faraday::Middleware::CurlLogger)
5
+ ::Faraday::Response
6
+ .register_middleware(curl_logger: Rspeckled::Faraday::Middleware::CurlLogger)
@@ -19,7 +19,7 @@ module Ebay
19
19
  'credentials' => {},
20
20
  'extra' => {
21
21
  'internal_return_to' => nil,
22
- }
22
+ },
23
23
  )
24
24
  end
25
25
  end
@@ -38,7 +38,7 @@ module Facebook
38
38
  'locale' => 'en_US',
39
39
  'updated_time' => '2011-09-11T17:00:51+0000',
40
40
  },
41
- }
41
+ },
42
42
  )
43
43
  end
44
44
  end
@@ -38,7 +38,7 @@ module Twitter
38
38
  'locale' => 'en_US',
39
39
  'updated_time' => '2011-09-11T17:00:51+0000',
40
40
  },
41
- }
41
+ },
42
42
  )
43
43
  end
44
44
  end
@@ -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] = ::Rspeckled::OmniAuth::MockAuthentications::Facebook.authentication
10
- config.mock_auth[:twitter] = ::Rspeckled::OmniAuth::MockAuthentications::Twitter.authentication
11
- config.mock_auth[:ebay] = ::Rspeckled::OmniAuth::MockAuthentications::Ebay.authentication
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.positive?
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
- :browser => :chrome,
17
- :options => options
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
- :browser => :chrome,
25
- :options => headless_options
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, :prompt_for_download => { :popups => 0 })
40
- browser_options.add_preference(:download, :default_directory => downloads_directory)
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