test/components/capabilities/resourceful_test.rb in express_templates-0.11.5 vs test/components/capabilities/resourceful_test.rb in express_templates-0.11.6
- old
+ new
@@ -1,8 +1,8 @@
require 'test_helper'
-module AdminModule
+module AdminModules
module Engine
end
class SmartThing < ExpressTemplates::Components::Configurable
include ExpressTemplates::Components::Capabilities::Resourceful
@@ -28,46 +28,46 @@
module ExpressTemplates
class ResourcefulTest < ActiveSupport::TestCase
test 'infers namespace and path prefix within an engine and scope' do
- smart_thing = AdminModule::SmartThing.new('admin_module/admin/something/index')
- assert_equal 'admin_module', smart_thing.namespace
+ smart_thing = AdminModules::SmartThing.new('admin_modules/admin/something/index')
+ assert_equal 'admin_modules', smart_thing.namespace
assert_equal 'admin', smart_thing.path_prefix
end
test 'infers a namespace and no prefix within an engine' do
# if defined? ExpressFoo::Engine
- smart_thing = AdminModule::SmartThing.new('admin_module/something/index')
- assert_equal 'admin_module', smart_thing.namespace
+ smart_thing = AdminModules::SmartThing.new('admin_modules/something/index')
+ assert_equal 'admin_modules', smart_thing.namespace
assert_equal nil, smart_thing.path_prefix
end
test 'no namespace, infers prefix within a scope within an app' do
# else of case above
- smart_thing = AdminModule::SmartThing.new('admin/something/index')
+ smart_thing = AdminModules::SmartThing.new('admin/something/index')
assert_equal nil, smart_thing.namespace
assert_equal 'admin', smart_thing.path_prefix
end
test 'no namespace, no prefix within an app' do
- smart_thing = AdminModule::SmartThing.new('somethings/index')
+ smart_thing = AdminModules::SmartThing.new('somethings/index')
assert_equal nil, smart_thing.namespace
assert_equal nil, smart_thing.path_prefix
end
test "#resource_class returns resource_class option if specified" do
- assert_equal FooBar, AdminModule::SmartThing.new('somethings/index', resource_class: 'FooBar').resource_class
- assert_equal Something, AdminModule::SmartThing.new('somethings/index', id: :something).resource_class
+ assert_equal FooBar, AdminModules::SmartThing.new('somethings/index', resource_class: 'FooBar').resource_class
+ assert_equal Something, AdminModules::SmartThing.new('somethings/index', id: :something).resource_class
end
test "#resource_class raises a helpful error message when the class does not exist" do
expected_error_message = [
"Could not find the class `FooBar`.",
"You may need to define the option `:resource_class`.",
].join(" ")
- smart_thing = AdminModule::SmartThing.
+ smart_thing = AdminModules::SmartThing.
new('somethings/index', resource_class: 'NonExistentBar')
assert_raises(ArgumentError, expected_error_message) do
smart_thing.resource_class
end