# File lib/releaf/rspec/features_matchers.rb, line 4 def primary_header_css_rule "main > section header" end
class Capybara::Session
Public Instance Methods
has_cells_text?(cells, options = {})
click to toggle source
# File lib/releaf/rspec/features_matchers.rb, line 8 def has_cells_text?(cells, options = {}) cells_count = cells.count cells_count += 1 if options.fetch(:with_toolbox, true) type = options.fetch(:type, "td") has_selector?(type, count: cells_count) && has_text?(cells.join("")) end
has_error?(error_message, options = {})
click to toggle source
Allows to match againg validation errors within forms Support either model specific (base) errors with:
expect(page).to have_error('Global form error message')
and attribute specific errors with:
expect(page).to have_error('Taken', field: 'Lol')
@param error_message [String] error message to find @param options [Hash] available option is `field` that can be anything that is normally accepted by fill_in
e.g., the label text or the id of the textarea
@return [true] whether errors has been found otherwise will raise Capybara::ElementNotFound exception
# File lib/releaf/rspec/features_matchers.rb, line 33 def has_error?(error_message, options = {}) error_found = false if options[:field] first('.field.has-error', minimum: 1) # wait for any errors to come from validation all(".field.has-error", wait: false).each do |field_container| if !error_found within(field_container) do if has_field?(options[:field], wait: false) && has_css?(".error", text: error_message, wait: false) error_found = true end end end end else if first(".form-error-box .error", text: error_message, minimum: 0) error_found = true end end unless error_found failure_text = "Unable to find error message #{error_message.inspect}" if options[:field] failure_text += " on field #{options[:field].inspect}" end raise Capybara::ElementNotFound.new failure_text end true end
has_header?(**args)
click to toggle source
# File lib/releaf/rspec/features_matchers.rb, line 15 def has_header?(**args) has_css?("#{primary_header_css_rule} h1", **args) end
has_no_header?(**args)
click to toggle source
# File lib/releaf/rspec/features_matchers.rb, line 19 def has_no_header?(**args) has_no_css?("#{primary_header_css_rule} h1", **args) end
has_notification?(text, type="success")
click to toggle source
# File lib/releaf/rspec/features_matchers.rb, line 69 def has_notification?(text, type="success") result = has_css?(".notifications .notification[data-type='#{type}']", text: text) if first(".notifications button.close", minimum: 0) find(".notifications .notification[data-type='#{type}'] button.close").click has_no_css?(".notifications .notification[data-type='#{type}'] button.close") end result end
primary_header_css_rule()
click to toggle source