Last active
January 21, 2021 17:57
-
-
Save odlp/5b692223d26e62a778bf43a91bf0838b to your computer and use it in GitHub Desktop.
Hit a spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/hit.rb | |
module HitSpec | |
def hit(*args, &block) | |
n = 100 | |
if args.last.is_a?(Hash) && args.last.key?(:n) | |
n = args.last.delete(:n) | |
end | |
n.times do | |
it(*args, &block) | |
end | |
end | |
end | |
RSpec.configure do |config| | |
config.extend HitSpec | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/hit_example_spec.rb | |
require "support/hit" | |
RSpec.describe "repeating a spec" do | |
hit "defaults to 100" do | |
expect(true).to be true | |
end | |
hit "is convenient", n: 1000 do | |
expect(true).to be true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by Que's
hit
helper for Minitest.