Sha256: 67f7d347d91e5ad20f8a7f80cc07b3bc2601ec566636792c38359ef6bf802fc4

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require 'spec_helper'
require 'support/active_model_lint'

class ActiveModelTest
  include Id::Model
  include Id::Form

  field :sheep

  def wrapped_in_plastic?
    true
  end
end

describe ActiveModelTest do

  subject { ActiveModelTest.new.to_model }

  it_behaves_like "ActiveModel"

  it 'has an I18n scope of id' do
    expect(ActiveModelTest.new.to_model.class.i18n_scope).to eq :id
  end

  it 'can return the fields of the model' do
    model = ActiveModelTest.new(sheep: 42).to_model
    expect(model.sheep).to eq 42
  end

  it "doesn't blow up for nil fields" do
    model = ActiveModelTest.new.to_model
    expect(model.sheep).to be_nil
  end

  it 'delegates method calls to the original model' do
    model = ActiveModelTest.new.to_model
    expect(model).to be_wrapped_in_plastic
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
id-0.1.1 spec/lib/id/active_model_spec.rb
id-0.1 spec/lib/id/active_model_spec.rb