Sha256: 7ccbfc638a41b846e364ae9c6ff62ab9e4ed21370f86be3043f5cbb3c42d9660

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 Bytes

Contents

require "spec_helper"

describe ::ActiveRemote::RemoteRecordNotSaved do
  let(:record) { ::Tag.new }

  before do
    record.errors.add(:base, :invalid, :message => "Some error one!")
    record.errors.add(:base, :invalid, :message => "Some error two!")
  end

  context "when an active remote record is used" do
    it "uses embedded errors in message" do
      expect { fail(::ActiveRemote::RemoteRecordNotSaved, record) }
        .to raise_error(ActiveRemote::RemoteRecordNotSaved, "Some error one!, Some error two!")
    end
  end

  context "when a string is used" do
    it "uses the string in the error message" do
      expect { fail(::ActiveRemote::RemoteRecordNotSaved, "something bad happened") }
        .to raise_error(ActiveRemote::RemoteRecordNotSaved, "something bad happened")
    end
  end

  context "when no message is used" do
    it "raises the error" do
      expect { raise(::ActiveRemote::RemoteRecordNotSaved) }
        .to raise_error(ActiveRemote::RemoteRecordNotSaved)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_remote-6.1.2 spec/lib/active_remote/errors_spec.rb
active_remote-7.0.0 spec/lib/active_remote/errors_spec.rb
active_remote-6.1.1 spec/lib/active_remote/errors_spec.rb
active_remote-6.1.0 spec/lib/active_remote/errors_spec.rb