master
 1require 'rails_helper'
 2
 3describe TutorialsController do
 4  let(:user){ create(:user) }
 5
 6  before { http_login(user) }
 7
 8  describe "#index" do
 9    let(:tutorial) { create(:tutorial) }
10
11    before :each do
12      user.tutorials << tutorial
13      get :index
14    end
15
16    it "assigns all tutorials as @tutorials" do
17      expect(assigns(:tutorials)).to match_array([tutorial])
18    end
19  end
20
21  describe "#show" do
22    let(:tutorial) { create(:tutorial) }
23
24    before :each do
25      user.tutorials << tutorial
26      get :show, params: { id: tutorial.to_param }
27    end
28
29    it "assigns the requested tutorial" do
30      expect(assigns(:tutorial)).to eql(tutorial)
31    end
32  end
33end