Sha256: 5971af291f6c7a1b93beff158d6fe7a4e87973d15180de87609fe0068621cc1f

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require "spec_helper"
require "ostruct"

RSpec.describe Pokeedex::Pokemon::Decorators::Base do
  let(:decorator) { described_class }
  let(:pokemon) do
    OpenStruct.new(
      number: 1,
      name: "Bulbasaur",
      description: "Tras nacer, crece alimentándose durante un tiempo de los nutrientes que contiene el bulbo de su lomo.",
      hight: 0.7,
      weight: 6.9,
      category: "Semilla",
      abilities: ["Espesura"],
      gender: ["male", "female"],
      types: ["Planta", "Veneno"],
      weakness: ["Fuego", "Hielo", "Volador", "Psíquico"],
      stats: {"PS" => 3, "Ataque" => 3, "Defensa" => 3, "Ataque Especial" => 4, "Defensa Especial" => 4, "Velocidad" => 3}
    )
  end

  describe "#to_s" do
    let(:expected) do
      <<~DECORATOR
        Número: 1
        Nombre: Bulbasaur
        Descripción: Tras nacer, crece alimentándose durante un tiempo de los nutrientes que contiene el bulbo de su lomo.
        Altura: 0.7 m
        Peso: 6.9 kg
        Categoría: Semilla
        Habilidades: Espesura
        Genero: Macho, Hembra
        Tipo: Planta, Veneno
        Habilidades: Fuego, Hielo, Volador, Psíquico

        Puntos de base
        ###------------ PS
        ###------------ Ataque
        ###------------ Defensa
        ####----------- Ataque Especial
        ####----------- Defensa Especial
        ###------------ Velocidad

      DECORATOR
    end

    subject { decorator.new(pokemon).to_s }

    context "when the pokemon is present" do
      it "returns the decorated pokemon" do
        expect(subject).to eq(expected)
      end
    end

    context "when the pokemon is not present" do
      let(:pokemon) { nil }

      it 'returns the message "Pokemon\'s not found"' do
        expect(subject).to eq("Pokemon's not found")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pokeedex-0.1.5 spec/pokeedex/pokemon/decorators/base_spec.rb
pokeedex-0.1.0 spec/pokeedex/pokemon/decorators/base_spec.rb