Last active
August 29, 2015 14:05
-
-
Save burtlo/feefde2f4300155379ad 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
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