pludoni_rspec 0.11 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c466a7c113bf41e61ead34a21d8666c036d09546b047796c8c36cbf86eb95a30
4
- data.tar.gz: f83e2c29694819e70f5e1764ac92149c54029ef05eab94d0d8d5c5d21c36f937
3
+ metadata.gz: 897a5ac1427f82428f620f7d860ae26c1f2d17ba654f656baa646f26d42876fc
4
+ data.tar.gz: 6e3bd7d8bdf3292ea15c071115d09c5b1caa2f96d9a505088d649f7efcf2b7f0
5
5
  SHA512:
6
- metadata.gz: 810faf546e1d8b267fb03ed3034fce9985d37484482befb490a0bf33206870d35c673fed0f4be6277a46315c63aa991e81d5637e3f78482df8fa0b1e4b974b32
7
- data.tar.gz: f5e335409f4ecb041ffbbabe2de88cf81b3c63f080eed031d74bf55fd315da8b1466bd10257e4e8855115e3bef47e0eabe4ab7ff8c47d48669158e6e7bf169d7
6
+ metadata.gz: 06ffcb0a2cd67c7cc7af74cf96c10eb18a575c59e23b22300fb3031426179cc2e866d6afb9cc943badb5ce46f3b7297de902b09afaa3160982bf0f44cee9d783
7
+ data.tar.gz: f72de2ea77aaf4f182a376f6ab35a9bcec5f16128c9ddd1778f79a0511945b7cb3bf06545b69e053858fc60b24fad8812a04f42379a92dfadaad0874213ee0d6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
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
+
1
17
  ### 0.11
2
18
 
3
19
  - Rails 7.1 fixture_paths deprecation
data/Gemfile.lock CHANGED
@@ -1,10 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pludoni_rspec (0.11)
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,6 +9,7 @@ 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,
@@ -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,9 +1,12 @@
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)
@@ -21,7 +24,7 @@ RSpec.configure do |config|
21
24
 
22
25
  config.bisect_runner = :shell
23
26
  config.order = :defined
24
- if Rails.version.to_f >= 7.1
27
+ if config.respond_to?(:fixture_paths)
25
28
  config.fixture_paths ||= []
26
29
  config.fixture_paths << "#{::Rails.root}/spec/fixtures"
27
30
  else
@@ -57,9 +60,42 @@ RSpec.configure do |config|
57
60
  end
58
61
 
59
62
  config.around(:each, :timeout) do |example|
60
- time = 10 unless time.kind_of?(Numeric)
63
+ time = 10 unless time.is_a?(Numeric)
61
64
  Timeout.timeout(time) do
62
65
  example.run
63
66
  end
64
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
+
65
101
  end
@@ -1,3 +1,3 @@
1
1
  module PludoniRspec
2
- VERSION = "0.11".freeze
2
+ VERSION = "0.20".freeze
3
3
  end
data/lib/pludoni_rspec.rb CHANGED
@@ -1,15 +1,10 @@
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
12
- attr_accessor :coverage_enabled
7
+ attr_accessor :destroy_headless, :wrap_js_spec_in_headless, :chrome_arguments, :capybara_timeout, :coverage_enabled
13
8
  end
14
9
  # self.chrome_driver_version = "2.36"
15
10
  self.destroy_headless = false
@@ -18,6 +13,7 @@ module PludoniRspec
18
13
  self.capybara_timeout = ENV['CI'] == '1' ? 30 : 5
19
14
  self.coverage_enabled = true
20
15
  end
16
+
21
17
  def self.run
22
18
  ENV["RAILS_ENV"] ||= 'test'
23
19
  coverage! if Config.coverage_enabled
@@ -29,6 +25,8 @@ module PludoniRspec
29
25
  require 'pludoni_rspec/cuprite'
30
26
  require 'pludoni_rspec/freeze_time'
31
27
  require 'pludoni_rspec/shared_context'
28
+ require 'pludoni_rspec/formatter'
29
+ RSpec.configuration.default_formatter = 'EnhancedDocumentationFormatter'
32
30
  if defined?(VCR)
33
31
  require 'pludoni_rspec/vcr'
34
32
  end
@@ -43,7 +41,7 @@ module PludoniRspec
43
41
  if File.exist?('coverage/.resultset.json') && (
44
42
  File.ctime('coverage/.resultset.json') < (Time.now - 900) ||
45
43
  (JSON.parse(File.read('coverage/.resultset.json')).keys.length > 4)
46
- )
44
+ )
47
45
  File.unlink('coverage/.resultset.json')
48
46
  if File.exist?('coverage/.resultset.json.lock')
49
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.11'
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-12-18 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