Sha256: 4fb2c1e052d6f73d5e785d40d59f44e390dbdc1c30f4b437f5fb94008f8c1687

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Azeroth::Decorator do
  describe 'readme' do
    it 'decorates model' do
      master = PokemonMaster.create(
        first_name: 'Ash',
        last_name: 'Ketchum',
        age: 10
      )

      master.create_favorite_pokemon(
        name: 'pikachu',
        nickname: 'Pikachu'
      )

      metapod = Pokemon.create(name: :metapod)

      master.pokemons.create(
        name: 'butterfree', previous_form: metapod
      )
      master.pokemons.create(name: 'squirtle')

      decorator = PokemonMaster::Decorator.new(master)

      expect(decorator.as_json).to eq(
        {
          'age' => 10,
          'name' => 'Ash Ketchum',
          'favorite_pokemon' => {
            'name' => 'pikachu',
            'nickname' => 'Pikachu'
          },
          'pokemons' => [{
            'name' => 'butterfree',
            'evolution_of' => 'metapod'
          }, {
            'name' => 'squirtle'
          }, {
            'name' => 'pikachu'
          }]
        }
      )
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
azeroth-1.0.0 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.10.1 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.10.0 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.9.0 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.8.2 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.8.1 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.8.0 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.7.4 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.7.3 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.7.2 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.7.1 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.7.0 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.6.5 spec/integration/readme/azeroth/decorator_spec.rb
azeroth-0.6.4 spec/integration/readme/azeroth/decorator_spec.rb