pludoni_rspec 0.10.1 → 0.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c83d9b2141173a041d9e1663c691b04a205c4de33c18926461daee3b9ae391d4
4
- data.tar.gz: 778e72c29d450c283e6a9ce286e5620029a109aa431f9052c8faa45084c055fb
3
+ metadata.gz: 897a5ac1427f82428f620f7d860ae26c1f2d17ba654f656baa646f26d42876fc
4
+ data.tar.gz: 6e3bd7d8bdf3292ea15c071115d09c5b1caa2f96d9a505088d649f7efcf2b7f0
5
5
  SHA512:
6
- metadata.gz: 8f1cade64c4f782b06b41c68421bbfc8306f0e17b970a89ec5db5a0ac052e8a8a6f8b96e9ab80a40ae902c5a02c0f34ae7ed546adfd53cf236aa0f3c54420538
7
- data.tar.gz: ead4bb043bd20908efdb7cca782e9712e18be8e637af8cc4c50d8c060a4c19e08637a0f5c5e3b6919a7b6545bb45da37895d1aeae771d144747236ba6ecb47b9
6
+ metadata.gz: 06ffcb0a2cd67c7cc7af74cf96c10eb18a575c59e23b22300fb3031426179cc2e866d6afb9cc943badb5ce46f3b7297de902b09afaa3160982bf0f44cee9d783
7
+ data.tar.gz: f72de2ea77aaf4f182a376f6ab35a9bcec5f16128c9ddd1778f79a0511945b7cb3bf06545b69e053858fc60b24fad8812a04f42379a92dfadaad0874213ee0d6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ### 0.20
2
+
3
+ - Added new default custom formatter instead of fuubar - Documentation based,
4
+ but prints out duration and file paths of the group
5
+ - Disable Smooth Scrolling for Cuprite
6
+ - Fix: Rails 7.1 `fixture_path` or `fixture_paths`
7
+ - Add: 3 new global helpers:
8
+ - ``only_run_when_single_spec_and_local!``
9
+ skip this example, only run if you are working on it and skip it later like special customers bugs etc.,
10
+ long running crawler etc. that you want to run occasionally
11
+ - ``local!``
12
+ For System specs:
13
+ prints the instructions to open the current page in your local browser if
14
+ you run the specs remotely, create a SSH tunnel to the server during
15
+ system specs and open the brOwser on your local machine
16
+
17
+ ### 0.11
18
+
19
+ - Rails 7.1 fixture_paths deprecation
20
+ - Cuprite with ``LD_PRELOAD => ""`` to fix jmalloc errors
21
+ - Added ``PludoniRspec.coverage_enabled`` to make it possible to disable coverage
22
+ - Support Fabrication Gem versions
23
+
1
24
  ### 0.10
2
25
 
3
26
  - Optional Vite build before first system spec
data/Gemfile.lock CHANGED
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pludoni_rspec (0.10.1)
4
+ pludoni_rspec (0.20)
5
5
  capybara (>= 3.13.2)
6
6
  cuprite
7
- fuubar (>= 2.3.1)
8
7
  headless (>= 2.3.1)
9
8
  pry-rails
10
9
  puma
@@ -37,9 +36,6 @@ GEM
37
36
  concurrent-ruby (~> 1.1)
38
37
  webrick (~> 1.7)
39
38
  websocket-driver (>= 0.6, < 0.8)
40
- fuubar (2.5.1)
41
- rspec-core (~> 3.0)
42
- ruby-progressbar (~> 1.4)
43
39
  headless (2.3.1)
44
40
  matrix (0.4.2)
45
41
  method_source (1.0.0)
@@ -69,7 +65,6 @@ GEM
69
65
  rspec-support (3.12.0)
70
66
  rspec_junit_formatter (0.6.0)
71
67
  rspec-core (>= 2, < 4, != 2.12.0)
72
- ruby-progressbar (1.13.0)
73
68
  simplecov (0.22.0)
74
69
  docile (~> 1.1)
75
70
  simplecov-html (~> 0.11)
@@ -9,10 +9,12 @@ Capybara.register_driver(:cuprite_pl) do |app|
9
9
  if ENV['CI']
10
10
  options['no-sandbox'] = nil
11
11
  end
