module ConstantLookup

Ruby on Rails 4.0.13

Since v4.0.13

Available in: v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Resolves a constant from a minitest spec name.

Given the following spec-style test:

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

The test will have the following name:

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

The constant WidgetsController can be resolved from the name. The following code will resolve the constant:

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

Extends

Used by

Included by (3)

Methods (inherited)

From ActiveSupport::Concern (2)

Type at least 2 characters to search.

↑↓ navigate · open · esc close