Created
March 8, 2012 17:24
-
-
Save ksexton/2002197 to your computer and use it in GitHub Desktop.
Playing with rspec
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
# play_spec.rb | |
require 'tempfile' | |
require './play' | |
describe 'uuencode' do | |
before do | |
file = Tempfile.new('play_spec') | |
file.print "Lorum Ipsum" | |
file.rewind | |
@coded = uuencode(file) | |
file.unlink | |
file = Tempfile.new('play_spec') | |
file.puts "Lorum Ipsum" | |
file.puts "Lorum Ipsum" | |
file.puts "Lorum Ipsum" | |
file.puts "Lorum Ipsum" | |
file.puts "Lorum Ipsum" | |
file.rewind | |
@multiline_coded = uuencode(file) | |
file.each_line do |i| | |
puts i | |
end | |
file.unlink | |
end | |
it "should return a string" do | |
@coded.class.should == String | |
end | |
it "should uuencode" do | |
@coded.should == "TG9ydW0gSXBzdW0=\n" | |
end | |
it "should handle multiline input" do | |
@multiline_coded.should == "TG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\n" | |
end | |
end | |
describe 'uudecode' do | |
before do | |
file = Tempfile.new('play_spec') | |
file.write "TG9ydW0gSXBzdW0=\n" | |
file.rewind | |
@coded = uudecode(file) | |
file = Tempfile.new('play_spec') | |
file.write "TG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\nTG9ydW0gSXBzdW0K\n" | |
file.rewind | |
@multiline_coded = uudecode(file) | |
end | |
it "should return a string" do | |
@coded.class.should == String | |
end | |
it "should uudecode" do | |
@coded.should == "Lorum Ipsum" | |
end | |
it "should handle multiline files" do | |
@multiline_coded.should == "Lorum Ipsum\nLorum Ipsum\nLorum Ipsum\nLorum Ipsum\nLorum Ipsum\n" | |
end | |
end |
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
Kyles-MacBook-Pro-2:play kes$ rspec play_spec.rb -c -f d | |
uuencode | |
should return a string | |
should uuencode | |
should handle multiline input | |
uudecode | |
should return a string | |
should uudecode | |
should handle multiline files | |
Finished in 0.00561 seconds | |
6 examples, 0 failures | |
Kyles-MacBook-Pro-2:play kes$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment