Sha256: c607c70830a64c7e8ffb6414c141d5884d7cf06751094cbb48f67acba1e6a1eb

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: false

require 'spec_helper'

describe Class do
  describe 'yard' do
    describe '#default_value' do
      subject { klass.new }

      let(:klass) do
        Class.new do
          default_value :name, 'John'
        end
      end

      context 'when calling method' do
        it 'returns the same value always' do
          expect(subject.name).to eq('John')
        end

        it 'returns the same instance accros instances of the class' do
          expect(subject.name).not_to be_equal('John')
          expect(subject.name).to be_equal(klass.new.name)
        end
      end
    end

    describe '#default_values' do
      subject { klass.new }

      let(:klass) do
        Class.new do
          default_values :name, :nick_name, 'John'
        end
      end

      context 'when calling method' do
        it 'returns the same value always' do
          expect(subject.name).to eq('John')
        end

        it 'returns the same value always' do
          expect(subject.nick_name).to eq('John')
        end

        it 'returns the same instance accros instances of the class' do
          expect(subject.name).not_to be_equal('John')
          expect(subject.name).to be_equal(klass.new.name)
        end

        it 'returns the same instance for all methods' do
          expect(subject.nick_name).not_to be_equal('John')
          expect(subject.name).to be_equal(subject.nick_name)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
darthjee-core_ext-1.7.3 spec/integration/yard/class/default_value_spec.rb
darthjee-core_ext-1.7.2 spec/integration/yard/class/default_value_spec.rb
darthjee-core_ext-1.7.1 spec/integration/yard/class/default_value_spec.rb