Sha256: 10b510acc39ad341d0477f447896bd65827bea48a56c195ad5e5e9c61066d390

Contents?: true

Size: 916 Bytes

Versions: 3

Compression:

Stored size: 916 Bytes

Contents

# encoding: utf-8
require "spec_helper"

module Hexx
  describe Helpers::Validations do

    before { class Test; include Helpers::Validations; end }
    after  { Hexx.send :remove_const, :Test }

    let(:service_invalid) { Hexx::ServiceInvalid }
    let(:message)         { Hexx::Message.new type: "error", text: "text" }
    let(:described_class) { Test }
    subject { described_class.new }

    it "includes ActiveModel::Validations" do
      expect(described_class).to include ActiveModel::Validations
    end

    describe "#validate!" do

      it "passes when service is valid" do
        allow(subject).to receive(:valud?).and_return true
        expect { subject.validate! }.not_to raise_error
      end

      it "fails when service is invalid" do
        allow(subject).to receive(:valid?).and_return false
        expect { subject.validate! }.to raise_error service_invalid
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hexx-7.1.0 spec/hexx/helpers/validations_spec.rb
hexx-7.0.1 spec/hexx/helpers/validations_spec.rb
hexx-7.0.0 spec/hexx/helpers/validations_spec.rb