简体   繁体   中英

How to skip / mock a test when no block is provided in Rails 5

我很难弄清楚如何以Rspec的方式在Rails中进行测试,而没有其余的Rspec。

I'm not 100% sure where this belongs, I put it in a file called:

config/initializers/integration_test_overrides.rb

But there might be a better place for it.

class ActionDispatch::IntegrationTest

  def self.test(test_string)
    if block_given?
      super
    else
      super(test_string) do
        skip
      end
    end
  end

end

Now when you call a test without the block:

test "endpoint accepts xml input"

The test will automatically skip it.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM