alias 'it' in rspec

前端 未结 2 644
-上瘾入骨i
-上瘾入骨i 2020-12-31 10:40

I\'m trying to write some tests (not for code coverage, but irrelevant here) in rspec for a ROR app and need to alias describe and it, at the least. I can alias describe jus

相关标签:
2条回答
  • 2020-12-31 10:54

    It looks like you want to use define_example_method. This is how RSpec defines the example group methods like it and specify which are all really just aliases of each other. Not sure if there's an approved API for tapping into it, but you should be able to do something like:

    module RSpec
      module Core
        class ExampleGroupMethods
          class << self
            define_example_method :they
          end
        end
      end
    end
    
    0 讨论(0)
  • 2020-12-31 11:10

    You want to use alias_example_to:

    RSpec.configure do |c|
      c.alias_example_to :they
    end
    

    This is part of the public API of RSpec.

    0 讨论(0)
提交回复
热议问题