ruby on rails - ArgumentError in mongoid-rspec -
when bundle exec rspec spec/controllers got:
/var/lib/gems/1.9.1/gems/rspec-core-3.0.4/lib/rspec/core/hooks.rb:521:in `extract_scope_from': must explicitly give scope (example, context, suite) or scope alias (each, all) when using symbols metadata hook. (argumenterror)
my gemfile:
gem 'rails', '4.1.4' gem 'mongoid', '~> 4', github: 'mongoid/mongoid' gem 'sass-rails', '~> 4.0.3' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem 'spring', group: :development group :development, :test gem 'rspec-rails', '~> 3.0.2' end group :test gem 'database_cleaner' gem 'factory_girl_rails' gem 'mongoid-rspec' end
my spec_helper.rb:
# spec_helper.rb env["rails_env"] ||= 'test' require file.expand_path("../../config/environment", __file__) require 'rspec/rails' # requires supporting ruby files custom matchers , macros, etc, # in spec/support/ , subdirectories. dir[rails.root.join("spec/support/**/*.rb")].each {|f| require f} rspec.configure |config| config.mock_with :rspec config.before :each mongoid.purge! end require 'database_cleaner' config.before(:siute) databasecleaner.strategy = :truncation databasecleaner.orm = "mongoid" end config.before(:each) databasecleaner.clean end end
my rails_helper.rb
# file copied spec/ when run 'rails generate rspec:install' env["rails_env"] ||= 'test' require 'spec_helper' require file.expand_path("../../config/environment", __file__) require 'rspec/rails' dir[rails.root.join("spec/support/**/*.rb")].each { |f| require f } rspec.configure |config| # argumenterror whether following commented out or not config.infer_spec_type_from_file_location! end
my spec/controllers/typer_controller_spec.rb (only file in controllers folder)
require "rails_helper" rspec.describe typercontroller, type:controller describe "get #index" "initializes properly" :index # nothing test yet end end end
you have syntax error here
rspec.describe typercontroller, type:controller
change to
rspec.describe typercontroller, type: :controller
Comments
Post a Comment