找不到生成器 rspec_model 问题 [英] Could not find generator rspec_model issue

查看:26
本文介绍了找不到生成器 rspec_model 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的模型用户创建一个 rspec,但每次运行时:

I am trying to create an rspec for my model User but every time I run:

rails g rspec_model User

我得到无法找到生成器 rspec_model.

I get Could not find generator rspec_model.

我检查了另一个 stackoverflow 线程,它说确保我有 gem 'rspec-rails',我有.我究竟做错了什么?这是我的 gemfile:

I checked another stackoverflow thread and it said make sure I have the gem 'rspec-rails' and I do. What am I doing wrong? Here's my gemfile:

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
  gem 'rspec', '2.0.1'
  gem 'webrat', '0.7.1'
end

group :development do
  gem 'rspec-rails', '2.0.1'
  gem 'sqlite3'
end

推荐答案

请使用(一次):

rails generate rspec:install

它将创建各种文件和规范目录.例如,您将需要创建模型目录并开始在该目录中创建规范.

It will create the various files and the spec directory. You will then need to, for example, create the models directory and start creating specs in that directory.

一旦你为 rspec 配置了你的应用程序,脚本/rails 生成 ModelName 也会创建我相信的 rspec 骨架文件.

Once you configure your application for rspec, script/rails generate ModelName will also create the rspec skeleton files I believe.

这篇关于找不到生成器 rspec_model 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