GSto
GSto

Reputation: 42350

How to get RSpec to test controllers in subdirectories?

I have some controllers that are in subdomains of the controllers folder.

for example, i have a controller in app/controllers/api/v1/offers_controller.rb that looks like this:

class Api::V1::OffersController < ApplicationController
  respond_to :json

  def index
   ...some code here
  end
end

I tried putting a controller in spec/controllers/api/v1/offers_controller.rb that looks like this:

require 'spec_helper'

descripe Api::V1::OffersController do
  describe "GET 'index'" do
    it "returns http success" do
      get 'index'
      response.should be_success
    end
  end
end

however, when I run rspec spec, this test does not get run at all. I also tried putting it in the spec/controllers directory, named api_v1_offers_controller.rb, and the test is still not run.

How can I write RSpec tests for these types of controllers?

Upvotes: 3

Views: 1202

Answers (1)

GSto
GSto

Reputation: 42350

It actually seems it was a mistake it how I named the file. it seems all RSpec tests need to end it _spec

Upvotes: 4

Related Questions