12
+ options['disable-smooth-scrolling'] = true
12
13
  Capybara::Cuprite::Driver.new(app,
13
14
  window_size: [1200, 800],
14
15
  browser_options: options,
15
16
  js_errors: true,
17
+ env: { "LD_PRELOAD" => "" },
16
18
  timeout: 20,
17
19
  process_timeout: 15,
18
20
  inspector: ENV['INSPECTOR']
@@ -0,0 +1,48 @@
1
+ require 'rspec/core'
2
+ require 'rspec/core/formatters/documentation_formatter'
3
+
4
+ class EnhancedDocumentationFormatter < RSpec::Core::Formatters::DocumentationFormatter
5
+ RSpec::Core::Formatters.register self, :example_group_started, :example_group_finished,
6
+ :example_passed, :example_pending, :example_failed
7
+
8
+ class << self
9
+ attr_accessor :threshold_for_good, :threshold_for_bad
10
+ end
11
+ self.threshold_for_good = 0.2
12
+ self.threshold_for_bad = 2
13
+
14
+ def example_group_started(notification)
15
+ output.puts if @group_level == 0
16
+ filename = if @group_level == 0
17
+ RSpec::Core::Formatters::ConsoleCodes.wrap(notification.group.file_path, :gray)
18
+ end
19
+ output.puts "#{current_indentation}#{notification.group.description.strip} #{filename}"
20
+
21
+ @group_level += 1
22
+ end
23
+
24
+ private
25
+
26
+ def passed_output(example)
27
+ super + " " + duration(example)
28
+ end
29
+
30
+ def failure_output(example)
31
+ super + " " + duration(example)
32
+ end
33
+
34
+ def pending_output(example, message)
35
+ super + " " + duration(example)
36
+ end
37
+
38
+ def duration(example)
39
+ time = example.metadata[:execution_result][:run_time]
40
+ if time < self.class.threshold_for_good
41
+ RSpec::Core::Formatters::ConsoleCodes.wrap("#{(time * 1000).round}ms", :black)
42
+ elsif time > self.class.threshold_for_bad
43
+ RSpec::Core::Formatters::ConsoleCodes.wrap("#{time.round(2)}s", :red)
44
+ else
45
+ RSpec::Core::Formatters::ConsoleCodes.wrap("#{time.round(2)}s", :yellow)
46
+ end
47
+ end
48
+ end
@@ -1,13 +1,20 @@
1
1
  RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActiveSupport::CurrentAttributes.reset_all if defined?(ActiveSupport::CurrentAttributes)
4
+ end
2
5
  config.example_status_persistence_file_path = 'tmp/rspec.failed.txt'
3
6
  config.expect_with :rspec do |expectations|
4
7
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
5
8
  end
6
- config.include RSpec::Rails::RequestExampleGroup, type: :request, file_path: /spec\/api/
9
+ config.include RSpec::Rails::RequestExampleGroup, type: :request, file_path: %r{spec/api}
7
10
  config.before do
8
11
  I18n.locale = I18n.default_locale
9
12
  if defined?(Fabrication)
10
- Fabrication::Sequencer.reset
13
+ if Fabrication::Sequencer.respond_to?(:clear)
14
+ Fabrication::Sequencer.clear
15
+ else
16
+ Fabrication::Sequencer.reset
17
+ end
11
18
  end
12
19
  end
13
20
 
@@ -17,7 +24,12 @@ RSpec.configure do |config|
17
24
 
18
25
  config.bisect_runner = :shell
19
26
  config.order = :defined
20
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
27
+ if config.respond_to?(:fixture_paths)
28
+ config.fixture_paths ||= []
29
+ config.fixture_paths << "#{::Rails.root}/spec/fixtures"
30
+ else
31
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
32
+ end
21
33
  config.infer_spec_type_from_file_location!
22
34
  config.use_transactional_fixtures = true
23
35
  if defined?(ActionMailer::Base)
@@ -48,9 +60,42 @@ RSpec.configure do |config|
48
60
  end
49
61
 
50
62
  config.around(:each, :timeout) do |example|
51
- time = 10 unless time.kind_of?(Numeric)
63
+ time = 10 unless time.is_a?(Numeric)
52
64
  Timeout.timeout(time) do
53
65
  example.run
54
66
  end
55
67
  end
68
+
69
+ # helper method for below
70
+ def current_file_is_the_only_spec?
71
+ file = caller.find { |c| c =~ /_spec\.rb/ }.split(':').first
72
+ file = Pathname.new(file).relative_path_from(Rails.root).to_s
73
+ ARGV.any? { |arg| arg.include?(file) }
74
+ end
75
+
76
+ # skip this example, only run if you are working on it and skip it later
77
+ # like special customers bugs etc.
78
+ def only_run_when_single_spec_and_local!
79
+ if ENV['CI'] || !current_file_is_the_only_spec?
80
+ skip "Only run when run as a single spec and not CI set"
81
+ end
82
+ end
83
+
84
+ # For System specs:
85
+ # prints the instructions to open the current page in your local browser
86
+ # if you run the specs remotely, create a SSH tunnel to the server during system specs
87
+ # and open the brOwser on your local machine
88
+ def local!
89
+ uri = URI.parse(page.current_url)
90
+ puts "--- Connect with local browser:"
91
+ puts " 1. Open a SSH tunnel with port forwarding to the test server:"
92
+ puts "\nssh #{ENV['LOGNAME']}@pludoni.com -L 8080:localhost:#{uri.port}\n"
93
+ puts " 2. Open in Browser: "
94
+ uri.port = nil
95
+ uri.scheme = nil
96
+ uri.host = nil
97
+ puts "\nhttp://localhost:8080#{uri}\n"
98
+ puts " Afterwards, you can close the SSH session"
99
+ end
100
+
56
101
  end
@@ -1,3 +1,3 @@
1
1
  module PludoniRspec
2
- VERSION = "0.10.1".freeze
2
+ VERSION = "0.20".freeze
3
3
  end
data/lib/pludoni_rspec.rb CHANGED
@@ -1,24 +1,22 @@
1
1
  require "pludoni_rspec/version"
2
2
  require 'json'
3
3
 
4
- # rubocop:disable Rails/FilePath
5
4
  module PludoniRspec
6
5
  class Config
7
6
  class << self
8
- attr_accessor :destroy_headless
9
- attr_accessor :wrap_js_spec_in_headless
10
- attr_accessor :chrome_arguments
11
- attr_accessor :capybara_timeout
7
+ attr_accessor :destroy_headless, :wrap_js_spec_in_headless, :chrome_arguments, :capybara_timeout, :coverage_enabled
12
8
  end
13
9
  # self.chrome_driver_version = "2.36"
14
10
  self.destroy_headless = false
15
11
  self.wrap_js_spec_in_headless = RbConfig::CONFIG['host_os']['linux']
16
12
  # self.chrome_arguments = ['headless', 'disable-gpu', "window-size=1600,1200", 'no-sandbox', 'disable-dev-shm-usage', 'lang=de']
17
13
  self.capybara_timeout = ENV['CI'] == '1' ? 30 : 5
14
+ self.coverage_enabled = true
18
15
  end
16
+
19
17
  def self.run
20
18
  ENV["RAILS_ENV"] ||= 'test'
21
- coverage!
19
+ coverage! if Config.coverage_enabled
22
20
  require 'pry'
23
21
  require File.expand_path("config/environment", Dir.pwd)
24
22
  abort("The Rails environment is running in production mode!") if Rails.env.production?
@@ -27,6 +25,8 @@ module PludoniRspec
27
25
  require 'pludoni_rspec/cuprite'
28
26
  require 'pludoni_rspec/freeze_time'
29
27
  require 'pludoni_rspec/shared_context'
28
+ require 'pludoni_rspec/formatter'
29
+ RSpec.configuration.default_formatter = 'EnhancedDocumentationFormatter'
30
30
  if defined?(VCR)
31
31
  require 'pludoni_rspec/vcr'
32
32
  end
@@ -41,7 +41,7 @@ module PludoniRspec
41
41
  if File.exist?('coverage/.resultset.json') && (
42
42
  File.ctime('coverage/.resultset.json') < (Time.now - 900) ||
43
43
  (JSON.parse(File.read('coverage/.resultset.json')).keys.length > 4)
44
- )
44
+ )
45
45
  File.unlink('coverage/.resultset.json')
