mardi 1 août 2017

Rspec rails api controller index test

I'm trying to test an api controller action with rspec, but since i am quite new to rspec i can't make it work. I have the following index action: render json: @website.jobs

I have to find all associated jobs to a website by name. Here is my spec:

let(:endpoint) { FactoryGirl.create(:website) }
let(:job) { FactoryGirl.create(:job) }

subject do
  get :index, params: { format: :json, 
                       name: endpoint.name }
end

expect(subject.body).to include(:job)

Am i doing something wrong, or am i missing something ?

Aucun commentaire:

Enregistrer un commentaire