Sha256: 85245a109cdf7f62aa6a3580a87c9a4032c16a5f3432f875f90576332a5d4ab2

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 Bytes

Contents

require 'test_helper'

module PushType
  class StructureFieldTest < ActiveSupport::TestCase

    class TestPage < PushType::Node
      field :foo, :structure do
        field :key, :string
        field :val, :text
      end
    end

    let(:node)  { TestPage.create FactoryGirl.attributes_for(:node, foo: val) }
    let(:val)   { { key: 'a', val: 'b' } }
    let(:field) { node.fields[:foo] }

    it { field.template.must_equal 'structure' }
    it { field.fields.keys.must_include :key, :val }
    it { field.fields.values.map { |v| v.class }.must_include PushType::StringField, PushType::TextField }
    it { field.json_value.must_equal({ 'key' => 'a', 'val' => 'b' }) }
    it { field.value.class.name.must_equal 'PushType::Structure' }
    it { field.value.fields.keys.must_include :key, :val }
    it { field.value.key.must_equal 'a' }
    it { field.value.val.must_equal 'b' }

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
push_type_core-0.6.0.beta.2 test/fields/push_type/structure_field_test.rb
push_type_core-0.6.0.beta.1 test/fields/push_type/structure_field_test.rb