Sha256: dd67dbf68a79bf5eff6617b14fc5df177f90d7ee9fb646c410310a271b5b7a62

Contents?: true

Size: 1012 Bytes

Versions: 36

Compression:

Stored size: 1012 Bytes

Contents

require 'core/spec_helper'

describe ZendeskAPI::CreateResource do
  context "create" do
    let(:attr) { { :test_field => "blah" } }
    subject { ZendeskAPI::TestResource }

    before(:each) do
      stub_request(:post, %r{test_resources}).to_return(:body => json)
    end

    it "should return instance of resource" do
      subject.create(client, attr).should be_instance_of(subject) 
    end

    context "with client error" do
      before(:each) do
        stub_request(:post, %r{test_resources}).to_return(:status => 500)
      end

      it "should handle it properly" do
        expect { silence_logger { subject.create(client, attr).should be_nil } }.to_not raise_error
      end
    end
  end

  context "create!" do
    subject { ZendeskAPI::TestResource }

    before(:each) do
      stub_request(:post, %r{test_resources}).to_return(:status => 500)
    end

    it "should raise if save fails" do
      expect { subject.create!(client, :test_field => "blah") }.to raise_error
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
zendesk_api-1.3.9 spec/core/create_resource_spec.rb
zendesk_api-1.3.8 spec/core/create_resource_spec.rb
zendesk_api-1.3.7 spec/core/create_resource_spec.rb
zendesk_api-1.2.10 spec/core/create_resource_spec.rb
zendesk_api-1.2.9 spec/core/create_resource_spec.rb
zendesk_api-1.2.8 spec/core/create_resource_spec.rb
zendesk_api-1.3.5 spec/core/create_resource_spec.rb
zendesk_api-1.2.7 spec/core/create_resource_spec.rb
zendesk_api-1.3.4 spec/core/create_resource_spec.rb
zendesk_api-1.3.2 spec/core/create_resource_spec.rb
zendesk_api-1.3.1 spec/core/create_resource_spec.rb
zendesk_api-1.3.0 spec/core/create_resource_spec.rb
zendesk_api-1.3.0.rc3 spec/core/create_resource_spec.rb
zendesk_api-1.2.6 spec/core/create_resource_spec.rb
zendesk_api-1.3.0.rc2 spec/core/create_resource_spec.rb
zendesk_api-1.3.0.rc1 spec/core/create_resource_spec.rb
zendesk_api-1.2.5 spec/core/create_resource_spec.rb
zendesk_api-1.2.4 spec/core/create_resource_spec.rb
zendesk_api-1.2.3 spec/core/create_resource_spec.rb
zendesk_api-1.2.2 spec/core/create_resource_spec.rb