0

I have 2 controllers with the same name but in different folders.

The first is in "controllers" the other one is in the "controllers/api/v1".

The first is running smoothly but the latter just don't run.

Both test files are on functionals test folder.

Running test file:

# encoding: utf-8
require 'test_helper'
require_relative '../../app/controllers/post_controller'

class PostControllerTest < ActionController::TestCase
...

Not running test:

# encoding: utf-8
require 'test_helper'
require_relative '../../app/controllers/api/v1/post_controller'

class ApiPostControllerTest < ActionController::TestCase
...

any idea why? thanx

----- note -----

it wasn't running the tests because it missed the test reference in the file name.

and worked just fine with vimsha answer.

Miguel de Sousa
  • 324
  • 2
  • 15

1 Answers1

1

ActionController::TestCase will automatically infer the controller under test from the test class name.

I think your test should be like below

class Api::V1::PostControllerTest < ActionController::TestCase
end

or

class ApiPostControllerTest < ActionController::TestCase
 tests Api::V1::PostController
end
usha
  • 28,973
  • 5
  • 72
  • 93