Sha256: e2e66e0aab2dac67ae0d6bc20720396715b53b1a1e630c3f739b42f06f1d70eb
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'simple_form' require 'active_enum/form_helpers/simple_form' describe 'ActiveEnum::FormHelpers::Simple' do include RSpec::Rails::HelperExampleGroup include SimpleForm::ActionViewExtensions::FormHelper before do controller.stub!(:action_name).and_return('new') reset_class Person do enumerate :sex do value :id => 1, :name => 'Male' value :id => 2, :name => 'Female' end end end it "should use enum input type for enumerated attribute" do output = simple_form_for(Person.new, :url => people_path) do |f| concat f.input(:sex) end output.should have_selector('select#person_sex') output.should have_xpath('//option[@value=1]', :content => 'Male') output.should have_xpath('//option[@value=2]', :content => 'Female') end it "should not use enum input type if :as option indicates other type" do output = simple_form_for(Person.new, :url => people_path) do |f| concat f.input(:sex, :as => :string) end output.should have_selector('input#person_sex') end it "should raise error if attribute for enum input is not enumerated" do lambda { simple_form_for(Person.new, :url => people_path) {|f| f.input(:attending, :as => :enum) } }.should raise_error(StandardError, "Attribute 'attending' has no enum class") end it "should not use enum input type if class does not support ActiveEnum" do output = simple_form_for(:not_active_record, NotActiveRecord.new, :url => people_path) do |f| concat f.input(:name) end output.should have_selector('input#not_active_record_name') end def people_path '/people' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_enum-0.9.0 | spec/active_enum/form_helpers/simple_form_spec.rb |
active_enum-0.8.2 | spec/active_enum/form_helpers/simple_form_spec.rb |