require 'test_helper' class RadioTest < ActiveSupport::TestCase test "radio requires a parent component" do fragment = -> { radio :preferred_email_format, ['HTML', 'Text'] } assert_raises(RuntimeError) { ExpressTemplates.compile(&fragment) } end def radio_with_array_options fragment = -> { express_form(:person) { radio :preferred_email_format, ['HTML', 'Text'] } } end test "radio has correct label field name and text" do assert_match '#{label_tag("person_preferred_email_format", "Preferred Email Format")}', ExpressTemplates.compile(&radio_with_array_options) end test "radio options present with class 'radio'" do compiled = ExpressTemplates.compile(&radio_with_array_options) assert_match 'radio_button(:person, :preferred_email_format, "Text", class: "radio"', compiled assert_match '_format, "HTML", class: "radio"', compiled end def radio_with_hash_options fragment = -> { express_form(:person) { radio :subscribed, {1 => 'Yes', 0 => 'No'}, wrapper_class: 'my-wrapper' } } end test "radio options may be specified with a hash" do compiled = ExpressTemplates.compile(&radio_with_hash_options) assert_match '