pokemon_spec.rb 696 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Pokemon', type: :system do
  4. let!(:pokemon) { create_list(:pokemon, 10) }
  5. context 'viewing' do
  6. context 'on the index page' do
  7. before { visit('/pokemon') }
  8. it 'shows me pokemon' do
  9. pokemon.each do |pkmn|
  10. expect(page).to have_text pkmn.nickname
  11. end
  12. end
  13. end
  14. context 'individual pokemon' do
  15. let!(:random_pokemon) { pokemon.sample }
  16. before { visit("/pokemon/#{random_pokemon.id}") }
  17. it 'shows me the pokemon' do
  18. expect(page).to have_text random_pokemon.id
  19. expect(page).to have_text random_pokemon.nickname
  20. end
  21. end
  22. end
  23. end