cb9d03f0d4
Also add test to ensure basic model does not explode when initialized with nil.
27 lines
517 B
Ruby
27 lines
517 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({})
|
|
end
|
|
end
|
|
end
|