Module: SerialSpec::ClassMethods

Defined in:
lib/serial_spec.rb

Instance Method Summary collapse

Instance Method Details

#with_request(request_str, params = {}, envs = {}, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/serial_spec.rb', line 17

def with_request(request_str, params={}, envs={}, &block)
  if request_str.split(/\s+/).count == 2
    request_method_string, request_path_str = request_str.split(/\s+/)
  end

  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
      end
    end

    instance_exec(&block) if block_given?

    it "should match all examples: #{__inherited_expectations__.keys}" do
      perform_request!
    end

  end

end