Sha256: 85812fa6504a11c7cbd151b4e1a7455e5f223eaf600669381be6234fb29d47b8

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe Facemock::Database::Permission do
  include TableHelper

  let(:table_name)   { :permissions }
  let(:column_names) { [ :id, :name, :user_id, :created_at ] }
  let(:children)     { [] }

  let(:id)           { 1 }
  let(:name)         { "read_stream" }
  let(:user_id)      { 1 }
  let(:created_at)   { Time.now }
  let(:options)      { { id: id, name: name, user_id: user_id, created_at: created_at } }

  after { remove_dynamically_defined_all_method }

  describe '::TABLE_NAME' do
    subject { Facemock::Database::Permission::TABLE_NAME }
    it { is_expected.to eq table_name }
  end

  describe '::COLUMN_NAMES' do
    subject { Facemock::Database::Permission::COLUMN_NAMES }
    it { is_expected.to eq column_names }
  end

  describe '::CHILDREN' do
    subject { Facemock::Database::Permission::CHILDREN }
    it { is_expected.to eq children }
  end

  describe '#initialize' do
    context 'without option' do
      subject { Facemock::Database::Permission.new }
      it { is_expected.to be_kind_of Facemock::Database::Permission }

      context 'then attributes' do
        it 'should be nil' do
          column_names.each do |column_name|
            value = Facemock::Database::Permission.new.send(column_name)
            expect(value).to be_nil
          end
        end
      end
    end

    context 'with all options' do
      subject { Facemock::Database::Permission.new(options) }
      it { is_expected.to be_kind_of Facemock::Database::Permission }

      context 'then attributes' do
        it 'should set specified value by option' do
          column_names.each do |column_name|
            value = Facemock::Database::Permission.new(options).send(column_name)
            expect(value).to eq options[column_name]
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facemock-0.0.7 spec/facemock/database/permission_spec.rb