Module: Capybara::RSpecMatchers

Defined in:
lib/capybara/rspec/compound.rb,
lib/capybara/rspec/matchers.rb

Defined Under Namespace

Modules: Compound Classes: BecomeClosed, HaveAllSelectors, HaveCurrentPath, HaveNoSelectors, HaveSelector, HaveText, HaveTitle, MatchSelector, Matcher

Instance Method Summary collapse

Instance Method Details

#become_closed(**options) ⇒ Object

Wait for window to become closed.

Examples:

expect(window).to become_closed(wait: 0.8)

Options Hash (**options):

  • :wait (Numeric) — default: Capybara.default_max_wait_time

    Maximum wait time



351
352
353
# File 'lib/capybara/rspec/matchers.rb', line 351

def become_closed(**options)
  BecomeClosed.new(options)
end

#have_all_of_selectors(*args, &optional_filter_block) ⇒ Object

RSpec matcher for whether the element(s) matching a group of selectors exist See Node::Matcher#assert_all_of_selectors



246
247
248
# File 'lib/capybara/rspec/matchers.rb', line 246

def have_all_of_selectors(*args, &optional_filter_block)
  HaveAllSelectors.new(*args, &optional_filter_block)
end

#have_button(locator = nil, **options, &optional_filter_block) ⇒ Object

RSpec matcher for buttons See Node::Matchers#has_button?



311
312
313
# File 'lib/capybara/rspec/matchers.rb', line 311

def have_button(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:button, locator, options, &optional_filter_block)
end

#have_checked_field(locator = nil, **options, &optional_filter_block) ⇒ Object

RSpec matcher for checked fields See Node::Matchers#has_checked_field?



323
324
325
# File 'lib/capybara/rspec/matchers.rb', line 323

def have_checked_field(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:field, locator, options.merge(checked: true), &optional_filter_block)
end

#have_css(css, **options, &optional_filter_block) ⇒ Object

RSpec matcher for whether elements(s) matching a given css selector exist See Node::Matchers#has_css?



277
278
279
# File 'lib/capybara/rspec/matchers.rb', line 277

def have_css(css, **options, &optional_filter_block)
  HaveSelector.new(:css, css, options, &optional_filter_block)
end

#have_current_path(path, **options) ⇒ Object

RSpec matcher for the current path See SessionMatchers#assert_current_path



299
300
301
# File 'lib/capybara/rspec/matchers.rb', line 299

def have_current_path(path, **options)
  HaveCurrentPath.new(path, options)
end

#have_field(locator = nil, **options, &optional_filter_block) ⇒ Object

RSpec matcher for links See Node::Matchers#has_field?



317
318
319
# File 'lib/capybara/rspec/matchers.rb', line 317

def have_field(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:field, locator, options, &optional_filter_block)
end

RSpec matcher for links See Node::Matchers#has_link?



305
306
307
# File 'lib/capybara/rspec/matchers.rb', line 305

def have_link(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:link, locator, options, &optional_filter_block)
end

#have_none_of_selectors(*args, &optional_filter_block) ⇒ Object

RSpec matcher for whether no element(s) matching a group of selectors exist See Node::Matcher#assert_none_of_selectors



252
253
254
# File 'lib/capybara/rspec/matchers.rb', line 252

def have_none_of_selectors(*args, &optional_filter_block)
  HaveNoSelectors.new(*args, &optional_filter_block)
end

#have_select(locator = nil, **options, &optional_filter_block) ⇒ Object

RSpec matcher for select elements See Node::Matchers#has_select?



335
336
337
# File 'lib/capybara/rspec/matchers.rb', line 335

def have_select(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:select, locator, options, &optional_filter_block)
end

#have_selector(*args, &optional_filter_block) ⇒ Object

RSpec matcher for whether the element(s) matching a given selector exist See Node::Matcher#assert_selector



240
241
242
# File 'lib/capybara/rspec/matchers.rb', line 240

def have_selector(*args, &optional_filter_block)
  HaveSelector.new(*args, &optional_filter_block)
end

#have_table(locator = nil, **options, &optional_filter_block) ⇒ Object

RSpec matcher for table elements See Node::Matchers#has_table?



341
342
343
# File 'lib/capybara/rspec/matchers.rb', line 341

def have_table(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:table, locator, options, &optional_filter_block)
end

#have_text(*args) ⇒ Object Also known as: have_content

RSpec matcher for text on the page See SessionMatchers#assert_text



288
289
290
# File 'lib/capybara/rspec/matchers.rb', line 288

def have_text(*args)
  HaveText.new(*args)
end

#have_title(title, **options) ⇒ Object



293
294
295
# File 'lib/capybara/rspec/matchers.rb', line 293

def have_title(title, **options)
  HaveTitle.new(title, options)
end

#have_unchecked_field(locator = nil, **options, &optional_filter_block) ⇒ Object

RSpec matcher for unchecked fields See Node::Matchers#has_unchecked_field?



329
330
331
# File 'lib/capybara/rspec/matchers.rb', line 329

def have_unchecked_field(locator = nil, **options, &optional_filter_block)
  HaveSelector.new(:field, locator, options.merge(unchecked: true), &optional_filter_block)
end

#have_xpath(xpath, **options, &optional_filter_block) ⇒ Object

RSpec matcher for whether elements(s) matching a given xpath selector exist See Node::Matchers#has_xpath?



266
267
268
# File 'lib/capybara/rspec/matchers.rb', line 266

def have_xpath(xpath, **options, &optional_filter_block)
  HaveSelector.new(:xpath, xpath, options, &optional_filter_block)
end

#match_css(css, **options, &optional_filter_block) ⇒ Object

RSpec matcher for whether the current element matches a given css selector



282
283
284
# File 'lib/capybara/rspec/matchers.rb', line 282

def match_css(css, **options, &optional_filter_block)
  MatchSelector.new(:css, css, options, &optional_filter_block)
end

#match_selector(*args, &optional_filter_block) ⇒ Object

RSpec matcher for whether the current element matches a given selector See Node::Matchers#assert_matches_selector



258
259
260
# File 'lib/capybara/rspec/matchers.rb', line 258

def match_selector(*args, &optional_filter_block)
  MatchSelector.new(*args, &optional_filter_block)
end

#match_xpath(xpath, **options, &optional_filter_block) ⇒ Object

RSpec matcher for whether the current element matches a given xpath selector



271
272
273
# File 'lib/capybara/rspec/matchers.rb', line 271

def match_xpath(xpath, **options, &optional_filter_block)
  MatchSelector.new(:xpath, xpath, options, &optional_filter_block)
end