Skip to content
This repository
tree: 9b84dd4b28
Fetching contributors…

Cannot retrieve contributors at this time

file 32 lines (26 sloc) 0.67 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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
Something went wrong with that request. Please try again.