Module: RCV::Spec::ClassMethods

Defined in:
lib/rcv/spec.rb

Instance Method Summary collapse

Instance Method Details

#should_reverse_play(cassette_file) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rcv/spec.rb', line 8

def should_reverse_play(cassette_file)
  describe "cassette: #{cassette_file}" do
    results = RCV::Cassette.new(cassette_file).reverse_play
    results.each_with_index  do |(request, actual, expected), i|
      describe "#{i}: #{request[:method]} #{request[:url]}" do
        it "should match status" do
          make_expectation(*[actual, expected].map{|h| h[:status]})
        end
        it "should match headers" do
          expected[:headers].each do |k,v|
            make_expectation actual[:headers][k], v
          end
        end
        it "should match body" do
          make_expectation(*[actual, expected].map{|h| h[:body]})
        end
      end
    end
  end
end