Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Test::Unit针对轨道中的发动机路径进行测试_Ruby On Rails_Unit Testing_Spree_Testunit - Fatal编程技术网

Ruby on rails 使用Test::Unit针对轨道中的发动机路径进行测试

Ruby on rails 使用Test::Unit针对轨道中的发动机路径进行测试,ruby-on-rails,unit-testing,spree,testunit,Ruby On Rails,Unit Testing,Spree,Testunit,我正在尝试针对使用的应用程序中的新功能进行一些功能测试 我遇到的问题是,当我启动我创建的测试时,应该存在的路径变量不存在,测试无法执行 假设我在本地路线中有这些路线。rb: Spree::Core::Engine.routes.draw do namespace :admin do resources :image_games end end 现在在我的测试中,我会有以下内容: require 'test_helper' module Spree modu

我正在尝试针对使用的应用程序中的新功能进行一些功能测试

我遇到的问题是,当我启动我创建的测试时,应该存在的路径变量不存在,测试无法执行

假设我在本地
路线中有这些路线。rb

Spree::Core::Engine.routes.draw do
    namespace :admin do
      resources :image_games
    end
  end
现在在我的测试中,我会有以下内容:

require 'test_helper'

module Spree
  module Admin
    class ImageGamesControllerTest < ActionController::TestCase
      test 'Should get index' do
        get admin_image_games_path
        assert_response :success
      end
    end
  end
end
需要“测试助手”
模块狂欢
模块管理员
类ImageGamesControllerTest
发生的情况是,将抛出一个
Minitest::UnexpectedError:NameError:未定义的局部变量或方法
admin\u image\u games\u path'`错误

我找到了一些建议,但所有的解决方案似乎都是针对RSpec的。我希望继续使用Test::Unit,因为我觉得它更像是我的家

所以我的问题是,如何将来自国外Rails引擎的路由加载到功能测试中

编辑:

似乎只有助手没有为我的测试工作。
使用
get'/store/admin/image\u games'
有效,但
get admin\u image\u games\u路径
无效。在正常运行应用程序时,这些帮助程序确实很难工作。

您的路径不需要任何参数吗?@AndréGuimarãesSakata我确实需要登录用户,但除此之外,没有。索引不带参数。只是为了确保,当您执行
bundle exec rake routes
时,您的路径将显示在列表中,就像您正在使用它一样?是的,admin\u image\u games GET/admin/image\u games(:格式)spree/admin/image_games#index当您更改
get
时,如下指定控制器:
get:index
,它能工作吗?你的路径不需要任何参数吗?@AndréGuimarãesSakata我需要登录用户,但除此之外没有。索引不带参数。只是为了确保,当你执行
bundle exec rake routes
时,你的路径会像你正在使用它一样出现在列表中?是的,admin_image_games GET/admin/image_games(:format)spree/admin/image_games#index当您更改
GET
指定如下控制器时:
GET:index
,是否有效?