【发布时间】:2017-01-10 02:40:57
【问题描述】:
我有这样的 rspec 测试代码
describe 'Utils' do
puts 1111
describe '#time_condition' do
puts 2221
it do
puts 'aaa'
end
puts 2223
end
end
我的 launch.json 是这样的
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/spec/*_rspec.rb",
"args": [
"--pattern",
"*_rspec.rb"
]
},
当我在 vscode 上运行测试时,我得到了
1111
2221
2223
当我通过命令运行测试时,得到了
>rspec spec --pattern *_rspec.rb
1111
2221
2223
aaa
.
Finished in 0.003 seconds (files took 0.23602 seconds to load)
1 example, 0 failures
如您所见,没有“aaa”输出,意味着没有“它”被执行。 那么...我怎样才能让它在 vscode 上运行?
顺便说一下,我的规范配置文件(由 rspec --init 生成)喜欢
.rspec
--color
--require spec_helper
spec\spec_helper.rb
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.profile_examples = 10
config.order = :random
Kernel.srand config.seed
end
VScode:1.4.0
Ruby 扩展:0.5.3
谢谢
【问题讨论】:
-
我在你的 rspec 文件中看不到你的期望
-
@Bustkiller 刚刚删除。不管有没有期望,'it' 都无法运行。
-
尝试改用语法
it 'test name' do -
@Bustkiller 不会也没有工作。正如我所写, rspec 命令成功。所以我的 rspec 代码很好。还是谢谢