Sha256: b0bd172d68c1eaf9fda3dff293473f424dae8e38a09d2914e7b4eaa2652d0f3f

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require "spec_helper"

module Hexx
  describe ServiceInvalid do

    let(:service) { Service.new }
    let(:error)   { Hexx::Message.new(type: "error", text: "some error") }

    describe ".new" do

      subject { Invalid }

      it "fails if no arguments given" do
        expect { described_class.new }.to raise_error ArgumentError
      end

      it "initializes the #service" do
        expect { described_class.new Service.new }.not_to raise_error
      end
    end

    describe "#messages" do

      subject { described_class.new(service).messages }
      let(:message) { subject.first }

      it "returns an array" do
        expect(subject).to be_kind_of Array
      end

      it "returns error messages" do
        service.errors.send :add, :base, error.text
        expect(message).to eq error
      end
    end

    describe "#message" do

      subject { described_class.new(service).message }

      it "returns a proper message" do
        expect(subject).to eq "Service invalid: #{ service.inspect }"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hexx-7.1.0 spec/hexx/service_invalid_spec.rb
hexx-7.0.1 spec/hexx/service_invalid_spec.rb
hexx-7.0.0 spec/hexx/service_invalid_spec.rb