控制器测试错误,预期为<“ categories / new”>,但使用<[]>进行渲染

时间:2018-06-22 08:17:02

标签: ruby-on-rails integration-testing

我才刚刚开始学习Ruby on Rails。本章是关于测试的,而在我进行测试时却是这样?我需要做什么?而且我应该了解什么以了解在轨道上测试红宝石?

这是我的Controller测试代码。

require 'test_helper'

class CategoriesControllerTest < ActionDispatch::IntegrationTest
  def setup
    @category = Category.create(name: "sports")
    @user = User.create(username: "supyaeaung", email: "supyaeaung27714@gmail.com", password: "hlaing", admin: true)
  end

test "should get new" do
    sign_in_as(@user, "password")
    get new_category_path
    assert_response :success
  end

这是错误。我该怎么办?

Error:
CategoriesControllerTest#test_should_get_new:
NoMethodError: undefined method `confirm' for #<User:0x00007fd0781e0370>
    test/controllers/categories_controller_test.rb:15:in `block in <class:CategoriesControllerTest>'

1 个答案:

答案 0 :(得分:0)

第15行的控制器尝试调用SQL> with test (projectid, status) as 2 (select 1, 'new' from dual union -- should be returned 3 select 2, 'new' from dual union 4 select 2, 'closed' from dual union 5 select 3, 'closed' from dual union 6 select 4, 'new' from dual -- should be returned 7 ) 8 select projectid 9 from test 10 group by projectid 11 having min(status) = max(status) 12 and min(status) = 'new'; PROJECTID ---------- 1 4 SQL> 对象上的方法confirm

User

您可能没有实现它。