Sha256: 2b0b0ed1346971f3ed5b6c184c16075e0e6a56b25b4ad0a97abb324f7c4385e4

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

describe Stenographer::Output, type: :model do
  it 'has a valid blueprint' do
    expect(build(:output)).to be_valid
  end

  describe 'Associations' do
    subject { build(:output) }

    it { is_expected.to belong_to(:authentication).class_name('Stenographer::Authentication') }
  end

  describe 'Validations' do
    subject { create(:output) }

    it { is_expected.to validate_presence_of(:authentication_id) }
    it { is_expected.to validate_presence_of(:configuration) }
  end

  describe 'Methods' do
    let!(:output) { create(:output) }

    describe '#configuration_hash' do
      describe 'nil' do
        before :each do
          output.update(configuration: nil)
        end

        it 'empty hash' do
          expect(output.configuration_hash).to eq({})
        end
      end

      describe 'has data' do
        before :each do
          output.update(configuration: { country: 'Ibiza' }.to_json)
        end

        it 'hash with values' do
          expect(output.configuration_hash[:country]).to eq('Ibiza')
        end
      end
    end

    describe '#filters_hash' do
      describe 'nil' do
        before :each do
          output.update(filters: nil)
        end

        it 'empty hash' do
          expect(output.filters_hash).to eq({})
        end
      end

      describe 'has data' do
        before :each do
          output.update(filters: { country: 'Ibiza' }.to_json)
        end

        it 'hash with values' do
          expect(output.filters_hash[:country]).to eq('Ibiza')
        end
      end
    end

    describe '#provider' do
      it 'returns the authentication provider' do
        expect(output.provider).to eq(output.authentication.provider)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stenographer-rails-0.6.5 spec/models/stenographer/output_spec.rb
stenographer-rails-0.6.4 spec/models/stenographer/output_spec.rb
stenographer-rails-0.6.3 spec/models/stenographer/output_spec.rb
stenographer-rails-0.6.2 spec/models/stenographer/output_spec.rb
stenographer-rails-0.6.1 spec/models/stenographer/output_spec.rb
stenographer-rails-0.6.0 spec/models/stenographer/output_spec.rb