Sha256: 5474d31aaa6395baf50686a16fbe548f9daadb3f3106eae7f9a5b1a9f0a4f9a1

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class FieldSetTest < Presenting::Test
  def setup
    @set = Presenting::FieldSet.new(Presenting::Attribute, :name, :value)
  end
  
  def test_reading_a_field_by_name
    @set << "foo"
    assert_equal "foo", @set["foo"].name
  end
  
  def test_pushing_a_field_by_name
    @set << "foo"
    assert_equal "foo", @set.first.name
  end
  
  def test_pushing_a_field_by_name_and_value
    @set << {"foo" => :bar}
    assert_equal "foo", @set.first.name
    assert_equal :bar, @set.first.value
  end
  
  def test_pushing_a_field_by_name_and_options
    @set << {"foo" => {:value => :bar}}
    assert_equal "foo", @set.first.name
    assert_equal :bar, @set.first.value
  end
  
  def test_adding_a_field_by_name
    @set["foo"] = nil
    assert_equal "foo", @set.first.name
  end
  
  def test_adding_a_field_by_name_and_value
    @set["foo"] = :bar
    assert_equal "foo", @set.first.name
    assert_equal :bar, @set.first.value
  end
  
  def test_adding_a_field_by_name_and_options
    @set["foo"] = {:value => :bar}
    assert_equal "foo", @set.first.name
    assert_equal :bar, @set.first.value
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
presenting-3.0.0 test/field_set_test.rb
presenting-2.1.0 test/field_set_test.rb
presenting-2.0.3 test/field_set_test.rb
presenting-2.0.2 test/field_set_test.rb
presenting-2.0.1 test/field_set_test.rb