Sha256: 9fc7fe4ce4ed40d6bf50ffeaf02fbdf5d3ec22a81e05e29829906d98563d012a

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe PokemonMastersController do
  describe 'POST create' do
    let(:parameters) do
      {
        format: :json,
        pokemon_master: {
          first_name: 'Ash'
        }
      }
    end

    it 'creates pokemon master' do
      expect { post :create, params: parameters }
        .to change(PokemonMaster, :count)
        .by(1)
    end

    it 'updates pokemon master age' do
      post :create, params: parameters

      expect(PokemonMaster.last.age).to eq(10)
    end
  end

  describe 'POST update' do
    let(:master) do
      create(:pokemon_master, age: 20, last_name: nil)
    end

    let(:parameters) do
      {
        id: master.id,
        format: :json,
        pokemon_master: { last_name: 'Joe' }
      }
    end

    it 'updates pokemon master' do
      expect { post :update, params: parameters }
        .to change { master.reload.last_name }
        .from(nil)
        .to('Joe')
    end

    it 'updates pokemon master age' do
      expect { post :update, params: parameters }
        .to change { master.reload.age }
        .from(20)
        .to(10)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
azeroth-1.0.0 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.10.1 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.10.0 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.9.0 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.8.2 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.8.1 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.8.0 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.7.4 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.7.3 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.7.2 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.7.1 spec/controllers/pokemon_masters_controller_spec.rb
azeroth-0.7.0 spec/controllers/pokemon_masters_controller_spec.rb