Sha256: 02bfd58666eec662b9ab5036fa614be48717350bd6da51eb986d137a689f274c
Contents?: true
Size: 959 Bytes
Versions: 6
Compression:
Stored size: 959 Bytes
Contents
require 'taketo/dsl' RSpec::Matchers.define :be_appropriate_construct do |construct, *args| chain(:under) do |enclosing_scope| @enclosing_scope = enclosing_scope end match do |actual| unless @enclosing_scope raise ArgumentError, "#under must be called to set enclosing scope" end @result = true dsl(@enclosing_scope) do |c| begin c.send(construct, *args) {} rescue Taketo::DSL::ScopeError => e @result = false rescue #nothing end end @result end description do "#{name_to_sentence} ##{construct}(#{args.join(", ")}) under #{@enclosing_scope.inspect}" end failure_message_for_should do |actual| "expected construct #{construct} to be appropriate under #{@enclosing_scope.inspect} scope" end failure_message_for_should_not do |actual| "expected construct #{construct} not to be appropriate under #{@enclosing_scope.inspect} scope" end end
Version data entries
6 entries across 6 versions & 1 rubygems