Class: RSpecExtensionsCollection::Matchers::SearchMatcher
- Inherits:
-
Object
- Object
- RSpecExtensionsCollection::Matchers::SearchMatcher
- Includes:
- MongoidModelHelpers
- Defined in:
- lib/rspec_extensions_collection/matchers/search_matcher.rb
Direct Known Subclasses
Constant Summary collapse
- KEYWORD =
"temp"- FIELD_CONTENT_WITH_KEYWORD =
"This contains the keyword #{KEYWORD} and something else."- FIELD_CONTENT_WITHOUT_KEYWORD =
"Used for some data."- LOCALES =
["en", "fr"]
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
-
#initialize(*args) ⇒ SearchMatcher
constructor
A new instance of SearchMatcher.
- #matches?(model_class) ⇒ Boolean
Methods included from MongoidModelHelpers
Constructor Details
#initialize(*args) ⇒ SearchMatcher
28 29 30 31 32 33 |
# File 'lib/rspec_extensions_collection/matchers/search_matcher.rb', line 28 def initialize(*args) if args.try(:last).instance_of?(Hash) @locale = args.pop[:locale] end @fields = args end |
Instance Method Details
#failure_message_for_should ⇒ Object
43 44 45 |
# File 'lib/rspec_extensions_collection/matchers/search_matcher.rb', line 43 def "expected #{@model_class} to find #{@matching_models} but got #{execute_query_to_models(@search_result)}" end |
#matches?(model_class) ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/rspec_extensions_collection/matchers/search_matcher.rb', line 35 def matches?(model_class) @model_class = model_class @model_class.delete_all create_models @search_result = execute execute_query_to_models(@search_result.asc(:_id)) == @matching_models end |