Sha256: 58e079b88bf20af7b460ef21e8a6f030a35a66544e42b0552d9f3ceb8ca9edda

Contents?: true

Size: 926 Bytes

Versions: 5

Compression:

Stored size: 926 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'json'

include ApiResource

describe Mocks do
  
  # we set up the mocks in spec helper, so we can just assert this
  it "should hijack the connection" do
    ApiResource::Mocks::Interface.any_instance.expects(:get).once.returns(
      ApiResource::Mocks::MockResponse.new("", {:headers => {"Content-type" => "application/json"}, :status_code => 200})
    )
    TestResource.reload_class_attributes
  end
  
  it "should allow the user to raise errors for invalid responsed" do
    old_err_status = ApiResource.raise_missing_definition_error 
    ApiResource::Base.raise_missing_definition_error = true
    
    lambda {
      class MyNewInvalidResource < ApiResource::Base; end
      MyNewInvalidResource.new 
    }.should raise_error(ApiResource::ResourceNotFound)
    
    ApiResource.raise_missing_definition_error = old_err_status
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
api_resource-0.2.5 spec/lib/mocks_spec.rb
api_resource-0.2.4 spec/lib/mocks_spec.rb
api_resource-0.2.3 spec/lib/mocks_spec.rb
api_resource-0.2.2 spec/lib/mocks_spec.rb
api_resource-0.2.1 spec/lib/mocks_spec.rb