Sha256: c54db218dfa2573024edf2a2ea1483a1dc8d9264473c428d7d4fb202bd0afa02

Contents?: true

Size: 986 Bytes

Versions: 14

Compression:

Stored size: 986 Bytes

Contents

RSpec.shared_examples_for "a saveable resource" do |factory_name|
  describe '#save' do
    context 'with a new resource' do
      cassette
      let(:resource) { build factory_name }
      subject { resource.save }

      it 'succeeds' do
        expect(subject).to be_truthy
      end

      it 'sets the ID' do
        expect {
          subject
        }.to change { resource.id }.from(nil)
      end

      it 'clears the changes' do
        expect {
          subject
        }.to change { resource.changed? }.from(true).to(false)
      end
    end

    context 'with an existing resource' do
      cassette
      let(:resource) { create factory_name }
      subject { resource.save }

      before(:each) do
        set_property(resource)
      end

      it 'succeeds' do
        expect(subject).to be_truthy
      end

      it 'clears the changes' do
        expect {
          subject
        }.to change { resource.changed? }.from(true).to(false)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hubspot-api-ruby-0.19.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.18.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.17.1 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.17.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.16.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.15.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.14.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.13.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.12.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.11.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.10.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.9.0 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.8.1 spec/shared_examples/saveable_resource.rb
hubspot-api-ruby-0.8.0 spec/shared_examples/saveable_resource.rb