Skip to content

Instantly share code, notes, and snippets.

@jeremyf
Created April 25, 2014 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyf/11296882 to your computer and use it in GitHub Desktop.
Save jeremyf/11296882 to your computer and use it in GitHub Desktop.
Spitballing some spec_support for mixed in behaviors
# a-gem/lib/hydra_permlink/spec_support.rb
require 'rspec'
shared_examples 'a permalinked object' do |options|
let(:model) { described_class.new }
included_services = options.fetch(:services)
if included_services.include?(:doi)
it 'should permalink to a DOI'
end
if included_services.include?(:ark)
it 'should permalink to an ARK'
end
end
# my-app/spec/models/my_model_spec.rb
describe MyModel do
it_behaves_like 'a permalinked object', services: [:doi, :ark]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment