require 'abstract_unit' class FormCountryHelperTest < ActionView::TestCase tests ActionView::Helpers::FormCountryHelper silence_warnings do Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin) end def test_country_select @post = Post.new @post.origin = "Denmark" expected_select = <<-COUNTRIES COUNTRIES assert_dom_equal(expected_select[0..-2], country_select("post", "origin")) end def test_country_select_with_priority_countries @post = Post.new @post.origin = "Denmark" expected_select = <<-COUNTRIES COUNTRIES assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"])) end def test_country_select_with_selected_priority_country @post = Post.new @post.origin = "New Zealand" expected_select = <<-COUNTRIES COUNTRIES assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"])) end def test_country_select_under_fields_for @post = Post.new @post.origin = "Australia" expected_select = <<-COUNTRIES COUNTRIES fields_for :post, @post do |f| concat f.country_select("origin") end assert_dom_equal(expected_select[0..-2], output_buffer) end def test_country_select_under_fields_for_with_index @post = Post.new @post.origin = "United States" expected_select = <<-COUNTRIES COUNTRIES fields_for :post, @post, :index => 325 do |f| concat f.country_select("origin") end assert_dom_equal(expected_select[0..-2], output_buffer) end def test_country_select_under_fields_for_with_auto_index @post = Post.new @post.origin = "Iraq" def @post.to_param; 325; end expected_select = <<-COUNTRIES COUNTRIES fields_for "post[]", @post do |f| concat f.country_select("origin") end assert_dom_equal(expected_select[0..-2], output_buffer) end end