Sha256: 6d29d866497850aacc8e5bb964f371985a31172981ad2aad3ebe027c50ec6402

Contents?: true

Size: 1017 Bytes

Versions: 19

Compression:

Stored size: 1017 Bytes

Contents

RSpec.describe RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation do
  subject(:cop) { described_class.new }

  it 'flags violations for `expect(current_path)`' do
    expect_offense(<<-RUBY)
      expect(current_path).to eq("/callback")
      ^^^^^^ Do not set an RSpec expectation on `current_path` in Capybara feature specs - instead, use the `have_current_path` matcher on `page`
    RUBY
  end

  it 'flags violations for `expect(page.current_path)`' do
    expect_offense(<<-RUBY)
      expect(page.current_path).to eq("/callback")
      ^^^^^^ Do not set an RSpec expectation on `current_path` in Capybara feature specs - instead, use the `have_current_path` matcher on `page`
    RUBY
  end

  it "doesn't flag a violation for other expectations" do
    expect_no_offenses(<<-RUBY)
      expect(current_user).to eq(user)
    RUBY
  end

  it "doesn't flag a violation for other references to `current_path`" do
    expect_no_offenses(<<-RUBY)
      current_path = WalkingRoute.last.path
    RUBY
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rubocop-rspec-1.30.1 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.30.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.29.1 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.29.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.28.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.27.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.26.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.25.1 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.25.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.24.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.23.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.22.2 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.22.1 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.22.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.21.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.20.1 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.20.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.19.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb
rubocop-rspec-1.18.0 spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb