Class: Remarkable::Controller::Matchers::AssignMatcher
- Inherits:
-
Matcher::Base
- Object
- Matcher::Base
- Remarkable::Controller::Matchers::AssignMatcher
- Includes:
- Helpers
- Defined in:
- lib/remarkable/controller/macros/assign_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(*names, &block) ⇒ AssignMatcher
constructor
A new instance of AssignMatcher.
- #matches?(subject) ⇒ Boolean
Methods included from Default::Helpers
#assert_contains, #assert_does_not_contain
Methods inherited from Matcher::Base
#failure_message, #negative, #negative_failure_message, #spec
Methods included from Matcher::DSL
Constructor Details
#initialize(*names, &block) ⇒ AssignMatcher
Returns a new instance of AssignMatcher.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/remarkable/controller/macros/assign_matcher.rb', line 9 def initialize(*names, &block) = names. @names = names [:equals] = block if block_given? warn "[DEPRECATION] Strings given in :equals to should_assign_to won't be evaluated anymore. You can give procs or use blocks instead." if [:equals].is_a?(String) warn "[DEPRECATION] :equals option is deprecated in should_assign_to. Please give :with instead." if [:equals] warn "[DEPRECATION] :class option is deprecated in should_assign_to. Please give :with_kind_of instead." if [:class] [:with] ||= .delete(:equals) [:with_kind_of] ||= .delete(:class) end |
Instance Method Details
#description ⇒ Object
33 34 35 36 37 38 |
# File 'lib/remarkable/controller/macros/assign_matcher.rb', line 33 def description description = "assign @#{@names.to_sentence}" description << " as class #{@options[:with_kind_of]}" if [:with_kind_of] description << " which is equal to #{@options[:with]}" if [:with] description end |
#matches?(subject) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/remarkable/controller/macros/assign_matcher.rb', line 22 def matches?(subject) @subject = subject initialize_with_spec! assert_matcher_for(@names) do |name| @name = name assigned_value? && is_kind_of? && is_equals_expected_value? end end |