2

これは初めてです。私は BDD を試してテストしています。チュートリアルを見て試しています。私の問題は、ガード ファイルで定義されているように、ガードがスペック フォルダーを探していることがわかりましたが、スペック フォルダーがありません。代わりにテストフォルダーがあります。

私が走るとき

guard

spec フォルダを読み込もうとしますが、spec フォルダがありません。spec フォルダの代わりに test フォルダを探すようにガード ファイルを編集してもよろしいですか?

rspec install を行うべきですか?

rails g rspec install

ジェネレータ rspec が見つかりませんでした。

私の宝石ファイル

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'

私のガードファイル

# 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

ジェネレーター rspec:install が見つかりませんでしたの回答に従ってください。 gem ファイルに rspec-rails を追加し、バンドル インストールを実行すると、rspec ジェネレーターが機能し、spec フォルダーが生成されました。

ただし、テストフォルダーには、フィクスチャ、受け入れ、機能などのフォルダーはありません!!

4

1 に答える 1

2

公式ドキュメント (https://github.com/rspec/rspec-rails#install) によると、以下を実行する必要があると思います:

# not: rails g rspec install
rails generate rspec:install   

「spec」フォルダーと「spec/spec_helper.rb」ファイル、およびその他の関連するものを生成します。

于 2013-01-03T12:38:03.813 に答える