Spec-Zone.ru › Ruby on Rails 4.1

модуль ActiveSupport::Testing::ConstantLookup

Разрешает константу из имени теста minitest.

Приведенный ниже тест в стиле spec:

describe WidgetsController, :index do
  describe "authenticated user" do
    describe "returns widgets" do
      it "has a controller that exists" do
        assert_kind_of WidgetsController, @controller
      end
    end
  end
end

Тест будет иметь следующее имя:

"WidgetsController::index::authenticated user::returns widgets"

Константа WidgetsController может быть разрешена по имени. Следующий код разрешит константу:

controller = determine_constant_from_test_name(name) do |constant|
  Class === constant && constant < ::ActionController::Metal
end

© 2004–2016 David Heinemeier Hansson
Licensed under the MIT License.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API