Question

I have a page where user should see items he created. So I decided I want a feature test for that(with rspec and capybara). What I wanted to do something like this:

require 'spec_helper'

    feature "Accounts pages" do
      scenario "user views his accounts" do
        user = create(:user)

        sign_in user

        expect(current_path).to eq accounts_path
        expect(page).to have_content "Your accounts"

        #here I want to check if records were loaded and/or displayed on page
      end
    end

So my questions:

  1. Is it a good idea to test if records were loaded on a specific page in a feature spec, or should I write controller spec for that?
  2. If it's ok to go with feature spec here, what would be idiomatically correct way to do that?
Was it helpful?

Solution

You can't use controller spec to test if records are shown by any page as controller doesn't care what's displayed and what's not. In that case using feature spec sounds just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top