Sha256: 88655160836baf62fe2dcdb4203b742cb0a02d8642896b5ecb7e72f76e0db135

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Acfs::Resource::Initialization' do
  let(:model) do
    Class.new(Acfs::Resource).tap do |c|
      c.class_eval do
        attr_accessor :name
        attr_reader :age

        private

        attr_writer :age
      end
    end
  end

  describe '#initialize' do
    it 'allows to set attributes with initializer' do
      m = model.new name: 'John'
      expect(m.name).to eq 'John'
    end

    it 'raises error when attributes with private setters are given' do
      expect { model.new age: 25 }.to raise_error(NoMethodError)
    end
  end

  describe '#persisted?' do
    it 'is false' do
      expect(model.new.persisted?).to be false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acfs-2.0.0 spec/acfs/resource/initialization_spec.rb
acfs-1.7.0 spec/acfs/resource/initialization_spec.rb