46
46
  if File.exist?('coverage/.resultset.json.lock')
47
47
  File.unlink('coverage/.resultset.json.lock')
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  # spec.add_dependency "vcr", ">= 3.0.0"
24
24
  # spec.add_dependency "geckodriver-helper", ">= 0.23.0"
25
25
  spec.add_dependency 'capybara', ">= 3.13.2"
26
- spec.add_dependency 'fuubar', '>= 2.3.1'
26
+ # spec.add_dependency 'fuubar', '>= 2.3.1'
27
27
  spec.add_dependency 'headless', ">= 2.3.1"
28
28
  spec.add_dependency 'pry-rails'
29
29
  spec.add_dependency 'puma'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pludoni_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: '0.20'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Wienert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.13.2
27
- - !ruby/object:Gem::Dependency
28
- name: fuubar
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.3.1
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.3.1
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: headless
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +173,7 @@ files:
187
173
  - lib/pludoni_rspec.rb
188
174
  - lib/pludoni_rspec/cuprite.rb
189
175
  - lib/pludoni_rspec/devise.rb
176
+ - lib/pludoni_rspec/formatter.rb
190
177
  - lib/pludoni_rspec/freeze_time.rb
191
178
  - lib/pludoni_rspec/shared_context.rb
192
179
  - lib/pludoni_rspec/spec_helper.rb