2016-08-16 69 views
0

运行rspec的这是红宝石样品RSpec的如何与多个标签

require "rspec" 
describe "Testing" do 
    it "test1",:status => "low" do 
     puts "test1" 
     expect(true).to eq true 
    end 
    it "test2",:status => "high" do 
     puts "test2" 
     expect(true).to eq true 
    end 
    it "test3",:status => "low" do 
     puts "test3" 
     expect(true).to eq true 
    end 
    it "test4",:status => "medium" do 
     puts "test4" 
     expect(true).to eq true 
    end 
end 

这是运行在高状态测试

rspec file_name --tag @status:"high" 

现在我想在高位运行,中的地位命令案例。任何想法?

回答

2

通过标记过滤在内部使用散列,这意味着您不能 为同一个键指定多个过滤器。例如,如果你试图 排除:name => 'foo':name => 'bar',你只会落得 排除:name => 'bar'

Read here

你要重命名的标签上运行多个实例这样

require "rspec" 
describe "Testing" do 
    it "test1",low: true do 
    puts "test1" 
    expect(true).to eq true 
    end 
    it "test2", high: true do 
    puts "test2" 
    expect(true).to eq true 
    end 
    it "test3", low: true do 
    puts "test3" 
    expect(true).to eq true 
    end 
    it "test4", medium: true do 
    puts "test4" 
    expect(true).to eq true 
    end 
end 

和运行测试是这样的:

rspec <file_name> --tag high --tag medium 

或者在你的情况,你可能只是exlude一个标签:

rspec <file_name> --tag ~status:low