Created
August 7, 2014 02:10
-
-
Save patmaddox/5cb31be563890b17e636 to your computer and use it in GitHub Desktop.
rubysteps 008 - tdd - approval tests snippet
This file contains 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
require 'approvals/rspec' | |
def output_methods(target, methods) | |
methods.inject([]) do |results, m| | |
results << %("#{target}".#{m} => #{target.send(m)}) | |
end | |
end | |
describe "Ruby standard library" do | |
it "has a useful String class" do | |
string = "fOo" | |
verify { output_methods(string, [:downcase, :upcase, :size, :empty?]) } | |
end | |
it "has a useful Hash class" do | |
hash = { foo: 'bar' } | |
verify { output_methods(hash, [:keys, :values, :size]) } | |
end | |
it "has a useful Array class" do | |
array = [1, 2, 4, 3, 'chicken'] | |
verify { output_methods(array, [:first, :last, :size]) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment