Я пытаюсь разработать тесты для плагина "foobar", который изменяет некоторые стандартные помощники Rails. В vendor / plugins / foobar / test / foobar_test.rb у меня есть следующее:
# create the test model
class Thing < ActiveRecord::Base
end
# create the test controller, which renders the included index template
class ThingsController < ActionController::Base
def index
@things = Thing.all
format.html { render(:file => 'index') }
end
def destroy
@thing = Thing.find(params[:id])
@thing.destroy
format.html { render(:file => 'index') }
end
end
# confirm that the test environment is working correctly
class ThingsTest < ActiveSupport::TestCase
test "model is loaded correctly" do
assert_kind_of Thing, Thing.new
end
end
# confirm that the controller and routes are working correctly
class ThingsControllerTest < ActionController::TestCase
test "should load index" do
with_routing do |set|
set.draw do
resources :things, :only => [:index, :destroy]
end
get :index
assert_response :success
end
end
end
Когда я запускаю rake, я получаю следующий результат:
test_should_load_index(ThingsControllerTest):
NameError: undefined local variable or method `_routes' for ThingsController:Class
Любая идея, что я делаю неправильно, что мешает мне получить доступ к маршруты? Я занимался этим несколько дней и просмотрел много документации, но безрезультатно. Спасибо за помощь!