Skip to content

Commit

Permalink
Reorganize tests a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 8, 2010
1 parent 25cc5b1 commit 2a1b232
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions test/inputs_test.rb
Expand Up @@ -27,27 +27,12 @@ def with_input_for(object, attribute_name, type, options={})
assert_select 'select.datetime'
end

# TextFieldInput
# StringInput
test 'input should map text field to string attribute' do
with_input_for @user, :name, :string
assert_select 'input[name=\'user[name]\'][id=user_name][value=New in Simple Form!][type=text]'
end

test 'input should generate an integer text field for integer attributes ' do
with_input_for @user, :age, :integer
assert_select 'input[type=number].integer#user_age'
end

test 'input should generate a float text field for float attributes ' do
with_input_for @user, :age, :float
assert_select 'input[type=number].float#user_age'
end

test 'input should generate a decimal text field for decimal attributes ' do
with_input_for @user, :age, :decimal
assert_select 'input[type=number].decimal#user_age'
end

test 'input should use default text size for decimal attributes' do
with_input_for @user, :credit_limit, :decimal
assert_select 'input.decimal[size=50]'
Expand All @@ -63,6 +48,22 @@ def with_input_for(object, attribute_name, type, options={})
assert_select 'input.string[size=50]'
end

# NumericInput
test 'input should generate an integer text field for integer attributes ' do
with_input_for @user, :age, :integer
assert_select 'input[type=number].integer#user_age'
end

test 'input should generate a float text field for float attributes ' do
with_input_for @user, :age, :float
assert_select 'input[type=number].float#user_age'
end

test 'input should generate a decimal text field for decimal attributes ' do
with_input_for @user, :age, :decimal
assert_select 'input[type=number].decimal#user_age'
end

# BooleanInput
test 'input should generate a checkbox by default for boolean attributes' do
with_input_for @user, :active, :boolean
Expand Down

0 comments on commit 2a1b232

Please sign in to comment.