rspec doesn't run first test case

90 Views Asked by At

The block #update doesn't run. Why? How to change it to run all of them. #anything works fine.

describe UsersController, type: :controller do
  login_admin

  describe '#update' do
    def user_update_params(roles:)
      {
        role_ids: roles.map(&:id),
        name: 'new'
      }
    end

    shared_examples_for 'update user' do
      it 'change the user' do
        expect do
          put :update, id: user.id, user: user_params
        end.to change { user.reload.name }
      end
    end
  end

  describe '#anything' do
    it 'is ok' do
      #runs ok
    end
  end
end
1

There are 1 best solutions below

0
On

It's a shared example, not a real test. It is supposed to be included in other test groups. Like this:

  describe '#whatever' do
    it_behaves_like 'update user'

    it 'runs shared example' do
    end
  end