Question: Been fighting this one all morning. Here are the links I have been pointed to and I am still having no luck:

<http://www.asp.net/visual-studio/overview/2013/release-notes-(release-candidate)>

<https://stackoverflow.com/a/18426574/1118218> (I did everything the accepted answer suggests)

<https://stackoverflow.com/a/18419011/1118218> (same question as above, but the solution here did not work either, does not resolve the classes)

I installed the ASPNET web tools refresh. Restarted visual studio. Everything seems to build correctly except for the AccountController. It cannot find AuthenticationIdentityManager(and IdentityStore). 

```
[Authorize]
public class AccountController : Controller
{
    public AccountController()
    {
        IdentityManager = new AuthenticationIdentityManager(new IdentityStore());
    }

    public AccountController(AuthenticationIdentityManager manager)
    {
        IdentityManager = manager;
    }

    public AuthenticationIdentityManager IdentityManager { get; private set; }
}

```

Any idea how to get this to work? All the nuget packages related to ASP.NET Identity, Owin, EF, and MVC are updated to the latest pre-release version.

Answer: 
I have a few techniques that I use to deal with this stuff.

The first is to use plain ruby methods over `let`. This is just my preference, I think it adds clarity to tests. Check this for more about that: <http://robots.thoughtbot.com/lets-not>

And then, I have a helper method for auth stuff. I'm using Devise for authentication, so my implementation will be different than yours, but this sets the HTTP\_AUTHORIZATION header for every request made to my app after calling the helper method in the tests.

```
module Requests
  module AuthenticationHelpers
    def basic_http_auth(user)
      credentials = ActionController::HttpAuthentication::Basic.encode_credentials(user.email,user.password)
      Rack::MockRequest::DEFAULT_ENV['HTTP_AUTHORIZATION'] = credentials
    end
  end
end

```

And then in the actual test, I'll do something like this:

```
describe "GET /api/v1/messages" do
  it 'returns an array of messages' do
    get '/api/v1/messages'
    basic_http_auth(FactoryGirl.create(:user))

    expect(response).to eq(200)
  end
end

```

So, if you're going to be using this across a lot of the API tests, move it into a support helper. And, if you're calling something multiple times in the same file, write a method (or put it in a `let` call) to DRY your your tests.
The easiest thing to do to avoid the duplication would be to define the token in the highest level describe so that it's available for all the examples in your spec.

In addition, to avoid any performance issue for the examples that don't depend on it, you can use `let` rather than `before` to define the token since `let` is lazily evaluated.

What you'd have then, is the following:

```
let(:access_token) do
  user = FactoryGirl.create(:user)
  authentication = FactoryGirl.create(:authentication, user: user)
  application = Doorkeeper::Application.create!(:name => "MyApp", :redirect_uri => "http://app.com")
  Doorkeeper::AccessToken.create!(:application_id => application.id, :resource_owner_id => authentication.identity.id)
  end

```

You'd need to also change your references to this token from `@access_token` to `access_token`, since you're defining a method and not an instance variable.