RSpec - Testing feature failing because elements are not rendered in test execution

1

I have a test feature that fails because at the time it runs some HTML elements ( <li data-podcast> ) have not yet been rendered.

Does anyone know how I can fix this?

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

    
asked by anonymous 05.08.2017 / 03:31

1 answer

0

Resolved.

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

FactoryGirl.create_list(:podcast, 3)
    
06.08.2017 / 23:35