require 'test_helper' require 'ostruct' class SelectTest < ActiveSupport::TestCase def assigns {resource: ::Person.new} end test "select requires a parent component" do assert_raises(RuntimeError) { html = arbre { select :gender, options: ['Male', 'Female'], selected: 'Male' } } end test "select comes with a label" do html = arbre { express_form(:person) { select :gender } } assert_match /', html end test "select defaults can be overridden" do html = arbre { express_form(:person) { select :gender, include_blank: false } } assert_no_match 'include_blank: true', html end test "select multiple: true if passed multiple true" do html = arbre { express_form(:person) { select :taggings, include_blank: false, multiple: true } } assert_match 'multiple="multiple"', html end test "select multiple gets options from associated has_many_through collection" do html = arbre { express_form(:person) { select :taggings, include_blank: false, multiple: true } } assert_match 'tagging_ids', html assert_match /