Module: RSpec::BeValidWhenMatcher
- Defined in:
- lib/rspec/be_valid_when_matcher.rb
Overview
Container module for be_valid_when matcher definition and implementation.
Defined Under Namespace
Classes: BeValidWhen
Basic chaining collapse
-
#is(*args) ⇒ self
Used to set field ‘value` and optional custom failure `message`.
Presence collapse
-
#is_not_present ⇒ self
Used to setup matcher for checking ‘nil` value.
Type collapse
-
#is_array(value = [42]) ⇒ self
Setup matcher for checking array values.
-
#is_bigdecimal(value = 0.42E2) ⇒ self
Setup matcher for checking bigdecimal values.
-
#is_bignum(value = 42**13) ⇒ self
Setup matcher for checking bignum values.
-
#is_complex(value = 42+0i) ⇒ self
Setup matcher for checking complex values.
-
#is_fixnum(value = 42) ⇒ self
Setup matcher for checking fixnum values.
-
#is_float(value = 3.14) ⇒ self
Setup matcher for checking float values.
-
#is_hash(value = { value: 42 }) ⇒ self
Setup matcher for checking hash values.
-
#is_integer(value = 42) ⇒ self
Setup matcher for checking integer values.
-
#is_numeric(value = 42) ⇒ self
Setup matcher for checking numeric values.
-
#is_range(value = 2..42) ⇒ self
Setup matcher for checking range values.
-
#is_rational(value = 42/1) ⇒ self
Setup matcher for checking rational values.
-
#is_regexp(value = /^value$/) ⇒ self
Setup matcher for checking regexp values.
-
#is_string(value = 'value') ⇒ self
Setup matcher for checking string values.
-
#is_symbol(value = :value) ⇒ self
Setup matcher for checking symbol values.
Logical value collapse
-
#is_false ⇒ self
Check validity of field with ‘FalseClass` value.
-
#is_true ⇒ self
Check validity of field with ‘TrueClass` value.
Instance Method Summary collapse
-
#be_valid_when(*args) ⇒ self
Model validity assertion.
Instance Method Details
#be_valid_when(field) ⇒ self #be_valid_when(field, value) ⇒ self #be_valid_when(field, value, message) ⇒ self
Model validity assertion.
201 202 203 204 205 206 207 208 209 210 |
# File 'lib/rspec/be_valid_when_matcher.rb', line 201 def be_valid_when(*args) number_of_arguments = args.size field_name = args.shift if number_of_arguments == 1 BeValidWhen.new(field_name) else BeValidWhen.new(field_name).is(*args) end end |
#is(value) ⇒ self #is(value, message) ⇒ self
Used to set field ‘value` and optional custom failure `message`.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 214
|
#is_array(value = [42]) ⇒ self
Setup matcher for checking array values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 318
|
#is_bigdecimal(value = 0.42E2) ⇒ self
Setup matcher for checking bigdecimal values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 297
|
#is_bignum(value = 42**13) ⇒ self
Setup matcher for checking bignum values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 269
|
#is_complex(value = 42+0i) ⇒ self
Setup matcher for checking complex values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 283
|
#is_false ⇒ self
Check validity of field with ‘FalseClass` value.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 356
|
#is_fixnum(value = 42) ⇒ self
Setup matcher for checking fixnum values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 262
|
#is_float(value = 3.14) ⇒ self
Setup matcher for checking float values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 276
|
#is_hash(value = { value: 42 }) ⇒ self
Setup matcher for checking hash values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 325
|
#is_integer(value = 42) ⇒ self
Setup matcher for checking integer values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 255
|
#is_not_present ⇒ self
Used to setup matcher for checking ‘nil` value.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 238
|
#is_numeric(value = 42) ⇒ self
Setup matcher for checking numeric values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 248
|
#is_range(value = 2..42) ⇒ self
Setup matcher for checking range values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 339
|
#is_rational(value = 42/1) ⇒ self
Setup matcher for checking rational values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 290
|
#is_regexp(value = /^value$/) ⇒ self
Setup matcher for checking regexp values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 311
|
#is_string(value = 'value') ⇒ self
Setup matcher for checking string values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 304
|
#is_symbol(value = :value) ⇒ self
Setup matcher for checking symbol values.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 332
|
#is_true ⇒ self
Check validity of field with ‘TrueClass` value.
|
# File 'lib/rspec/be_valid_when_matcher.rb', line 350
|