Ruby on rails 3 设计助手方法,确认!无法在出厂设置中使用/找到
全部,Ruby on rails 3 设计助手方法,确认!无法在出厂设置中使用/找到,ruby-on-rails-3,devise,factory-bot,Ruby On Rails 3,Devise,Factory Bot,全部, 语言:RubyonRails 版本:rails 3 问题中的宝石:设计和制造女孩轨道 我参考并尝试使用factory girl为我的控制器规格设置管理员和常规设计用户。我正在DeVICE中使用可确认模块 在spec/support/controller_macros.rb中,我调用confirm!从工厂获取用户对象后。 代码/评论说 > "user.confirm! # or set a confirmed_at inside the factory. Only > necessar
- 语言:RubyonRails
- 版本:rails 3
- 问题中的宝石:设计和制造女孩轨道
失败/错误:无法从回溯中找到匹配行
命名错误:
未定义的方法“确认!”为了#
#./spec/support/controller\u macros.rb:8:in'login\u user'
我的spec/spec_helper.rb如下所示
-----------spec/spec_helper.rb-开始----------------------------
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'webrat'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
end
环境[“RAILS_ENV”]| |=“测试”
需要文件。展开\u路径(“../../config/environment”,\u文件\u)
需要“rspec/rails”
需要“网络鼠”
#需要支持带有自定义匹配器和宏等的ruby文件,
#在spec/support/及其子目录中。
Dir[Rails.root.join(“spec/support/***.rb”)]。每个{f |都需要f}
RSpec.configure do | config|
config.mock_with:rspec
config.include designe::TestHelpers,:type=>:controller
config.extend ControllerMacros,:type=>:controller
#如果不使用ActiveRecord或ActiveRecord设备,请删除此行
config.fixture_path=“#{::Rails.root}/spec/fixtures”
#如果您不使用ActiveRecord,或者您不希望运行每个
#在事务中的示例中,删除以下行或赋值为false
#而不是真的。
config.use\u transactional\u fixtures=true
结束
-----------spec/spec_helper.rb-结束----------------------------
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'webrat'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
end
可能是什么问题导致确认!找不到/不工作
谢谢:)确认!如果您正在使用:confirmable designe模块,那么这是必需的 在你的user.rb(设计模型)中,在你的设计选项中放置:confirmable,或者如果你不想使用此模块(此模块向用户发送确认电子邮件)。删除确认!从控制器_macros.rb