Module: Remarkable::Matcher::DSL
- Included in:
- Base
- Defined in:
- lib/remarkable/dsl.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/remarkable/dsl.rb', line 5 def self.included(base) base.extend ClassMethods base.class_eval do class_inheritable_accessor :loop_argument, :instance_writer => false class_inheritable_reader :matcher_for_assertions, :matcher_assertions # loop_argument is the value the we are going to loop with # assert_matcher_for. self.loop_argument = nil # matcher_for_assertions contains the methods that should be called # inside assert_matcher_for. assertions() # matcher_assertions contains the methods that should be called # inside assert_matcher. single_assertions() end end |
Instance Method Details
#matches?(subject) ⇒ Boolean
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/remarkable/dsl.rb', line 166 def matches?(subject) @subject = subject before_assert # Gets the loop_argument and loops it setting the singular name of # loop argument. For example, if loop_argument is :good_values, we # will get @good_values and then set the instance variable @good_value. # # Then we go for each method declared in assertions and eval it. # Later we do the same for each method declared in single_assertion. # assert_matcher_for(instance_variable_get("@#{loop_argument}")) do |value| instance_variable_set("@#{loop_argument.singularize}", value) matcher_for_assertions.inject(true) do |bool, method| bool && send_assertion_method(method) end end && assert_matcher do matcher_assertions.inject(true) do |bool, method| bool && send_assertion_method(method) end end end |