Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

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
Source Link
Can Hanhan
  • 438
  • 2
  • 6

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
lang-rb

AltStyle によって変換されたページ (->オリジナル) /