Sha256: b5211bc83a84f2b88e4403423ca4f06bf19f233149bf864c2cd8eadff9340ae9

Contents?: true

Size: 1.3 KB

Versions: 24

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe ActiveRemote::Validations do
  let(:invalid_record) { ::Post.new }
  let(:valid_record) { ::Post.new(:name => 'test') }

  before { allow(valid_record).to receive(:create_or_update).and_return(true) }
  before { allow(invalid_record).to receive(:create_or_update).and_return(true) }

  describe 'save' do
    context 'valid record' do
      it 'returns true' do
        result = valid_record.save
        expect(result).to be true
      end
    end

    context 'invalid record' do
      it 'returns false' do
        result = invalid_record.save
        expect(result).to be false
      end
    end
  end

  describe 'save!' do
    context 'valid record' do
      it 'returns true' do
        result = valid_record.save!
        expect(result).to be true
      end
    end

    context 'invalid record' do
      it 'raises invalid record error' do
        expect { invalid_record.save! }.to raise_error(ActiveRemote::RemoteRecordInvalid)
      end
    end
  end

  describe 'valid?' do
    context 'valid record' do
      it 'returns true' do
        result = valid_record.valid?
        expect(result).to be true
      end
    end

    context 'invalid record' do
      it 'returns false' do
        result = invalid_record.valid?
        expect(result).to be false
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
active_remote-2.3.2 spec/lib/active_remote/validations_spec.rb
active_remote-2.3.1 spec/lib/active_remote/validations_spec.rb
active_remote-2.3.0 spec/lib/active_remote/validations_spec.rb
active_remote-2.2.0 spec/lib/active_remote/validations_spec.rb