1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/cases/model_test.rb
Attila Domokos 01434a5ee6 Adding tests for ActiveModel::Model
* Verifying persisted? is false when Model initialized
* Passing nil to Model should not blow up
* Changing test name to the one suggested in pull request comment
2013-01-12 20:04:24 -05:00

32 lines
670 B
Ruby

require 'cases/helper'
class ModelTest < ActiveModel::TestCase
include ActiveModel::Lint::Tests
class BasicModel
include ActiveModel::Model
attr_accessor :attr
end
def setup
@model = BasicModel.new
end
def test_initialize_with_params
object = BasicModel.new(:attr => "value")
assert_equal object.attr, "value"
end
def test_initialize_with_nil_or_empty_hash_params_does_not_explode
assert_nothing_raised do
BasicModel.new()
BasicModel.new nil
BasicModel.new({})
end
end
def test_persisted_is_always_false
object = BasicModel.new(:attr => "value")
assert object.persisted? == false
end
end