Created
October 4, 2012 17:33
-
-
Save ngan/3835153 to your computer and use it in GitHub Desktop.
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
shared_examples "a measurable object" do |measurement, measurement_methods| | |
measurement_methods.each do |measurement_method| | |
it "should return #{measurement} from ##{measurement_method}" do | |
subject.send(measurement_method).should == measurement | |
end | |
end | |
end | |
describe Array, "with 3 items" do | |
subject { [1, 2, 3] } | |
it_behaves_like "a measurable object", 3, [:size, :length] | |
end | |
describe String, "of 6 characters" do | |
subject { "FooBar" } | |
it_behaves_like "a measurable object", 6, [:size, :length] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment