According to the RSpec book, before(:all):
... gets run once and only once in its
own instance of Object, but its
instance variables get copied to each
instance in which the examples are
run. A word of caution in using this:
in general, we want to have each
example run in complete isolation from
one another. As soon as we start
sharing state across examples,
unexpected things begin to happen.
So in your examples @blah is copied before each test is run, thus values assigned to it do not carry over from one example to another.
It seems like you want to do something like this (air code):
it "gets a token" do
@token = OAuth.some_method_that_returns_a_token
end
it "uses that token to access some OAuth feature" do
result = OAuth.some_feature(@token)
result.should be_something_something
end
This smells like a test of OAuth, not of your code. You should consider stubbing out the some_feature method (more air code):
it "responds in some way when I use a valid token" do
@token = mock('token')
OAuth.should_receive(:some_feature).with(@token).and_return("success")
result = my_code_which_uses_ouath(@token)
result.should == "success"
end