我无法弄清楚如何让没有rails的rspec工作
root
--lib/
----information.rb
--spec/
----spec_helper.rb
----information_spec.rb
.rspec
.ruby-version
Gemfile
Gemfile.lock
spec_helper.rb(在rspec --init
和我尝试不同的事情之后)
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
Dir["../lib/**/*.rb"].each {|file| require file }
RSpec.configure do |config|
# The settings below are suggest...
...
end
information_spec.rb
require_relative 'spec_helper'
RSpec.describe Information do
it 'describes stuff' do
expect(true).to be(true)
end
end
information.rb
class Information
end
控制台输出
~ rspec
~/spec/information_spec.rb:3:in `<top (required)>': uninitialized constant Information (NameError)
答案 0 :(得分:0)
在规范的开头:
require 'information'