我喜歡使用RSpec的include配置方法來包含僅用於命名空間的 模塊,這樣我就不必爲它們的 內部類使用完全限定名稱,並且模塊。這與Ruby 1.9.2中的RSpec 2.11.0一起工作良好。但現在在Ruby 1.9.3上的 已不再適用。我怎樣才能讓它再次運作?在Ruby 1.9.3中通過RSpec配置包含名稱空間模塊
下面的例子foobar_spec.rb:
module Foo
class Bar
end
end
RSpec.configure do |config|
config.include Foo
end
describe Foo::Bar do
it "should work" do
Bar.new
end
end
如果您通過以下命令調用它:
rspec foobar_spec.rb
它將Ruby的工作1.9.2就好了。但它會在Ruby 1.9.3中引發以下錯誤:
Failure/Error: Bar.new
NameError:
uninitialized constant Bar
似乎並不像ruby-lang.org上的人真的確定這個補丁是否是一個好主意。所以我不確定「故意」的事情。 – aef