Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Forked from myronmarston/example_group.rb
Created August 1, 2010 14:45
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 dchelimsky/503432 to your computer and use it in GitHub Desktop.
Save dchelimsky/503432 to your computer and use it in GitHub Desktop.
shared_examples_for "a measurable object" do |measurement_method, measurement|
it "should return #{measurement} from ##{measurement_method}" do
subject.send(measurement_method).should == measurement
end
end
describe Array do
it_should_behave_like "a measurable object", :size, 2 do
subject { [2, 13] }
end
end
describe String do
it_should_behave_like "a measurable object", :length, 6 do
subject { "FooBar" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment