Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I skip middleware in my Rspec request specs?

I'm writing some pretty standard Rspec request specs for a Rails app.

describe "show" do
  it "should respond successfully when given an id that exists" do
    @badger = FactoryGirl.create(:badger)
    get "/badgers/#{@badger.id}"
    response.should be_ok
  end
end

However, we've just added a middleware component for a single sign-on system, so the response comes back as a redirect - "please sign in."

For the purposes of these tests, how can I leave the middleware out of the chain? (It has its own tests elsewhere.)

like image 664
Nathan Long Avatar asked Oct 15 '25 17:10

Nathan Long


1 Answers

In your config/environments/test.rb you can delete this middleware:

config.middleware.delete YourMiddleware::Goes::Here
like image 122
Ryan Bigg Avatar answered Oct 18 '25 06:10

Ryan Bigg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!