Ruby on rails Rails 4集成测试-失败(事件断言为真)
好吧,昨天我问了一个有点尴尬的问题,但我们又被卡住了 我们已经修复了所有控制器测试,并开始编写集成测试。我们在所有集成测试中都遇到了错误,甚至著名的assert=true: 站点布局测试.rbRuby on rails Rails 4集成测试-失败(事件断言为真),ruby-on-rails,ruby-on-rails-4,testing,integration-testing,minitest,Ruby On Rails,Ruby On Rails 4,Testing,Integration Testing,Minitest,好吧,昨天我问了一个有点尴尬的问题,但我们又被卡住了 我们已经修复了所有控制器测试,并开始编写集成测试。我们在所有集成测试中都遇到了错误,甚至著名的assert=true: 站点布局测试.rb require 'test_helper' class SiteLayoutTest < ActionDispatch::IntegrationTest test "the truth" do assert true end #commenting out our real
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "the truth" do
assert true
end
#commenting out our real tests for debugging
=begin
test "top navigation bar links" do
get 'beta/index'
assert_template 'beta/index'
assert_select "a[href=?]", home_path
assert_select "a[href=?]", how_it_works_path
to do add map, community, sign up, login paths
to do: add paths to links on dropdown if user is logged in
end
=end
end
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
include Devise::TestHelpers
# Add more helper methods to be used by all tests here...
#
def setup_variables
@base_title = "TripHappy"
end
end
测试助手.rb
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "the truth" do
assert true
end
#commenting out our real tests for debugging
=begin
test "top navigation bar links" do
get 'beta/index'
assert_template 'beta/index'
assert_select "a[href=?]", home_path
assert_select "a[href=?]", how_it_works_path
to do add map, community, sign up, login paths
to do: add paths to links on dropdown if user is logged in
end
=end
end
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
include Devise::TestHelpers
# Add more helper methods to be used by all tests here...
#
def setup_variables
@base_title = "TripHappy"
end
end
不幸的是,该错误消息对于错误发生的位置几乎没有任何线索。我试着阅读小测验,但不知道该去哪里看,我完全迷路了
提前谢谢你
作为参考,我们正在跟踪,这意味着我们正在使用警卫和小型记者。我们也有一个登录系统,通过设计,如果这影响到任何东西
解决方案:
这是一个设计上的问题。我在
class-ActiveSupport::TestCase
中加入了include designe::TestHelpers
,而不是class-ActionController::TestCase
,这是designe的问题。我在ActiveSupport::TestCase类中包含Desive::TestHelpers,而不是ActionController::TestCase类我非常不喜欢一连串的问题,尤其是在几乎相同的主题上。在没有人给你答案的情况下,他们的进步很小。请考虑把你的答案作为答案,接受它们,而不是把它们编辑成问题。