Sha256: 92cd54684659e29679207d58c469e5eabf9c786bdaf2fa85a6f1329a866dc93d

Contents?: true

Size: 994 Bytes

Versions: 20

Compression:

Stored size: 994 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
      subject.should_receive(:create).and_return(nil)
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
zendesk_api-0.3.14 spec/core/create_resource_spec.rb
zendesk_api-0.3.13 spec/core/create_resource_spec.rb
zendesk_api-0.3.12 spec/core/create_resource_spec.rb
zendesk_api-0.3.11 spec/core/create_resource_spec.rb
zendesk_api-0.3.10 spec/core/create_resource_spec.rb
zendesk_api-0.3.9 spec/core/create_resource_spec.rb
zendesk_api-0.3.8 spec/core/create_resource_spec.rb
zendesk_api-0.3.7 spec/core/create_resource_spec.rb
zendesk_api-0.3.6 spec/core/create_resource_spec.rb
zendesk_api-0.3.5 spec/core/create_resource_spec.rb
zendesk_api-0.3.4 spec/core/create_resource_spec.rb
zendesk_api-0.3.3 spec/core/create_resource_spec.rb
zendesk_api-0.3.2 spec/core/create_resource_spec.rb
zendesk_api-0.3.1 spec/core/create_resource_spec.rb
zendesk_api-0.3.0 spec/core/create_resource_spec.rb
zendesk_api-0.2.6 spec/core/create_resource_spec.rb
zendesk_api-0.2.5 spec/core/create_resource_spec.rb
zendesk_api-0.2.4 spec/core/create_resource_spec.rb
zendesk_api-0.2.2 spec/core/create_resource_spec.rb
zendesk_api-0.2.1 spec/core/create_resource_spec.rb