pokemon_spec.rb 665 B

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