开发者

Rspec2, Rails3, can't run rspec spec

I just installed Rspec2 in my Rails3 (3.0.3) project. When I run rspec spec from rails root I get:

No examples were matched. Perhaps {:if=>#<Proc:0x00000100933388@/Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:50 (lambda)>, :unless=>#<Proc:0x00000100933360@/Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:51 (lambda)>} is excluding everything?


Finished in 0.00004 seconds
0 examples, 0 failures

I can run rspec name_of_spec_test.rb directly and that seems to work, but not the generic "rspec spec" command. Also, if I add require 'spec_helper.rb' to the top of my name_of_spec_test.rb file I get:

/Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:644:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:644:in `open'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:644:in `block in connect'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:644:in `connect'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:626:in `start'
    from /Users/ivan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/http.rb:1168:in `request'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rsolr-1.0.0/lib/rsolr/connection.rb:15:in `execute'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rsolr-1.0.0/lib/rsolr/client.rb:151:in `execute'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rsolr-1.0.0/lib/rsolr/client.rb:146:in `send_and_receive'
    from (eval):2:in `post'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rsolr-1.0.0/lib/rsolr/client.rb:55:in `update'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rsolr-1.0.0/lib/rsolr/client.rb:75:in `add'
    from /Users/ivan/Documents/Projects/catalog_service.git/app/models/search/cake_to_solr.rb:39:in `<class:Playlist>'
    from /Users/ivan/Documents/Projects/catalog_service.git/app/models/search/cake_to_solr.rb:11:in `<top (required)>'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:346:in `require_or_load'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:300:in `depend_on'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:216:in `require_dependency'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/engine.rb:137:in `each'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/engine.rb:137:in `block in eager_load!'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/engine.rb:135:in `each'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/engine.rb:135:in `eager_load!'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:108:in `eager_load!'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
    from /Us开发者_开发百科ers/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
    from /Users/ivan/Documents/Projects/catalog_service.git/config/environment.rb:5:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/ivan/Documents/Projects/catalog_service.git/spec/spec_helper.rb:3:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/ivan/Documents/Projects/catalog_service.git/spec/models/search_test.rb:1:in `<top (required)>'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `block in load_spec_files'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `map'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in `load_spec_files'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in `run'
    from /Users/ivan/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in `block in autorun'

I am using RVM to manage my rails environment.

I don't know if this is relevant, but when I initially ran script/rails generate rspec:install it only installed .rspec, created the spec dir and spec/spec_helper.rb.

Also, I'm not using rails migrations because we have a variety of databases that we connect to. So, when I create a model, and I test it, I manually create a spec/models directory and put my *_test.rb rspec file in it.

Any ideas about what I'm missing here, would be greatly appreciated!

Here's my Gemfile, spec_helper.rb file, and test.rb files.

Gemfile:

source 'http://rubygems.org'

gem 'rails'
gem 'mysql2', '0.2.6'
gem 'legacy_data'
gem 'htmlentities'
gem 'httparty'
gem 'net-ssh'
gem 'net-sftp'
gem 'rsolr'
gem 'activerecord-import'
gem 'ar-extensions'


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

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19'

# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Gems for RSpec
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
   gem 'rspec-rails'
   gem 'webrat'
   gem 'rspec'
end
gem 'autotest'

spec_helper.rb:

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  # config.fixture_path = "#{::Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = false
end

test.rb:

CatalogService::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # The test environment is used exclusively to run your application's
  # test suite.  You never need to work with it otherwise.  Remember that
  # your test database is "scratch space" for the test suite and is wiped
  # and recreated between test runs.  Don't rely on the data there!
  config.cache_classes = true

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Raise exceptions instead of rendering exception templates
  config.action_dispatch.show_exceptions = false

  # Disable request forgery protection in test environment
  config.action_controller.allow_forgery_protection    = false

  # Tell Action Mailer not to deliver emails to the real world.
  # The :test delivery method accumulates sent emails in the
  # ActionMailer::Base.deliveries array.
  config.action_mailer.delivery_method = :test

  # Use SQL instead of Active Record's schema dumper when creating the test database.
  # This is necessary if your schema can't be completely dumped by the schema dumper,
  # like if you have constraints or database-specific column types
  # config.active_record.schema_format = :sql

  # Print deprecation notices to the stderr
  config.active_support.deprecation = :stderr

end

Thanks for any thoughts in advance!


Looks like you were correct by adding spec_helper, and maybe put rsolr in a group => [:development, :production], because it looks like the test environment is loading Solr and failing for some reason?


You might check your default pattern. Looks like you said your files were named "spec/models/XXXX_test.rb" and rspec looks for the "_spec.rb" ending by default.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