# Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rspec/rails" require "factory_girl" # Load support files Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| config.use_transactional_fixtures = true end def default_selections @parent_1 = Factory(:selection, :system_code => "state") @child_1 = Factory(:selection, :parent => @parent_1) @child_2 = Factory(:selection, :parent => @parent_1, :is_default => true) @child_3 = Factory(:selection, :parent => @parent_1) @child_4 = Factory(:selection, :parent => @parent_1) end def selected_options options, selection, has_blank_item options.each do |child| selected = (selection && selection.id == child.id) ? "[selected='selected']" : "" assert_select "option[value='#{child.id}']#{selected}" end assert_select "option[selected='selected']", 0 unless selection assert_select "option[value='']", (has_blank_item ? 1 : 0) end