Sha256: 5c7b49cb6c956b03f32d7f232b075e6357bb4b3f283e5c83ccc5a421dd251beb

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

class BasicFieldsTest < ActiveSupport::TestCase

  BASIC_FIELDS = %w(email phone text password color date datetime
                    datetime_local number range
                    search telephone time url week)

  test "text requires parent" do
    fragment = -> {
      text :name
    }
    assert_raises(RuntimeError) {
      ExpressTemplates.compile(&fragment)
    }
  end

  test "all fields work" do
    BASIC_FIELDS.each do |type|
      fragment = -> {
        express_form(:foo) {
          send(type, :bar)
        }
      }
      assert_match '#{label_tag("foo_bar", "Bar")', ExpressTemplates.compile(&fragment)
      assert_match "#{type}_field(:foo, :bar)", ExpressTemplates.compile(&fragment)
    end
  end

  test "textarea uses rails text_area helper" do
    fragment = -> {
      express_form(:foo) {
        textarea :bar
      }
    }
    assert_match '#{label_tag("foo_bar", "Bar")', ExpressTemplates.compile(&fragment)
    assert_match "text_area(:foo, :bar)", ExpressTemplates.compile(&fragment)
  end


  test "hidden uses rails hidden_tag helper" do
    fragment = -> {
      express_form(:foo) {
        hidden :bar
      }
    }
    assert_no_match '#{label_tag("foo_bar", "Bar")', ExpressTemplates.compile(&fragment)
    assert_match "hidden_field(:foo, :bar)", ExpressTemplates.compile(&fragment)
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
express_admin-1.2.1 vendor/gems/express_templates/test/components/forms/basic_fields_test.rb
express_admin-1.2.0 vendor/gems/express_templates/test/components/forms/basic_fields_test.rb
express_templates-0.5.0 test/components/forms/basic_fields_test.rb
express_templates-0.4.2 test/components/forms/basic_fields_test.rb
express_templates-0.4.1 test/components/forms/basic_fields_test.rb
express_templates-0.4.0 test/components/forms/basic_fields_test.rb