Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Created April 27, 2013 23:25
Show Gist options
  • Save steveklabnik/5475159 to your computer and use it in GitHub Desktop.
Save steveklabnik/5475159 to your computer and use it in GitHub Desktop.
shared examples in MiniTest As usual, "Just Use Ruby"
require 'test_helper'
describe "foo" do
include SupportsCount
end
module SupportsCount
describe "#count" do
it "is a dummy test for this example" do
assert true
end
end
end
@zenspider
Copy link

For only one it per module? I don't see the point (even if it supports more than one).

@wojtekmach
Copy link

@wojtekmach
Copy link

@zenspider you probably already know that, but I was actually surprised that getting 95% use cases of shared examples with spec DSL is as simple as:

class Module
  include Minitest::Spec::DSL
end

module SupportsCount
  it 'responds to count' do
  end
end

it, before, after just works. It's kind of beautiful it's so simple. describe doesn't work but who cares.

@steveklabnik sorry for bombing your gist :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment