Check the answer from Pavel Druzyak for a different question the answer from Pavel Druzyak for a different question. It answers your question as well.
Your code can be refactored to this;
describe ProjectsController do
let(:project) { Project.create! }
describe "GET index" do
before(:each) { get :index }
it { should respond_with(:success) }
it { should assign_to(:projects).with([project]) }
end
describe "GET show" do
before(:each) { get :show, {:id => @project.to_param} }
it { should respond_with(:success) }
it { should assign_to(:projects).with(project) }
end
end
Check the answer from Pavel Druzyak for a different question. It answers your question as well.
Your code can be refactored to this;
describe ProjectsController do
let(:project) { Project.create! }
describe "GET index" do
before(:each) { get :index }
it { should respond_with(:success) }
it { should assign_to(:projects).with([project]) }
end
describe "GET show" do
before(:each) { get :show, {:id => @project.to_param} }
it { should respond_with(:success) }
it { should assign_to(:projects).with(project) }
end
end
Check the answer from Pavel Druzyak for a different question. It answers your question as well.
Your code can be refactored to this;
describe ProjectsController do
let(:project) { Project.create! }
describe "GET index" do
before(:each) { get :index }
it { should respond_with(:success) }
it { should assign_to(:projects).with([project]) }
end
describe "GET show" do
before(:each) { get :show, {:id => @project.to_param} }
it { should respond_with(:success) }
it { should assign_to(:projects).with(project) }
end
end
Check the answer from Pavel Druzyak for a different question. It answers your question as well.
Your code can be refactored to this;
describe ProjectsController do
let(:project) { Project.create! }
describe "GET index" do
before(:each) { get :index }
it { should respond_with(:success) }
it { should assign_to(:projects).with([project]) }
end
describe "GET show" do
before(:each) { get :show, {:id => @project.to_param} }
it { should respond_with(:success) }
it { should assign_to(:projects).with(project) }
end
end