-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
i wonder if it's possible to run the request only once and then have multiple expectations on it structured in multiple tests.
let's pretend one request creates 10 different things and we need 20 expectations here (stupid example, i know) and we don't want to have one single test but structure it more.
the alternative would be to have a request in every test but that slows down the pipeline a lot.
any possibility?
context "runs the request just once" do
before(:all) do
@document = create :document
@request = get :show, params: {id: @document.id}
end
it "has expectation" do
end
it "has more expectation" do
end
it "has other expectations" do
end
it "checks random stuff" do
end
end
if i run this, i get
@routes is nil: make sure you set it in your test's setup method.
one working way is, but is there another?
context "runs the request just once" do
request = nil
before(:each) do
request ||= begin
puts "run me only once buddy"
@document = create :document
get :show, params: {id: @document.id}
end
end
it "has expectation" do
expect(request).to have_http_status(302)
end
it "has more expectation" do
expect(request).to have_http_status(302)
end
it "has other expectations" do
expect(request).to have_http_status(302)
end
it "checks random stuff" do
expect(request).to have_http_status(302)
end
end
Metadata
Metadata
Assignees
Labels
No labels