dimanche 20 mars 2016

rspec test of index, show all not archived

Im trying to set up a (basic) test for a new feature I am going to implement. I have a job controller and instead of default showing all jobs I like to hide all the ones which is archived. I tried different ways but it seems like i am missing a piece or two of this puzzle. First i tried with calling 'visit' but get the message it does not exist. Second approach is using 'render' but that also ends up in a error saying render does not exists. (can i even use these methods in a controller spec?)

Is it wrong to put this in a controller test?

2 last test are causing errors

require "rails_helper"
require "spec_helper"


describe JobsController, :type => :controller do 

  context 'GET index' do   
   it "should be successful" do
     get :index
     expect(response).to be_success
   end

  it "renders the index template" do
   get :index
   expect(response).to render_template("index")
 end

 it "should not show any archived jobs as default" do
    visit jobs_path
    page.should have_no_content("Archived")

 end

  it 'should show the headers' do
    render :template => 'job/index', :layout => 'layouts/job'
    rendered.should_not contain('Archived')

  end

 end
end

Aucun commentaire:

Enregistrer un commentaire