【问题标题】:rspec spec automatic logical grouping (by "tags")rspec 规范自动逻辑分组(通过“标签”)
【发布时间】:2011-06-27 14:51:06
【问题描述】:

是否有任何现有的解决方案(最好是 gem)来使用 rspec 运行一些规范切片?

例如:
rspec . # runs whole test suite
rspec . --keywords=project # runs all specs that have "project" keyword there somewhere

还是类似的?

【问题讨论】:

    标签: ruby-on-rails ruby tags components rspec


    【解决方案1】:

    您可以通过向描述、上下文或测试提供键值对来在 rspec 中使用标签,如下所示:

    describe "A set of tests", :constraint => 'slow'
    describe "Another set of tests", :focus => true
    

    您可以通过以下方式运行这些集合中的任何一个:

    rspec --tag constraint:slow
    rspec --tag focus
    

    【讨论】:

    • 这是一个很好的评论,但我想更多的是像 grepping 所有规范内容并只运行包含我的关键字的规范
    • 你不能用 rspec 做到这一点,但你可以使用 bash :-) find 。 -type f -name '*spec' -exec grep 'search-string' {} \ | xargs rspec
    【解决方案2】:

    我认为内置的“--example”选项可以满足您的需求:

    rspec . --example "project"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多