source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/matches_style_spec.rb | Ruby | mit | 10,156 | master | 1,517 | # 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, '#firs... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/html_spec.rb | Ruby | mit | 10,156 | master | 1,530 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_select_spec.rb | Ruby | mit | 10,156 | master | 14,293 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_select?' do
before { @session.visit('/form') }
it 'should be true if the field is on the page' do
expect(@session).to have_select('Locale')
expect(@session).to have_select('form_region')
expect(@session).to have_select('Languages')
expe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/node_spec.rb | Ruby | mit | 10,156 | master | 53,785 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/within_spec.rb | Ruby | mit | 10,156 | master | 6,515 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#within' do
before do
@session.visit('/with_scope')
end
context 'with CSS selector' do
it 'should click links in the given scope' do
@session.within(:css, '#for_bar li:first-child') do
@session.click_link('Go')
end
expect... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/find_link_spec.rb | Ruby | mit | 10,156 | master | 2,460 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#find_link' do
before do
@session.visit('/with_html')
end
it 'should find any link' do
expect(@session.find_link('foo').text).to eq('ullamco')
expect(@session.find_link('labore')[:href]).to match %r{/with_simple_html$}
end
context 'aria_l... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/click_button_spec.rb | Ruby | mit | 10,156 | master | 17,134 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#click_button' do
before do
@session.visit('/form')
end
it 'should wait for asynchronous load', requires: [:js] do
@session.visit('/with_js')
@session.using_wait_time(1.5) do
@session.click_link('Click me')
@session.click_button('N... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/unselect_spec.rb | Ruby | mit | 10,156 | master | 4,279 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#unselect' do
before do
@session.visit('/form')
end
context 'with multiple select' do
it 'should unselect an option from a select box by id' do
@session.unselect('Commando', from: 'form_underwear')
@session.click_button('awesome')
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_current_path_spec.rb | Ruby | mit | 10,156 | master | 5,097 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_current_path?' do
before do
@session.visit('/with_js')
end
it 'should be true if the page has the given current path' do
expect(@session).to have_current_path('/with_js')
end
it 'should allow regexp matches' do
expect(@session).to ha... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/find_spec.rb | Ruby | mit | 10,156 | master | 21,744 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#find' do
before do
@session.visit('/with_html')
end
after do
Capybara::Selector.remove(:monkey)
end
it 'should find the first element using the given locator' do
expect(@session.find('//h1').text).to eq('This is a test')
expect(@sess... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/current_scope_spec.rb | Ruby | mit | 10,156 | master | 836 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#current_scope' do
before do
@session.visit('/with_scope')
end
context 'when not in a #within block' do
it 'should return the document' do
expect(@session.current_scope).to be_a Capybara::Node::Document
end
end
context 'when in a #w... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_text_spec.rb | Ruby | mit | 10,156 | master | 12,862 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_text?' do
it 'should be true if the given text is on the page at least once' do
@session.visit('/with_html')
expect(@session).to have_text('est')
expect(@session).to have_text('Lorem')
expect(@session).to have_text('Redirect')
expect(@... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/node_wrapper_spec.rb | Ruby | mit | 10,156 | master | 1,287 | # frozen_string_literal: true
class NodeWrapper
def initialize(element); @element = element end
def to_capybara_node(); @element end
end
Capybara::SpecHelper.spec '#to_capybara_node' do
before do
@session.visit('/with_html')
end
it 'should support have_xxx expectations' do
para = NodeWrapper.new(@s... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_any_selectors_spec.rb | Ruby | mit | 10,156 | master | 1,024 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#have_any_of_selectors' do
before do
@session.visit('/with_html')
end
it 'should be true if any of the given selectors are on the page' do
expect(@session).to have_any_of_selectors(:css, 'p a#foo', 'h2#blah', 'h2#h2two')
end
it 'should be fal... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/save_and_open_screenshot_spec.rb | Ruby | mit | 10,156 | master | 1,530 | # frozen_string_literal: true
require 'launchy'
Capybara::SpecHelper.spec '#save_and_open_screenshot' do
before do
@session.visit '/'
end
it 'opens file from the default directory', requires: [:screenshot] do
expected_file_regex = /capybara-\d+\.png/
allow(@session.driver).to receive(:save_screensh... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_field_spec.rb | Ruby | mit | 10,156 | master | 15,505 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_field' do
before { @session.visit('/form') }
it 'should be true if the field is on the page' do
expect(@session).to have_field('Dog')
expect(@session).to have_field('form_description')
expect(@session).to have_field('Region')
expect(@se... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_title_spec.rb | Ruby | mit | 10,156 | master | 2,219 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_title?' do
before do
@session.visit('/with_js')
end
it 'should be true if the page has the given title' do
expect(@session).to have_title('with_js')
expect(@session.has_title?('with_js')).to be true
end
it 'should allow regexp matche... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/assert_text_spec.rb | Ruby | mit | 10,156 | master | 9,632 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#assert_text' do
it 'should be true if the given text is on the page' do
@session.visit('/with_html')
expect(@session.assert_text('est')).to be(true)
expect(@session.assert_text('Lorem')).to be(true)
expect(@session.assert_text('Redirect')).to ... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/accept_alert_spec.rb | Ruby | mit | 10,156 | master | 2,507 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#accept_alert', requires: [:modals] do
before do
@session.visit('/with_js')
end
it 'should accept the alert' do
@session.accept_alert do
@session.click_link('Open alert')
end
expect(@session).to have_xpath("//a[@id='open-alert' and @... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/find_button_spec.rb | Ruby | mit | 10,156 | master | 2,277 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#find_button' do
before do
@session.visit('/form')
end
it 'should find any button' do
expect(@session.find_button('med')[:id]).to eq('mediocre')
expect(@session.find_button('crap321').value).to eq('crappy')
end
context 'aria_label attribu... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/selectors_spec.rb | Ruby | mit | 10,156 | master | 3,702 | # frozen_string_literal: true
Capybara::SpecHelper.spec Capybara::Selector do
before do
@session.visit('/form')
end
describe ':label selector' do
it 'finds a label by text' do
expect(@session.find(:label, 'Customer Name').text).to eq 'Customer Name'
end
it 'finds a label by for attribute ... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_element_spec.rb | Ruby | mit | 10,156 | master | 2,061 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_element?' do
before do
@session.visit('/with_html')
end
it 'should be true if the given element is on the page' do
expect(@session).to have_element('a', id: 'foo')
expect(@session).to have_element('a', text: 'A link', href: '/with_simple_... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_table_spec.rb | Ruby | mit | 10,156 | master | 6,886 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_table?' do
before do
@session.visit('/tables')
end
it 'should be true if the table is on the page' do
expect(@session).to have_table('Villain')
expect(@session).to have_table('villain_table')
expect(@session).to have_table(:villain_ta... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/reset_session_spec.rb | Ruby | mit | 10,156 | master | 5,479 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#reset_session!' do
it 'removes cookies from current domain' do
@session.visit('/set_cookie')
@session.visit('/get_cookie')
expect(@session).to have_content('test_cookie')
@session.reset_session!
@session.visit('/get_cookie')
expect(@s... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/title_spec.rb | Ruby | mit | 10,156 | master | 817 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#title' do
it 'should get the title of the page' do
@session.visit('/with_title')
expect(@session.title).to eq('Test Title')
end
context 'with css as default selector' do
before { Capybara.default_selector = :css }
after { Capybara.defaul... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_xpath_spec.rb | Ruby | mit | 10,156 | master | 5,933 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_xpath?' do
before do
@session.visit('/with_html')
end
it 'should be true if the given selector is on the page' do
expect(@session).to have_xpath('//p')
expect(@session).to have_xpath("//p//a[@id='foo']")
expect(@session).to have_xpath... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/dismiss_prompt_spec.rb | Ruby | mit | 10,156 | master | 548 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#dismiss_prompt', requires: [:modals] do
before do
@session.visit('/with_js')
end
it 'should dismiss the prompt' do
@session.dismiss_prompt do
@session.click_link('Open prompt')
end
expect(@session).to have_xpath("//a[@id='open-promp... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/first_spec.rb | Ruby | mit | 10,156 | master | 5,730 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#first' do
before do
@session.visit('/with_html')
end
it 'should find the first element using the given locator' do
expect(@session.first('//h1').text).to eq('This is a test')
expect(@session.first("//input[@id='test_field']").value).to eq('mo... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/attach_file_spec.rb | Ruby | mit | 10,156 | master | 9,413 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#attach_file' do
let(:test_file_path) { File.expand_path('../fixtures/test_file.txt', File.dirname(__FILE__)) }
let(:another_test_file_path) { File.expand_path('../fixtures/another_test_file.txt', File.dirname(__FILE__)) }
let(:test_jpg_file_path) { File.e... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/accept_prompt_spec.rb | Ruby | mit | 10,156 | master | 2,659 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#accept_prompt', requires: [:modals] do
before do
@session.visit('/with_js')
end
it 'should accept the prompt with no message' do
@session.accept_prompt do
@session.click_link('Open prompt')
end
expect(@session).to have_xpath("//a[@i... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/active_element_spec.rb | Ruby | mit | 10,156 | master | 998 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#active_element', requires: [:active_element] do
it 'should return the active element' do
@session.visit('/form')
@session.send_keys(:tab)
expect(@session.active_element).to match_selector(:css, '[tabindex="1"]')
@session.send_keys(:tab)
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/go_back_spec.rb | Ruby | mit | 10,156 | master | 403 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#go_back', requires: [:js] do
it 'should fetch a response from the driver from the previous page' do
@session.visit('/')
expect(@session).to have_content('Hello world!')
@session.visit('/foo')
expect(@session).to have_content('Another World')
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/select_spec.rb | Ruby | mit | 10,156 | master | 7,768 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#select' do
before do
@session.visit('/form')
end
it 'should return value of the first option' do
expect(@session.find_field('Title').value).to eq('Mrs')
end
it 'should return value of the selected option' do
@session.select('Miss', from:... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/visit_spec.rb | Ruby | mit | 10,156 | master | 8,527 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#visit' do
it 'should fetch a response from the driver with a relative url' do
@session.visit('/')
expect(@session).to have_content('Hello world!')
@session.visit('/foo')
expect(@session).to have_content('Another World')
end
it 'should fet... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/fill_in_spec.rb | Ruby | mit | 10,156 | master | 10,659 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#fill_in' do
before do
@session.visit('/form')
end
it 'should fill in a text field by id' do
@session.fill_in('form_first_name', with: 'Harry')
@session.click_button('awesome')
expect(extract_results(@session)['first_name']).to eq('Harry')... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/find_by_id_spec.rb | Ruby | mit | 10,156 | master | 924 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#find_by_id' do
before do
@session.visit('/with_html')
end
it 'should find any element by id' do
expect(@session.find_by_id('red').tag_name).to eq('a')
end
it 'casts to string' do
expect(@session.find_by_id(:red).tag_name).to eq('a')
en... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/evaluate_async_script_spec.rb | Ruby | mit | 10,156 | master | 1,122 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#evaluate_async_script', requires: [:js] do
it 'should evaluate the given script and return whatever it produces' do
@session.visit('/with_js')
expect(@session.evaluate_async_script('arguments[0](4)')).to eq(4)
end
it 'should support passing eleme... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/uncheck_spec.rb | Ruby | mit | 10,156 | master | 4,055 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#uncheck' do
before do
@session.visit('/form')
end
it 'should uncheck a checkbox by id' do
@session.uncheck('form_pets_hamster')
@session.click_button('awesome')
expect(extract_results(@session)['pets']).to include('dog')
expect(extrac... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/evaluate_script_spec.rb | Ruby | mit | 10,156 | master | 1,769 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#evaluate_script', requires: [:js] do
it 'should evaluate the given script and return whatever it produces' do
@session.visit('/with_js')
expect(@session.evaluate_script('1+3')).to eq(4)
end
it 'should ignore leading whitespace' do
@session.vi... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/save_screenshot_spec.rb | Ruby | mit | 10,156 | master | 1,739 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
let(:alternative_path) { File.join(Dir.pwd, 'save_screenshot_tmp') }
before do
@old_save_path = Capybara.save_path
Capybara.save_path = nil
@session.visit '/foo'
end
after do
Capybara.save_pa... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/sibling_spec.rb | Ruby | mit | 10,156 | master | 1,818 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#sibling' do
before do
@session.visit('/with_html')
end
after do
Capybara::Selector.remove(:monkey)
end
it 'should find a prior sibling element using the given locator' do
el = @session.find(:css, '#mid_sibling')
expect(el.sibling('//... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/check_spec.rb | Ruby | mit | 10,156 | master | 10,148 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#check' do
before do
@session.visit('/form')
end
describe "'checked' attribute" do
it 'should be true if checked' do
@session.check('Terms of Use')
expect(@session.find(:xpath, "//input[@id='form_terms_of_use']")['checked']).to be_trut... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/save_page_spec.rb | Ruby | mit | 10,156 | master | 3,434 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#save_page' do
let(:alternative_path) { File.join(Dir.pwd, 'save_and_open_page_tmp') }
before do
@old_save_path = Capybara.save_path
Capybara.save_path = nil
@session.visit('/foo')
end
after do
Capybara.save_path = @old_save_path
Dir... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/choose_spec.rb | Ruby | mit | 10,156 | master | 4,071 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#choose' do
before do
@session.visit('/form')
end
it 'should choose a radio button by id' do
@session.choose('gender_male')
@session.click_button('awesome')
expect(extract_results(@session)['gender']).to eq('male')
end
it 'ignores rea... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/text_spec.rb | Ruby | mit | 10,156 | master | 2,650 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#text' do
it 'should print the text of the page' do
@session.visit('/with_simple_html')
expect(@session.text).to eq('Bar')
end
it 'ignores invisible text by default' do
@session.visit('/with_html')
expect(@session.find(:id, 'hidden-text').... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/current_url_spec.rb | Ruby | mit | 10,156 | master | 3,929 | # frozen_string_literal: true
require 'capybara/spec/test_app'
Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
before :all do # rubocop:disable RSpec/BeforeAfterAll
@servers = Array.new(2) { Capybara::Server.new(TestApp.new).boot }
# sanity check
expect(@servers[0].port).not_to... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/find_field_spec.rb | Ruby | mit | 10,156 | master | 4,166 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#find_field' do
before do
@session.visit('/form')
end
it 'should find any field' do
Capybara.test_id = 'data-test-id'
expect(@session.find_field('Dog').value).to eq('dog')
expect(@session.find_field('form_description').value).to eq('Descri... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_button_spec.rb | Ruby | mit | 10,156 | master | 5,845 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_button?' do
before do
@session.visit('/form')
end
it 'should be true if the given button is on the page' do
expect(@session).to have_button('med')
expect(@session).to have_button('crap321')
expect(@session).to have_button(:crap321)
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/assert_all_of_selectors_spec.rb | Ruby | mit | 10,156 | master | 5,717 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#assert_all_of_selectors' do
before do
@session.visit('/with_html')
end
it 'should be true if the given selectors are on the page' do
@session.assert_all_of_selectors(:css, 'p a#foo', 'h2#h2one', 'h2#h2two')
end
it 'should be false if any of ... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/ancestor_spec.rb | Ruby | mit | 10,156 | master | 3,089 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#ancestor' do
before do
@session.visit('/with_html')
end
after do
Capybara::Selector.remove(:monkey)
end
it 'should find the ancestor element using the given locator' do
el = @session.find(:css, '#first_image')
expect(el.ancestor('//p... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_link_spec.rb | Ruby | mit | 10,156 | master | 3,155 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#has_link?' do
before do
@session.visit('/with_html')
end
it 'should be true if the given link is on the page' do
expect(@session).to have_link('foo')
expect(@session).to have_link('awesome title')
expect(@session).to have_link('A link', h... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/save_and_open_page_spec.rb | Ruby | mit | 10,156 | master | 433 | # frozen_string_literal: true
require 'launchy'
Capybara::SpecHelper.spec '#save_and_open_page' do
before do
@session.visit '/foo'
end
after do
Dir.glob('capybara-*.html').each do |file|
FileUtils.rm(file)
end
end
it 'sends open method to launchy' do
allow(Launchy).to receive(:open)
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_sibling_spec.rb | Ruby | mit | 10,156 | master | 1,508 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#have_sibling' do
before do
@session.visit('/with_html')
end
it 'should assert a prior sibling element using the given locator' do
el = @session.find(:css, '#mid_sibling')
expect(el).to have_sibling(:css, '#pre_sibling')
end
it 'should as... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/refresh_spec.rb | Ruby | mit | 10,156 | master | 1,177 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_all_selectors_spec.rb | Ruby | mit | 10,156 | master | 2,514 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#have_all_of_selectors' do
before do
@session.visit('/with_html')
end
it 'should be true if the given selectors are on the page' do
expect(@session).to have_all_of_selectors(:css, 'p a#foo', 'h2#h2one', 'h2#h2two')
end
it 'should be false if ... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/screenshot_spec.rb | Ruby | mit | 10,156 | master | 436 | # coding: US-ASCII
# frozen_string_literal: true
Capybara::SpecHelper.spec '#save_screenshot' do
let(:image_path) { File.join(Dir.tmpdir, 'capybara-screenshot.png') }
before do
@session.visit '/'
end
it 'should generate PNG file', requires: [:screenshot] do
path = @session.save_screenshot image_path
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/response_code_spec.rb | Ruby | mit | 10,156 | master | 234 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#status_code' do
it 'should return response codes', requires: [:status_code] do
@session.visit('/with_simple_html')
expect(@session.status_code).to eq(200)
end
end |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/has_none_selectors_spec.rb | Ruby | mit | 10,156 | master | 2,887 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#have_none_of_selectors' do
before do
@session.visit('/with_html')
end
it 'should be false if any of the given locators are on the page' do
expect do
expect(@session).to have_none_of_selectors(:xpath, '//p', '//a')
end.to raise_error RSp... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/dismiss_confirm_spec.rb | Ruby | mit | 10,156 | master | 1,048 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#dismiss_confirm', requires: [:modals] do
before do
@session.visit('/with_js')
end
it 'should dismiss the confirm' do
@session.dismiss_confirm do
@session.click_link('Open confirm')
end
expect(@session).to have_xpath("//a[@id='open-c... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/assert_style_spec.rb | Ruby | mit | 10,156 | master | 981 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#assert_matches_style', requires: [:css] do
it 'should not raise if the elements style contains the given properties' do
@session.visit('/with_html')
expect do
@session.find(:css, '#first').assert_matches_style(display: 'block')
end.not_to ra... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/frame/within_frame_spec.rb | Ruby | mit | 10,156 | master | 3,968 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#within_frame', requires: [:frames] do
before do
@session.visit('/within_frames')
end
it 'should find the div in frameOne' do
@session.within_frame('frameOne') do
expect(@session.find("//*[@id='divInFrameOne']").text).to eql 'This is the tex... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/frame/frame_title_spec.rb | Ruby | mit | 10,156 | master | 639 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#frame_title', requires: [:frames] do
before do
@session.visit('/within_frames')
end
it 'should return the title in a frame' do
@session.within_frame('frameOne') do
expect(@session.driver.frame_title).to eq 'This is the title of frame one'
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/frame/frame_url_spec.rb | Ruby | mit | 10,156 | master | 607 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#frame_url', requires: [:frames] do
before do
@session.visit('/within_frames')
end
it 'should return the url in a frame' do
@session.within_frame('frameOne') do
expect(@session.driver.frame_url).to end_with '/frame_one'
end
end
it '... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/frame/switch_to_frame_spec.rb | Ruby | mit | 10,156 | master | 4,634 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#switch_to_frame', requires: [:frames] do
before do
@session.visit('/within_frames')
end
after do
# Ensure we clean up after the frame changes
@session.switch_to_frame(:top)
end
it 'should find the div in frameOne' do
frame = @session... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/become_closed_spec.rb | Ruby | mit | 10,156 | master | 3,131 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#become_closed', requires: %i[windows js] do
let!(:window) { @session.current_window }
let(:other_window) do
@session.window_opened_by do
@session.find(:css, '#openWindow').click
end
end
before do
@session.visit('/with_windows')
end
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/window_opened_by_spec.rb | Ruby | mit | 10,156 | master | 3,570 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/open_new_window_spec.rb | Ruby | mit | 10,156 | master | 879 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#open_new_window', requires: [:windows] do
before do
@window = @session.current_window
@session.visit('/with_windows')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w
w.close
end
@session... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/current_window_spec.rb | Ruby | mit | 10,156 | master | 743 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#current_window', requires: [:windows] do
before do
@window = @session.current_window
@session.visit('/with_windows')
end
after do
(@session.windows - [@window]).each do |w|
@session.switch_to_window w
w.close
end
@session.... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/switch_to_window_spec.rb | Ruby | mit | 10,156 | master | 5,071 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/windows_spec.rb | Ruby | mit | 10,156 | master | 1,287 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/window_spec.rb | Ruby | mit | 10,156 | master | 6,260 | # frozen_string_literal: true
# NOTE: This file uses `sleep` to sync up parts of the tests. This is only implemented like this
# because of the methods being tested. In tests using Capybara this type of behavior should be implemented
# using Capybara provided assertions with builtin waiting behavior.
Capybara::SpecHe... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/window/within_window_spec.rb | Ruby | mit | 10,156 | master | 5,751 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
before do
@window = @session.current_window
@session.visit('/with_windows')
@session.find(:css, '#openTwoWindows').click
@session.document.synchronize(3, errors: [Capybara::CapybaraError]) do
rais... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/element/matches_selector_spec.rb | Ruby | mit | 10,156 | master | 4,810 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#match_selector?' do
let(:element) { @session.find(:xpath, '//span', text: '42') }
before do
@session.visit('/with_html')
end
it 'should be true if the element matches the given selector' do
expect(element).to match_selector(:xpath, '//span')
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/element/match_xpath_spec.rb | Ruby | mit | 10,156 | master | 845 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#match_xpath?' do
before do
@session.visit('/with_html')
@element = @session.find(:css, 'span.number')
end
it 'should be true if the given selector is on the page' do
expect(@element).to match_xpath('//span')
expect(@element).to match_xpat... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/element/assert_match_selector_spec.rb | Ruby | mit | 10,156 | master | 1,389 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#assert_matches_selector' do
before do
@session.visit('/with_html')
@element = @session.find(:css, 'span', text: '42')
end
it 'should be true if the given selector matches the element' do
expect(@element.assert_matches_selector(:css, '.number'... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/spec/session/element/match_css_spec.rb | Ruby | mit | 10,156 | master | 1,099 | # frozen_string_literal: true
Capybara::SpecHelper.spec '#match_css?' do
before do
@session.visit('/with_html')
@element = @session.find(:css, 'span', text: '42')
end
it 'should be true if the given selector matches the element' do
expect(@element).to match_css('span')
expect(@element).to match_... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matcher_proxies.rb | Ruby | mit | 10,156 | master | 1,974 | # frozen_string_literal: true
module Capybara
module RSpecMatcherProxies
def all(*args, **kwargs, &block)
if defined?(::RSpec::Matchers::BuiltIn::All) && args.first.respond_to?(:matches?)
::RSpec::Matchers::BuiltIn::All.new(*args)
else
find_all(*args, **kwargs, &block)
end
e... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers.rb | Ruby | mit | 10,156 | master | 7,426 | # frozen_string_literal: true
require 'capybara/rspec/matchers/have_selector'
require 'capybara/rspec/matchers/have_ancestor'
require 'capybara/rspec/matchers/have_sibling'
require 'capybara/rspec/matchers/match_selector'
require 'capybara/rspec/matchers/have_current_path'
require 'capybara/rspec/matchers/match_style'... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/features.rb | Ruby | mit | 10,156 | master | 909 | # frozen_string_literal: true
RSpec.shared_context 'Capybara Features', capybara_feature: true do
instance_eval do
alias background before
alias given let
alias given! let!
end
end
# ensure shared_context is included if default shared_context_metadata_behavior is changed
RSpec.configure do |config|
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/spatial_sugar.rb | Ruby | mit | 10,156 | master | 608 | # frozen_string_literal: true
module Capybara
module RSpecMatchers
module SpatialSugar
def above(el)
options[:above] = el
self
end
def below(el)
options[:below] = el
self
end
def left_of(el)
options[:left_of] = el
self
end
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/base.rb | Ruby | mit | 10,156 | master | 3,133 | # frozen_string_literal: true
require 'capybara/rspec/matchers/compound'
require 'capybara/rspec/matchers/count_sugar'
require 'capybara/rspec/matchers/spatial_sugar'
module Capybara
module RSpecMatchers
module Matchers
class Base
include ::Capybara::RSpecMatchers::Matchers::Compound if defined?(:... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/become_closed.rb | Ruby | mit | 10,156 | master | 858 | # frozen_string_literal: true
module Capybara
module RSpecMatchers
module Matchers
class BecomeClosed
def initialize(options)
@options = options
end
def matches?(window)
@window = window
@wait_time = Capybara::Queries::BaseQuery.wait(@options, window.s... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/have_text.rb | Ruby | mit | 10,156 | master | 645 | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveText < CountableWrappedElementMatcher
def element_matches?(el)
el.assert_text(*@args, **@kw_args)
end
def element_does_not_match?(el)
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/have_sibling.rb | Ruby | mit | 10,156 | master | 703 | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveSibling < CountableWrappedElementMatcher
def element_matches?(el)
el.assert_sibling(*@args, **session_query_options, &@filter_block)
end
de... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/match_style.rb | Ruby | mit | 10,156 | master | 1,025 | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class MatchStyle < WrappedElementMatcher
def initialize(styles = nil, **kw_args, &filter_block)
styles, kw_args = kw_args, {} if styles.nil?
super(styles, *... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/compound.rb | Ruby | mit | 10,156 | master | 2,199 | # frozen_string_literal: true
if defined?(RSpec::Expectations::Version)
module Capybara
module RSpecMatchers
module Matchers
module Compound
include ::RSpec::Matchers::Composable
def and(matcher)
And.new(self, matcher)
end
def and_then(matcher)
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/have_title.rb | Ruby | mit | 10,156 | master | 542 | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveTitle < WrappedElementMatcher
def element_matches?(el)
el.assert_title(*@args, **@kw_args)
end
def element_does_not_match?(el)
el... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/count_sugar.rb | Ruby | mit | 10,156 | master | 627 | # frozen_string_literal: true
module Capybara
module RSpecMatchers
module CountSugar
def once; exactly(1); end
def twice; exactly(2); end
def thrice; exactly(3); end
def exactly(number)
options[:count] = number
self
end
def at_most(number)
options[:ma... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/have_selector.rb | Ruby | mit | 10,156 | master | 2,154 | # frozen_string_literal: true
# rubocop:disable Naming/PredicatePrefix
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveSelector < CountableWrappedElementMatcher
def initialize(*args, **kw_args, &filter_block)
super
return u... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/have_ancestor.rb | Ruby | mit | 10,156 | master | 805 | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveAncestor < CountableWrappedElementMatcher
def element_matches?(el)
el.assert_ancestor(*@args, **session_query_options, &@filter_block)
end
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/have_current_path.rb | Ruby | mit | 10,156 | master | 627 | # frozen_string_literal: true
require 'capybara/rspec/matchers/base'
module Capybara
module RSpecMatchers
module Matchers
class HaveCurrentPath < WrappedElementMatcher
def element_matches?(el)
el.assert_current_path(current_path, **@kw_args, &@filter_block)
end
def eleme... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/rspec/matchers/match_selector.rb | Ruby | mit | 10,156 | master | 706 | # frozen_string_literal: true
require 'capybara/rspec/matchers/have_selector'
module Capybara
module RSpecMatchers
module Matchers
class MatchSelector < HaveSelector
def element_matches?(el)
el.assert_matches_selector(*@args, **session_query_options, &@filter_block)
end
... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/server/checker.rb | Ruby | mit | 10,156 | master | 929 | # frozen_string_literal: true
module Capybara
class Server
class Checker
TRY_HTTPS_ERRORS = [EOFError, Net::ReadTimeout, Errno::ECONNRESET].freeze
def initialize(host, port)
@host, @port = host, port
@ssl = false
end
def request(&block)
ssl? ? https_request(&bloc... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/server/animation_disabler.rb | Ruby | mit | 10,156 | master | 2,482 | # frozen_string_literal: true
module Capybara
class Server
class AnimationDisabler
def self.selector_for(css_or_bool)
case css_or_bool
when String
css_or_bool
when true
'*'
else
raise CapybaraError, 'Capybara.disable_animation supports either a ... |
github | teamcapybara/capybara | https://github.com/teamcapybara/capybara | lib/capybara/server/middleware.rb | Ruby | mit | 10,156 | master | 1,516 | # frozen_string_literal: true
module Capybara
class Server
class Middleware
class Counter
def initialize
@value = []
@mutex = Mutex.new
end
def increment(uri)
@mutex.synchronize { @value.push(uri) }
end
def decrement(uri)
@mu... |
github | ruby-grape/grape | https://github.com/ruby-grape/grape | Rakefile | Ruby | mit | 9,984 | master | 590 | # frozen_string_literal: true
require('rubygems')
require('bundler')
Bundler.setup(:default, :test, :development)
Bundler::GemHelper.install_tasks
require('rspec/core/rake_task')
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.exclude_pattern = 'spec/integration/**/*_spec.rb'
e... |
github | ruby-grape/grape | https://github.com/ruby-grape/grape | grape.gemspec | Ruby | mit | 9,984 | master | 1,347 | # frozen_string_literal: true
require_relative 'lib/grape/version'
Gem::Specification.new do |s|
s.name = 'grape'
s.version = Grape::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Michael Bleigh']
s.email = ['michael@intridea.com']
s.homepage = 'https://github.com/ruby-g... |
github | ruby-grape/grape | https://github.com/ruby-grape/grape | Gemfile | Ruby | mit | 9,984 | master | 807 | # frozen_string_literal: true
source('https://rubygems.org')
gemspec
group :development, :test do
gem 'builder', require: false
gem 'bundler'
gem 'rake'
gem 'rubocop', '1.86.0', require: false
gem 'rubocop-performance', '1.26.1', require: false
gem 'rubocop-rspec', '3.9.0', require: false
end
group :dev... |
github | ruby-grape/grape | https://github.com/ruby-grape/grape | Guardfile | Ruby | mit | 9,984 | master | 341 | # frozen_string_literal: true
guard :rspec, all_on_start: true, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }
end
guard :rubocop do
watch(/.+\.rb$/)
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File... |
github | ruby-grape/grape | https://github.com/ruby-grape/grape | benchmark/issue_mounting.rb | Ruby | mit | 9,984 | master | 658 | # frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'grape'
gem 'rack'
gem 'minitest'
gem 'rack-test'
end
require 'minitest/autorun'
require 'rack/test'
require 'grape'
class GrapeAPIBugTest < Minitest::Test
include Rack::Test::Methods
RootAPI = C... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.