Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retry_callback not working #93

Open
csalvato opened this issue Apr 11, 2018 · 2 comments
Open

retry_callback not working #93

csalvato opened this issue Apr 11, 2018 · 2 comments

Comments

@csalvato
Copy link

Here's my spec helper:

require "codeclimate-test-reporter"
require 'rspec/retry'

CodeClimate::TestReporter.start
FakeBraintree.activate!

RSpec.configure do |config|
  config.full_backtrace=false

  config.before do
    FakeBraintree.clear!
  end

  config.include ShowMeTheCookies, :type => :feature

  config.expect_with :rspec do |expectations|
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  # rspec-mocks config goes here. You can use an alternate test double
  # library (such as bogus or mocha) by changing the `mock_with` option here.
  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
    mocks.verify_doubled_constant_names = true
    # Prevents you from mocking or stubbing a method that does not exist on
    # a real object. This is generally recommended, and will default to
    # `true` in RSpec 4.
    config.around(:each, type: :helper) do |ex|
      config.mock_with :rspec do |mocks|
        mocks.verify_partial_doubles = false
        ex.run
        mocks.verify_partial_doubles = true
      end
    end
  end

  # show retry status in spec process
  config.verbose_retry = true
  # show exception that triggers a retry if verbose_retry is set to true
  config.display_try_failure_messages = true

  # run retry only on features
  config.around :each, :js do |ex|
    ex.run_with_retry retry: 3
  end

  # callback to be run between retries
  config.retry_callback = proc do |ex|
    # restart phantomjs between retries
    if ex.metadata[:js]
      restart_phantomjs
    end
  end

  # Run specs in random order to surface order dependencies. If you find an
  # order dependency and want to debug it, you can fix the order by providing
  # the seed, which is printed after each run.
  #     --seed 1234
  config.order = :random

  config.raise_errors_for_deprecations!
end

def restart_phantomjs
  puts "-> Restarting phantomjs: iterating through capybara sessions..."
  session_pool = Capybara.send('session_pool')
  session_pool.each do |mode,session|
    msg = "  => #{mode} -- "
    driver = session.driver
    if driver.is_a?(Capybara::Poltergeist::Driver)
      msg += "restarting"
      driver.restart
    else
      msg += "not poltergeist: #{driver.class}"
    end
    puts msg
  end
end

But it produces an error because retry_callback does not exist:

╰─$ rspec spec/features/referral_landing_page_spec.rb:43                                                                     1 ↵
bundler: failed to load command: rspec (/Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/bin/rspec)
NoMethodError: undefined method `retry_callback=' for #<RSpec::Core::Configuration:0x007fa296601180>
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/spec/spec_helper.rb:52:in `block in <top (required)>'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core.rb:97:in `configure'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/spec/spec_helper.rb:7:in `<top (required)>'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/spec/rails_helper.rb:13:in `<top (required)>'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/spec/features/referral_landing_page_spec.rb:1:in `require'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/spec/features/referral_landing_page_spec.rb:1:in `<top (required)>'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `load'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `each'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:106:in `setup'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:92:in `run'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/bin/rspec:23:in `load'
  /Users/csalvato/Dropbox/csalvato-home-dropbox/Development/Territory/vendor/bundle/ruby/2.3.0/bin/rspec:23:in `<top (required)>'

Looked at the gem code and can't figure out why. Any advice?

@michaelglass
Copy link
Contributor

what version of them gem are you using?

@xenjke
Copy link

xenjke commented Nov 20, 2019

Works fine on 0.6.1 with exactly the same proc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants