lib/rspec/request_describer.rb in rspec-request_describer-0.4.0 vs lib/rspec/request_describer.rb in rspec-request_describer-0.5.0
- old
+ new
@@ -1,9 +1,11 @@
require 'rspec/request_describer/version'
module RSpec
module RequestDescriber
+ class IncorrectDescribe < StandardError; end
+
RESERVED_HEADER_NAMES = %w[
content-type
host
https
].freeze
@@ -60,10 +62,13 @@
end
end
let(:endpoint_segments) do
current_example = ::RSpec.respond_to?(:current_example) ? ::RSpec.current_example : example
- current_example.full_description.match(/(#{::Regexp.union(SUPPORTED_METHODS)}) (\S+)/).to_a
+ match = current_example.full_description.match(/(#{::Regexp.union(SUPPORTED_METHODS)}) (\S+)/)
+ raise IncorrectDescribe, 'Please use the format "METHOD /path" for the describe' unless match
+
+ match.to_a
end
# @return [String] e.g. `"get"`
let(:http_method) do
endpoint_segments[1].downcase