Hello everybody,
I'm a long time rspec user, mostly within Rails, but now using rspec for
the first time for API integration tests. I'd appreciate your help on this.
My code looks like this:
describe "Request" do
let(:path) { path }
let(:headers) { headers }
let(:response) { do_request(path, headers) }
describe "success" do
it "should have an ETag header" do
response.headers[:etag].should(be_present) unless response.code == 204
end
it "should have a Cache-Control header" do
response.headers[:cache_control].should be_present
end
# MORE EXAMPLES
it_behaves_like "any GET request" # should create the response again,
with invalid headers
end
end
Is there a way to cache response between some examples? The code is
actually more complicated and creating several requests, for example with
different Content Type headers, so I don't just want to execute the request
once in before(:all). The goal would be to speed up some of the examples
that are in the "success" block and could reuse the response from the
outter group. The code now is very slow, as the whole resource environment
needs to be set up and teared down for each single example.
I tried looking into using a before(:all) block, but it's telling me that I
should not use let within this block.
Thanks,
Sascha
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/4f081a08-c8d2-4846-a517-39406df681cc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.