Class: ActiveAttr::Matchers::HaveAttributeMatcher
- Inherits:
-
Object
- Object
- ActiveAttr::Matchers::HaveAttributeMatcher
- Defined in:
- lib/active_attr/matchers/have_attribute_matcher.rb
Overview
Verifies that an ActiveAttr-based model has an attribute matching the given criteria. See #have_attribute
Instance Method Summary (collapse)
-
- (HaveAttributeMatcher) of_type(type)
Specify that the attribute should have the given type.
-
- (HaveAttributeMatcher) with_default_value_of(default_value)
Specify that the attribute should have the given default value.
Instance Method Details
- (HaveAttributeMatcher) of_type(type)
Specify that the attribute should have the given type
50 51 52 53 54 55 |
# File 'lib/active_attr/matchers/have_attribute_matcher.rb', line 50 def of_type(type) @description << " of type #{type}" @expected_ancestors << "ActiveAttr::TypecastedAttributes" @attribute_expectations << lambda { @model_class._attribute_type(attribute_name) == type } self end |
- (HaveAttributeMatcher) with_default_value_of(default_value)
Specify that the attribute should have the given default value
71 72 73 74 75 76 |
# File 'lib/active_attr/matchers/have_attribute_matcher.rb', line 71 def with_default_value_of(default_value) @description << " with a default value of #{default_value.inspect}" @expected_ancestors << "ActiveAttr::AttributeDefaults" @attribute_expectations << lambda { attribute_definition[:default] == default_value } self end |