Sha256: d104a545b0c185f33169d6a1d1c29b7f71c2b4d02e4857553dbd9a2f693c5d47

Contents?: true

Size: 1.03 KB

Versions: 20

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe ActiveRestClient::Recording do
  it "can confirm if a recording callback is set" do
    class MyObject1
      include ActiveRestClient::Recording
    end
    expect(MyObject1.record_response?).to be_false
    MyObject1.record_response do
      puts "Hello world"
    end
    expect(MyObject1.record_response?).to be_true
  end

  it "remembers a block given to it to later be called back" do
    class MyObject2
      include ActiveRestClient::Recording
    end
    MyObject2.record_response do
      puts "Hello world"
    end
    expect(MyObject2.instance_variable_get(:@record_response)).to_not be_nil
  end

  it "calls back to the block if record_response is given a url and response" do
    class MyObject3
      include ActiveRestClient::Recording
    end
    MyObject3.record_response do |url, response|
      raise Exception.new("#{url}|#{response}")
    end
    expect{MyObject3.record_response("http://www.example.com/", "Hello world")}.to raise_error(Exception, 'http://www.example.com/|Hello world')
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active_rest_client-1.0.6 spec/lib/recording_spec.rb
active_rest_client-1.0.5 spec/lib/recording_spec.rb
active_rest_client-1.0.4 spec/lib/recording_spec.rb
active_rest_client-1.0.3 spec/lib/recording_spec.rb
active_rest_client-1.0.2 spec/lib/recording_spec.rb
active_rest_client-1.0.1 spec/lib/recording_spec.rb
active_rest_client-1.0.0 spec/lib/recording_spec.rb
active_rest_client-0.9.75 spec/lib/recording_spec.rb
active_rest_client-0.9.73 spec/lib/recording_spec.rb
active_rest_client-0.9.72 spec/lib/recording_spec.rb
active_rest_client-0.9.71 spec/lib/recording_spec.rb
active_rest_client-0.9.70 spec/lib/recording_spec.rb
active_rest_client-0.9.69 spec/lib/recording_spec.rb
active_rest_client-0.9.68 spec/lib/recording_spec.rb
active_rest_client-0.9.67 spec/lib/recording_spec.rb
active_rest_client-0.9.66 spec/lib/recording_spec.rb
active_rest_client-0.9.65 spec/lib/recording_spec.rb
active_rest_client-0.9.60 spec/lib/recording_spec.rb
active_rest_client-0.9.59 spec/lib/recording_spec.rb
active_rest_client-0.9.58 spec/lib/recording_spec.rb