Hello everybody.

I'm confused with the behaviour of *before* hooks and I have several 
questions:

*1. *The term *:suite *is supposed to run the hook once before the first 
spec runs. I need to set the host for the bunch of my request tests:
RSpec.configure do |config|
    config.before(:suite) do
         host! "foo.example.com"
    end
end 
This raises undefined method host! error, however this works *ok* if I 
change *:suite* with *:all* Why? What is the correct way to once set the 
host for all the tests?

*2.* Resources, created in *before(:each)* block, are deleted automatically 
after tests:
RSpec.describe "Projects", :type => :request do
    describe "GET /projects" do
        context "common case" do
            before do
                @project = create(:project) # factory
                get projects_path, nil, {Accept: 'application/json'}   
            end

            it "should return status ok" do
            ....
            ....
        end
    end
end
However, if I change *before* with *before(:all) *(no need to create the 
resource again / make request again in my case), record stays in database. 
Why?

gem versions:
rspec (2.99.0)
rspec-rails (3.0.2)
rspec-core (3.0.4, 2.99.2)
rails (4.1.1)


-- 
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/6a03880f-f3aa-469c-b8af-e053bb1b2b40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to