Sha256: b7f4861d18d6db2363e410d665eff0701320de35b72a0ed8780b7782cfbdb247

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper'

describe Mavenlink::Specificators::Validation do
  subject { model.new }

  before { described_class.apply(model) }

  let(:model) do
    Class.new Mavenlink::Model do
      attr_accessor :name

      def self.specification
        {'validations' => {'name' => {'presence' => true}}}
      end

      def self.model_name
        ActiveModel::Name.new(self, nil, 'temp')
      end
    end
  end

  it { should validate_presence_of :name }

  describe 'real model' do
    let(:client) { Object.new }

    context 'new record' do
      subject { Mavenlink::Workspace.new({}, nil, client) }

      it { should validate_presence_of :title }
    end

    context 'persisted record' do
      subject { Mavenlink::Workspace.new({ id: 12 }, nil, client) }

      it { should validate_presence_of :title }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mavenlink-0.0.1 spec/lib/mavenlink/specificators/validation_spec.rb