lib/remarkable/macros.rb in remarkable-3.0.1 vs lib/remarkable/macros.rb in remarkable-3.0.2

- old
+ new

@@ -1,48 +1,48 @@ module Remarkable - module Macros + module Macros protected - + def method_missing(method_id, *args, &block) #:nodoc: - if method_id.to_s =~ /^(should_not|should)_(.+)/ - should_or_should_not_method_missing($1, $2, caller, *args, &block) + if method_id.to_s =~ /^(should_not|should)_(.+)/ + should_or_should_not_method_missing($1, $2, caller, *args, &block) elsif method_id.to_s =~ /^x(should_not|should)_(.+)/ disabled_method_missing($1, $2, *args, &block) - else + else super(method_id, *args, &block) end - end - + end + def should_or_should_not_method_missing(should_or_should_not, method, calltrace, *args, &block) #:nodoc: - it { - begin - send(should_or_should_not, send(method, *args, &block)) - rescue Exception => e - e.set_backtrace(calltrace.to_a) - raise e - end + it { + begin + send(should_or_should_not, send(method, *args, &block)) + rescue Exception => e + e.set_backtrace(calltrace.to_a) + raise e + end } - end + end - def disabled_method_missing(should_or_should_not, method, *args, &block) #:nodoc: - description = get_description_from_matcher(should_or_should_not, method, *args, &block) + def disabled_method_missing(should_or_should_not, method, *args, &block) #:nodoc: + description = get_description_from_matcher(should_or_should_not, method, *args, &block) xexample(description) - end - - # Try to get the description from the matcher. If an error is raised, we - # deduct the description from the matcher name, but it will be shown in - # english. - # - def get_description_from_matcher(should_or_should_not, method, *args, &block) #:nodoc: - verb = should_or_should_not.to_s.gsub('_', ' ') - - desc = Remarkable::Matchers.send(method, *args, &block).spec(self).description - verb = Remarkable.t("remarkable.core.#{should_or_should_not}", :default => verb) - rescue - desc = method.to_s.gsub('_', ' ') - ensure - verb << ' ' << desc - end + end + + # Try to get the description from the matcher. If an error is raised, we + # deduct the description from the matcher name, but it will be shown in + # english. + # + def get_description_from_matcher(should_or_should_not, method, *args, &block) #:nodoc: + verb = should_or_should_not.to_s.gsub('_', ' ') + + desc = Remarkable::Matchers.send(method, *args, &block).spec(self).description + verb = Remarkable.t("remarkable.core.#{should_or_should_not}", :default => verb) + rescue + desc = method.to_s.gsub('_', ' ') + ensure + verb << ' ' << desc + end end end