Rspec - Feature test failing because elements are not rendered in test execution

Asked

Viewed 21 times

1

I have a test Feature failing because the moment it runs some HTML elements (<li data-podcast>) not yet rendered.

Does anyone know how to fix it?

RSpec.describe 'Podcasts List', type: :feature do
  scenario 'A user visits the root page and views a podcasts list' do
    visit '/'

    within '[data-podcasts]' do
      expect(page).to have_selector 'li[data-podcast]', minimum: 3
    end
  end
end

inserir a descrição da imagem aqui

  • Are rendered via JS?

  • @Luizcarvalho no, an instance variable is populated with all db files (@podcasts = Podcast.all) and then do a each listing all of them (@podcasts.all.each do ..).

1 answer

0

Solved.

When we run our tests, the test database is accessed, not the development database. The solution was to instantiate all objects that were used in the Feature test:

FactoryGirl.create_list(:podcast, 3)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.