2012-03-05 29 views
8

tôi đặt thông số kỹ thuật của tôi cho module dưới lib thư mục vào spec/lib, nhưng tôi chạy không rspec cũng không spec spec/ có thể nhận được spec trong spec/lib đi xét nghiệm.rspec-ray không chạy thử nghiệm dưới đặc tả/lib

Có bất kỳ điều gì cần được định cấu hình cho điều này không? Tôi đang sử dụng đường ray 3.2.0, sau đây là của tôi 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 

Trả lời

18

Bạn có thể điều chỉnh các mô hình RSpec sử dụng bằng cách thiết lập config.pattern trong file spec/spec_helper.rb bạn

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

Điều này sẽ làm RSpec chạy tất cả các thử nghiệm được khớp với mẫu đã cho. (Và cũng chạy các bài kiểm tra trong spec/lib)

Các vấn đề liên quan