我有一个简单的测试,但是describe
关键字在冰糕测试中不起作用。
我在这些方法上收到的错误:
Method `describe` does not exist on `T.class_of(<root>)`7003
RSpec.describe(Model) do
describe 'my test' do
before(:each) do # .before error
user = FactoryBot.create(:user)
end
it 'can fill in all fields' do # .it errors
end
end
end
我想我需要告诉冰糕在上下文中如何称呼它spec_helper.rb
但我不知道该怎么做。
我已经安装了这个 gemrspec-sorbet
and ran
spec/spec_helper.rb
require 'rspec/sorbet'
为了消除错误,我运行了以下命令:
RSpec.describe(Model) do
T.bind(self, T.untyped)
# T.bind(self, RSpec) This does not work either
end
我已经设法通过绑定 RSpec 文件来实现某种功能。
首先,我安装了rspec-冰糕 https://github.com/samuelgiles/rspec-sorbetgem 主要帮助进行双打和结构检查,除此之外没有太多帮助。
然后我手动绑定 RSpec 测试。这使我能够获得 Sorbet 扩展的自动完成功能和好处,尽管它并不适用于所有情况。
RSpec.describe(MyModel) do
T.bind(self, T.untyped)
# add your tests...
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)