我想在运行任意 RSpec 测试之前执行一些代码,但前提是要测试的示例组位于特定目录中或带有特定标签。
例如,如果我有以下组:
## spec/file_one.rb
describe "Spec One - A group which needs the external app running", :external => true do
describe "Spec Two - A group which does not need the external app running" do
## spec/file_two.rb
describe "Spec Three - A group which does NOT need the external app running" do
## spec/always_run/file_three.rb
describe "Spec Four - A group which does need the external app running"
然后我希望只有在测试运行包含规范一或规范四时才执行代码。
当我可以依赖文件名时,这相对容易做到,但在依赖标签时更难。如何检查将运行哪些文件示例,然后检查它们的标签?