2012-03-05 9 views
8

मैं spec/lib में lib फ़ोल्डर के अंतर्गत मॉड्यूल के लिए मेरे चश्मा डाल के तहत परीक्षण नहीं चलता है, लेकिन मैं न तो है और न ही rspecspec spec/ चलाने मिल सकता है spec/lib में कल्पना का परीक्षण किया।rspec-रेल कल्पना/lib

क्या इसके लिए कुछ भी कॉन्फ़िगर करने की आवश्यकता है? मैं रेल 3.2.0 का उपयोग कर रहा है, तो निम्न है मेरी spec_helper.rb

require 'rubygems' 
require 'spork' 
#uncomment the following line to use spork with the debugger 
#require 'spork/ext/ruby-debug' 

Spork.prefork do 
    # Loading more in this block will cause your tests to run faster. However, 
    # if you change any configuration or code from libraries loaded here, you'll 
    # need to restart spork for it take effect. 
# These lines are needed for SimpleCov to generate a complete coverage report 
    require 'simplecov' 
    SimpleCov.start 'rails' 

    # 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' 
    require 'rspec/autorun' 

    # 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| 
    config.infer_base_class_for_anonymous_controllers = false 
    config.mock_with :rspeC# use rspec's built-in mock objects 

    require 'database_cleaner' 

    config.before(:suite) do 
     DatabaseCleaner.strategy = :truncation 
     DatabaseCleaner.orm = "mongoid" 
    end 

    config.before(:each) do 
     DatabaseCleaner.clean 
    end 
    end 

end 

Spork.each_run do 
    # This code will be run each time you run your specs. 

end 

उत्तर

18

आप पैटर्न

RSpec.configure do |config| 
    config.pattern = "**/*_spec.rb" 
end 

यह RSpec कर देगा अपने कल्पना/spec_helper.rb फ़ाइल में config.pattern की स्थापना करके RSpec का उपयोग करता है समायोजित कर सकते हैं दिए गए पैटर्न से मेल खाने वाले सभी परीक्षण चलाएं। (और spec/lib में परीक्षण भी चलाएं)