Sha256: 810d8c97091ac057b172966c8cfbdb8df25191a5a69870a2302b24431a2b2602

Contents?: true

Size: 1.38 KB

Versions: 30

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

Capybara::SpecHelper.spec '#matches_style?', requires: [:css] do
  before do
    @session.visit('/with_html')
  end

  it 'should be true if the element has the given style' do
    expect(@session.find(:css, '#first')).to match_style(display: 'block')
    expect(@session.find(:css, '#first').matches_style?(display: 'block')).to be true
    expect(@session.find(:css, '#second')).to match_style('display' => 'inline')
    expect(@session.find(:css, '#second').matches_style?('display' => 'inline')).to be true
  end

  it 'should be false if the element does not have the given style' do
    expect(@session.find(:css, '#first').matches_style?('display' => 'inline')).to be false
    expect(@session.find(:css, '#second').matches_style?(display: 'block')).to be false
  end

  it 'allows Regexp for value matching' do
    expect(@session.find(:css, '#first')).to match_style(display: /^bl/)
    expect(@session.find(:css, '#first').matches_style?('display' => /^bl/)).to be true
    expect(@session.find(:css, '#first').matches_style?(display: /^in/)).to be false
  end

  it 'deprecated has_style?' do
    expect { have_style(display: /^bl/) }.to \
      output(/have_style is deprecated/).to_stderr

    el = @session.find(:css, '#first')
    allow(el).to receive(:warn).and_return(nil)
    el.has_style?('display' => /^bl/)
    expect(el).to have_received(:warn)
  end
end

Version data entries

30 entries across 27 versions & 3 rubygems

Version Path
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/capybara-3.33.0/lib/capybara/spec/session/matches_style_spec.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/capybara-3.32.2/lib/capybara/spec/session/matches_style_spec.rb
capybara-3.33.0 lib/capybara/spec/session/matches_style_spec.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/capybara-3.32.2/lib/capybara/spec/session/matches_style_spec.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/spec/session/matches_style_spec.rb
capybara-3.32.2 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.32.1 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.32.0 lib/capybara/spec/session/matches_style_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/spec/session/matches_style_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/capybara-3.31.0/lib/capybara/spec/session/matches_style_spec.rb
capybara-3.31.0 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.30.0 lib/capybara/spec/session/matches_style_spec.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/spec/session/matches_style_spec.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/spec/session/matches_style_spec.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/spec/session/matches_style_spec.rb
capybara-3.29.0 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.28.0 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.27.0 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.26.0 lib/capybara/spec/session/matches_style_spec.rb
capybara-3.25.0 lib/capybara/spec/session/matches_style_spec.rb