Sha256: 00949854490eb1036c876083b3c925a31557983b51e86ea039419f5370bc595c

Contents?: true

Size: 1.06 KB

Versions: 21

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Arstotzka::ClassMethods do
  describe 'yard' do
    let!(:instance) { klass.new(hash) }
    let(:klass) do
      Class.new(MyModel) do
        include Arstotzka
        expose :first_name, full_path: 'name.first'
        expose :age, 'cars', type: :integer
      end
    end
    let(:hash) do
      {
        'name' => { first: 'John', last: 'Williams' },
        :age => '20',
        'cars' => 2.0
      }
    end

    describe '#first_name' do
      it 'crawls into the hash to find the value of the first name' do
        expect(instance.first_name).to eq('John')
      end
    end

    describe '#age' do
      it 'crawls into the hash to find the value of the age' do
        expect(instance.age).to eq(20)
      end

      it do
        expect(instance.age).to be_a(Integer)
      end
    end

    describe '#cars' do
      it 'crawls into the hash to find the value of the age' do
        expect(instance.cars).to eq(2)
      end

      it do
        expect(instance.cars).to be_a(Integer)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
arstotzka-1.6.2 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.6.1 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.6.0 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.5.0 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.4.4 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.4.3 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.4.2 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.4.1 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.4.0 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.3.2 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.3.1 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.3.0 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.2.4 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.2.3 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.2.2 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.2.1 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.2.0 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.1.0 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.0.4 spec/integration/yard/arstotzka/class_methods_spec.rb
arstotzka-1.0.3 spec/integration/yard/arstotzka/class_methods_spec.rb