【发布时间】:2016-04-28 07:20:02
【问题描述】:
这是终端中的问题:
treehouse:~/projects/odot (master *) $ bin/rails generate model todo_item todo_list:references content:string -p
/home/treehouse/projects/odot/config/application.rb:23:in `<class:Application>': undefined method `configure' for RSpec:Module (NoMethodError)
from /home/treehouse/projects/odot/config/application.rb:10:in `<module:Odot>'
from /home/treehouse/projects/odot/config/application.rb:9:in `<top (required)>'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.0.1/lib/rails/commands.rb:43:in `require'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.0.1/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
这里是 odot/config/application.rb 文件:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module Odot
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
RSpec.configure do |c|
c.expose_current_running_example_as :example
end
RSpec.configure do |c|
c.expose_current_running_example_as :example
end
end
end
这里是 bin/rails 文件:
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
我不知道如何访问 .rbenv/.... 文件。
我似乎无法解决问题所在。这些是启动我的 rails 待办事项列表应用程序时文件夹中的默认文件。我在三个不同的文件中做了几个 rspec 测试,在完成最后一个文件后,这不会让我继续执行任何其他任务。
这在运行 bin/rake 时会一直持续:
rake aborted!
NoMethodError: undefined method `configure' for RSpec:Module
/home/treehouse/projects/odot/config/application.rb:23:in `<class:Application>'
/home/treehouse/projects/odot/config/application.rb:10:in `<module:Odot>'
/home/treehouse/projects/odot/config/application.rb:9:in `<top (required)>'
/home/treehouse/projects/odot/Rakefile:4:in `require'
/home/treehouse/projects/odot/Rakefile:4:in `<top (required)>'
那么这里是 rakefile 文件:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Odot::Application.load_tasks
我不知道发生了什么。运气好的话?干杯。
【问题讨论】:
-
如果它以前可以正常工作,那么您的 rbenv 可能已更改。
-
你可能是对的。我在创建规范测试时遇到了一些错误,如果可以解决问题,我会点击捆绑更新。结果我忘了在我的一个 rspec 测试中包含一个“do”。我不认为会是这样。我不确定我是否有不同版本的 rake。我不记得也无法弄清楚可能发生了什么变化。
标签: ruby-on-rails ruby ruby-on-rails-4 rspec