Skip to content

Instantly share code, notes, and snippets.

@vinyar
Forked from burtlo/example_spec.rb
Created August 19, 2014 19:35
Show Gist options
  • Save vinyar/f4ba980a88fe784f6698 to your computer and use it in GitHub Desktop.
Save vinyar/f4ba980a88fe784f6698 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