Use RSpec's “expect” etc. outside a describe … it block

后端 未结 1 509
礼貌的吻别
礼貌的吻别 2021-01-12 15:32

I\'m building a web-app automation framework that is designed to allow for:

  • automating tasks, of course
  • building test scenarios easily

相关标签:
1条回答
  • 2021-01-12 16:00

    include ::RSpec::Matchers

    class A
      include ::RSpec::Matchers
      def test
        expect('1'.to_i).to eq 1
      end
    
      def failed_test
        expect('1'.to_i).to eq 2
      end
    end
    A.new.test
    # => true
    A.new.failed_test
    # RSpec::Expectations::ExpectationNotMetError: 
    # expected: 2
    #      got: 1
    
    0 讨论(0)
提交回复
热议问题