Sha256: 3118afc4522c3af5aa0d9989e5f171429a91485c052d35eadb1507178d3ff2de

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 KB

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
      expect(subject.create(client, attr)).to 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 { expect(subject.create(client, attr)).to 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(ZendeskAPI::Error::NetworkError)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
zendesk_api-1.13.1 spec/core/create_resource_spec.rb
zendesk_api-1.12.1 spec/core/create_resource_spec.rb
zendesk_api-1.12.0 spec/core/create_resource_spec.rb
zendesk_api-1.11.7 spec/core/create_resource_spec.rb
zendesk_api-1.11.6 spec/core/create_resource_spec.rb
zendesk_api-1.11.5 spec/core/create_resource_spec.rb
zendesk_api-1.11.4 spec/core/create_resource_spec.rb
zendesk_api-1.11.3 spec/core/create_resource_spec.rb
zendesk_api-1.11.2 spec/core/create_resource_spec.rb
zendesk_api-1.11.1 spec/core/create_resource_spec.rb
zendesk_api-1.11.0 spec/core/create_resource_spec.rb
zendesk_api-1.10.0 spec/core/create_resource_spec.rb