lib/serial_spec.rb in serial-spec-0.2.1 vs lib/serial_spec.rb in serial-spec-0.3.0

- old
+ new

@@ -13,13 +13,20 @@ module SerialSpec extend ActiveSupport::Concern include ItExpects include RequestResponse include RequestResponse::Helpers + if defined?(ActiveModel::Serializer) require "serial_spec/request_response/provide_matcher" include RequestResponse::ProvideMatcher + + if defined?(::RSpec) and + defined?(::RSpec::Core::Version::STRING) and + Gem::Version.new(::RSpec::Core::Version::STRING) >= Gem::Version.new("3.2.0") + require "serial_spec/request_response/include_provide_matcher" + end end SERIAL_VALID_VERBS = %w{GET POST PUT PATCH DELETE OPTIONS HEAD} module ClassMethods @@ -31,11 +38,18 @@ context_klass = context "with request: '#{request_str}'" do if request_str.split(/\s+/).count == 2 request_method_string, request_path_str = request_str.split(/\s+/) if SERIAL_VALID_VERBS.include?(request_method_string) - request_method request_method_string - request_path request_path_str + # Prefer preference to blocks, chances are the blocks need to be + # executed at a lower level + unless request_opts[:request_method] and request_opts[:request_method].instance_of?(InheritableAccessors::InheritableOptionAccessor::LetOption) + request_method request_method_string + end + + unless request_opts[:request_path] and request_opts[:request_path].instance_of?(InheritableAccessors::InheritableOptionAccessor::LetOption) + request_path request_path_str + end end end instance_exec(&block) if block_given?