Class: PencilPusher::HaveTextField
- Inherits:
-
Object
- Object
- PencilPusher::HaveTextField
show all
- Includes:
- Matchers, RSpec::Matchers
- Defined in:
- lib/pencil_pusher/have_text_field.rb
Instance Method Summary
collapse
Methods included from Matchers
#have_errors, #have_int_field, #have_required_choice_field, #have_required_field, #have_required_float_field, #have_required_int_field, #have_required_text_field, #have_text_field
Constructor Details
#initialize(field_name, valid_value) ⇒ HaveTextField
Returns a new instance of HaveTextField.
6
7
8
9
|
# File 'lib/pencil_pusher/have_text_field.rb', line 6
def initialize(field_name, valid_value)
@field_name = field_name
@valid_value = valid_value
end
|
Instance Method Details
#description ⇒ Object
32
33
34
|
# File 'lib/pencil_pusher/have_text_field.rb', line 32
def description
"have text field #{field_name}"
end
|
#failure_message_for_should(actual, two) ⇒ Object
Also known as:
failure_message
21
22
23
|
# File 'lib/pencil_pusher/have_text_field.rb', line 21
def failure_message_for_should(actual, two)
@error
end
|
#failure_message_for_should_not(actual) ⇒ Object
Also known as:
failure_message_when_negated
25
26
27
|
# File 'lib/pencil_pusher/have_text_field.rb', line 25
def failure_message_for_should_not(actual)
"expected #{actual} to not have text field #{field_name} but did"
end
|
#matches?(builder) ⇒ Boolean
11
12
13
14
15
16
17
18
19
|
# File 'lib/pencil_pusher/have_text_field.rb', line 11
def matches?(builder)
begin
expect(FormBuilder.form(builder, field_name => valid_value)).not_to have_errors(field_name)
rescue => e
@error = e.message
raise e
end
true
end
|