Skip to content

Instantly share code, notes, and snippets.

@burtlo
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burtlo/feefde2f4300155379ad to your computer and use it in GitHub Desktop.
Save burtlo/feefde2f4300155379ad to your computer and use it in GitHub Desktop.
describe String do
it "responds to #to_s" do
expect("").to respond_to(:to_s)
end
it "responds to the correct methods" do
[ :to_s, :to_i, :to_f ].each do |method|
expect("").to respond_to(method)
end
end
[ :to_s, :to_i, :to_f ].each do |method|
it "responds to #{method}" do
expect("").to respond_to(method)
end
end
def required_methods
[ :to_s, :to_i, :to_f ]
end
required_methods.each do |method|
it "responds to #{method}" do
expect("").to respond_to(method)
end
end
# Or something that is a little more Rspec
let(:methods_to_test) do
[ :to_s, :to_i, :to_f ]
end
methods_to_test.each do |method|
it "responds to #{method}" do
expect("").to respond_to(method)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment