Skip to content

Instantly share code, notes, and snippets.

@paul
Created March 26, 2009 02:00
Show Gist options
  • Save paul/85823 to your computer and use it in GitHub Desktop.
Save paul/85823 to your computer and use it in GitHub Desktop.
share_examples_for "An Adapter" do
def adapter_supports?(method)
@adapter.class.instance_methods(false).include?(method.to_s)
end
before :all do
raise "+@adapter+ should be defined in before block" unless instance_variable_get("@adapter")
# More setup ...
end
if adapter_supports?(:create)
describe '#create' do
before do
@adapter.create(:foo, :bar)
# ...
end
it 'should do something' do
# ...
end
it 'should do something else' do
# ...
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment