Sha256: a368e21ac945e167726f91d5d8b69ad38328d137fcab36eae90da0b91ea5de8c

Contents?: true

Size: 943 Bytes

Versions: 8

Compression:

Stored size: 943 Bytes

Contents

require 'test_helper'

module PushType
  class CustomizableTest < ActiveSupport::TestCase

    class TestPage < PushType::Node
      field :foo
      field :bar, :text
      field :baz, validates: { presence: true }
      field :qux, :number, validates: { presence: true }
    end

    let(:page) { TestPage.new }
    let(:fields) { page.fields }

    it { TestPage.fields.must_be_instance_of Hash }
    it { fields.must_be_instance_of Hash }

    describe '.field' do
      it { fields[:foo].must_be_instance_of StringField }
      it { fields[:bar].must_be_instance_of TextField }
      it { fields[:baz].must_be_instance_of StringField }
      it { TestPage.validators_on(:baz).map(&:class).must_include ActiveRecord::Validations::PresenceValidator }
      it { fields[:qux].must_be_instance_of NumberField }
      it { TestPage.validators_on(:qux).map(&:class).must_include ActiveRecord::Validations::PresenceValidator }
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
push_type_core-0.8.0.beta.1 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.7.0 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.7.0.beta.1 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.6.0 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.6.0.beta.4 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.6.0.beta.3 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.6.0.beta.2 test/models/concerns/push_type/customizable_test.rb
push_type_core-0.6.0.beta.1 test/models/concerns/push_type/customizable_test.rb