Class: FoundationApi::ShouldaMatcher::PersistenceMethodMatcher
- Inherits:
-
Object
- Object
- FoundationApi::ShouldaMatcher::PersistenceMethodMatcher
- Defined in:
- lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb
Instance Method Summary collapse
- #calling(interface) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(method) ⇒ PersistenceMethodMatcher
constructor
A new instance of PersistenceMethodMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #with_destoy_type(type) ⇒ Object
- #with_destroy_key(key) ⇒ Object
- #with_uniqueness_of(attribute) ⇒ Object
Constructor Details
#initialize(method) ⇒ PersistenceMethodMatcher
Returns a new instance of PersistenceMethodMatcher.
4 5 6 7 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 4 def initialize(method) @expected_method = method @options = [] end |
Instance Method Details
#calling(interface) ⇒ Object
30 31 32 33 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 30 def calling(interface) @interface = interface.to_s self end |
#description ⇒ Object
26 27 28 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 26 def description "specified persistence method #{@expected_method}" end |
#failure_message ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 14 def = [] << "You specified an illegal caller #{@expected_method.inspect}" unless method_supported? << "One of the options you specified #{@options.inspect} is not backed by the method #{@expected_method.inspect}" unless << option_failure? if option_failure? .join(" and\n") end |
#matches?(subject) ⇒ Boolean
9 10 11 12 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 9 def matches?(subject) @klass = subject.class method_supported? && interface_matches? && && !option_failure? end |
#negative_failure_message ⇒ Object
22 23 24 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 22 def "Something did not match. However should_not does not make sense here" end |
#with_destoy_type(type) ⇒ Object
47 48 49 50 51 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 47 def with_destoy_type(type) @options << :destroy_type @destroy_type = type self end |
#with_destroy_key(key) ⇒ Object
41 42 43 44 45 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 41 def with_destroy_key(key) @options << :destroy_key @destroy_key = key self end |
#with_uniqueness_of(attribute) ⇒ Object
35 36 37 38 39 |
# File 'lib/foundation_api/shoulda_matcher/persistence_method_matcher.rb', line 35 def with_uniqueness_of(attribute) @options << :unique @unique = attribute self end |