Is it possible to include conditional logic within an Rspec2 tag so that I can run all examples with tags less than or equal to a given value?
Something like:
rspec Dummy_spec.rb --tag version:= <=2
Obviously, this doesn't work but is there some Ruby magic that would make this work?
The reason for doing so is that I want to version my Rspec examples using tags. More specifically, I want to be able to filter all examples with a tag that is equal to or less than the tag value I specify when running the examples.
For example, if I am working on version 2 of my code but also getting a jump start on version 3, then I want to be able to just run all the examples that would be applicable to version 1 and version 2 of my code..but not version 3. (see code example below)
In anticipation of some replies, my rspec examples are in a separate project than my production code so its not a simple matter of versioning the examples with the code. But if there is a better way to handle this, I'm open to alternatives.
Full example of what I want to do:
describe "using version as tags" do
context "When I run 'rspec Dummy_spec.rb --tag version:2'"
it "should run this test applicable to ver 1", :version =>1 do
true.should eq(true)
end
it "should run this test applicable to ver 2", :version =>2 do
true.should eq(true)
end
it "should not run this test applicable to ver 3", :version =>3 do
true.should eq(true)
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.