Module: RSpec::TagMatchers

Defined in:
lib/rspec/tag_matchers.rb,
lib/rspec/tag_matchers/has_tag.rb,
lib/rspec/tag_matchers/has_form.rb,
lib/rspec/tag_matchers/has_input.rb,
lib/rspec/tag_matchers/has_select.rb,
lib/rspec/tag_matchers/has_checkbox.rb,
lib/rspec/tag_matchers/has_date_select.rb,
lib/rspec/tag_matchers/has_time_select.rb,
lib/rspec/tag_matchers/multiple_input_matcher.rb

Defined Under Namespace

Modules: Helpers Classes: HasCheckbox, HasDateSelect, HasForm, HasInput, HasSelect, HasTag, HasTimeSelect, MultipleInputMatcher

Instance Method Summary collapse

Examples:

Matching a checked checkbox for terms_of_service

it { should have_checkbox.for(:terms_of_service).checked }

Matching an unchecked checkbox for terms_of_service

it { should have_checkbox.for(:terms_of_service).not_checked }

Returns:

See Also:

Modifiers:



20
21
22
# File 'lib/rspec/tag_matchers/has_checkbox.rb', line 20

def have_checkbox
  HasCheckbox.new
end

#have_date_selectHasDateSelect

Matches inputs generated by Rails' date_select helper.

Examples:

Matching a date select for an event's start_date

it { should have_date_select.for(:event => :start_date) }

Matching a date select for a credit card expiration

it { should have_date_select.discard(:day).for(:credit_card => :expiration) }

Returns:

See Also:

Modifiers:



21
22
23
# File 'lib/rspec/tag_matchers/has_date_select.rb', line 21

def have_date_select
  HasDateSelect.new
end

#have_formHasForm

Matches tags in HTML.

Examples:

Matching a simple form

it { should have_form.with_verb(:post).with_action("/signup") }

Matching a form with an overridden method

it { should have_form.with_verb(:put) }

Returns:

See Also:

Modifiers:



20
21
22
# File 'lib/rspec/tag_matchers/has_form.rb', line 20

def have_form
  HasForm.new
end

#have_inputHasInput

Matches tags in HTML.

Examples:

Matching an input for the name attribute on user

it { should have_input.for(:user => :name) }
it { should have_input.for(:user, :name) }

Matching an input with a value of "42".

it { should have_input.value("42") }

Returns:

See Also:

Modifiers:



22
23
24
# File 'lib/rspec/tag_matchers/has_input.rb', line 22

def have_input
  HasInput.new
end

#have_selectHasSelect

Matches