首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rails guard正在查找spec文件夹,但没有spec文件夹

rails guard正在查找spec文件夹,但没有spec文件夹
EN

Stack Overflow用户
提问于 2013-01-03 20:06:19
回答 1查看 1.4K关注 0票数 2

这是我第一次尝试BDD和testing,我通过查看教程来尝试,我的问题是我发现guard正在寻找它的guard文件中定义的spec文件夹,但没有spec文件夹,我有测试文件夹。

当我跑的时候

guard

它尝试加载等级库文件夹,但没有等级库文件夹。是否可以编辑防护文件以查找test文件夹而不是spec文件夹?

我应该安装rspec吗?

rails g rspec install

找不到生成器rspec。

我的gem文件

代码语言:javascript
复制
source 'https://rubygems.org'

gem 'rails',     path: '/home/phanindra/rails'
gem 'journey', git: 'https://github.com/rails/journey.git'
gem 'arel',      git: 'https://github.com/rails/arel'
gem 'activerecord-deprecated_finders', git: 'https://github.com/rails/activerecord-deprecated_finders'

gem 'sqlite3'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sprockets-rails', git: 'https://github.com/rails/sprockets-rails'
  gem 'sass-rails',   git: 'https://github.com/rails/sass-rails'
  gem 'coffee-rails', git: 'https://github.com/rails/coffee-rails'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', platforms: :ruby

  gem 'uglifier', '>= 1.0.3'
end
gem 'rb-inotify', '~> 0.8.8'
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

group :test, :development do
  gem 'cucumber-rails', :require => false
  gem 'database_cleaner'
  gem 'rspec'
  gem 'spork'
  gem 'guard'
  gem 'guard-rspec'
  gem 'launchy'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano', group: :development

# To use debugger
# gem 'debugger'

我的防护文件

代码语言:javascript
复制
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec' do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }

  # Capybara features specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/features/#{m[1]}_spec.rb" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

按照Could not find generator rspec:install.上的回答,我已经将rspec-rails添加到了我的gem文件中,并进行了捆绑安装,然后rspec生成器工作并生成了spec文件夹。

但是它在测试文件夹中没有任何诸如fixtures或acceptance或functional等文件夹!!

EN

回答 1

Stack Overflow用户

发布于 2013-01-03 20:38:04

根据官方文档(https://github.com/rspec/rspec-rails#install),我认为您应该运行:

代码语言:javascript
复制
# not: rails g rspec install
rails generate rspec:install   

生成"spec“文件夹和"spec/spec_helper.rb”文件以及其他相关内容。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14138628

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档