Skip to content

Instantly share code, notes, and snippets.

@thomasfedb
Created December 28, 2013 20:18
Show Gist options
  • Select an option

  • Save thomasfedb/8163708 to your computer and use it in GitHub Desktop.

Select an option

Save thomasfedb/8163708 to your computer and use it in GitHub Desktop.
describe StudiesController do
sign_in
describe "#index" do
let(:studies) { FactoryGirl.create_list :study, 3 }
subject { get :index }
specify { expect_it.to be_successful }
specify { expect_it.to assign(:studies).with(studies) }
end
describe "#show" do
context "with a valid study id" do
let(:study) { FactoryGirl.create :study }
subject { get :show, id: study.id }
specify { expect_it.to be_successful }
specify { expect_it.to assign(:study).with(study) }
end
context "with an invalid study id" do
subject { get :show, id: -1 }
specify { expect_it{}.to raise_error(ActiveRecord::RecordNotFound) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment