我试图用 rspec 进行回溯,但由于某种原因我无法让它工作。
这是测试文件:
require 'spec_helper'
describe ActivityReport do
it "should create a new instance given valid attributes" do
activity = Factory(:activity_report)
end
这是我运行的命令:
rspec --backtrace spec/models/activity_report_spec.rb
这就是我得到的:
No examples matched {:focus=>true}. Running all.
ActivityReport
should create a new instance given valid attributes (FAILED - 1)
Failures:
1) ActivityReport should create a new instance given valid attributes
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /Users/pbartels/.rvm/gems/ruby-1.9.2-p290@brothelking/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:206
Finished in 40.76 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/models/activity_report_spec.rb:16 # ActivityReport should create a new instance given valid attributes
我的.rspec:
--format nested
--color
--drb
--backtrace
还有我在 spec_helper.rb 中的 RSpec 部分:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'factory_girl'
require 'database_cleaner'
require 'active_record/fixtures'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = true
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
config.backtrace_clean_patterns = [
/\/lib\d*\/ruby\//,
/bin\//,
#/gems/,
/spec\/spec_helper\.rb/,
/lib\/rspec\/(core|expectations|matchers|mocks)/
]
end
我尝试了使用和不使用“backtrace_clean_patterns”。
有人知道这里有什么问题吗?