Class: PencilPusher::HaveIntField
- Inherits:
-
Object
- Object
- PencilPusher::HaveIntField
show all
- Includes:
- Matchers
- Defined in:
- lib/pencil_pusher/have_int_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, error) ⇒ HaveIntField
Returns a new instance of HaveIntField.
5
6
7
8
9
|
# File 'lib/pencil_pusher/have_int_field.rb', line 5
def initialize(field_name, valid_value, error)
@field_name = field_name
@valid_value = valid_value
@error = error
end
|
Instance Method Details
#description ⇒ Object
30
31
32
|
# File 'lib/pencil_pusher/have_int_field.rb', line 30
def description
"have int field #{field_name}"
end
|
#failure_message_for_should(actual, two) ⇒ Object
22
23
24
|
# File 'lib/pencil_pusher/have_int_field.rb', line 22
def failure_message_for_should(actual, two)
@error
end
|
#failure_message_for_should_not(actual) ⇒ Object
26
27
28
|
# File 'lib/pencil_pusher/have_int_field.rb', line 26
def failure_message_for_should_not(actual)
"expected #{actual} to not have int field #{field_name} but did"
end
|
#matches?(builder) ⇒ Boolean
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/pencil_pusher/have_int_field.rb', line 11
def matches?(builder)
begin
FormBuilder.form(builder, {field_name => 'here'}).should have_errors(field_name, [error])
FormBuilder.form(builder, field_name => valid_value).should_not have_errors(field_name)
rescue => e
@error = e.message
raise e
end
true
end
|