Sha256: 6328d2fda20ba1d14e067fd4f25afec47865d3276db04851e9ba8df9ee192ffc

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

shared_examples_for "a model with a create action" do |model_attributes|
  def invalid_attributes
    {}
  end

  describe ".create" do
    it "creates a model based on a hash of attributes" do
      model = nil

      VCR.use_cassette("#{classname}_create") do
        model = described_class.create!(model_attributes)
      end

      expect(model).to respond_to :id
      expect(model.id).not_to be_empty
    end

    it "raises a FailedRequestError when the create action fails" do
      VCR.use_cassette("#{classname}_create_failed") do
        expect { described_class.create!(invalid_attributes) }.to raise_error Namely::FailedRequestError
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
namely-0.0.1 spec/shared_examples/a_model_with_a_create_action.rb