Skip to content

Instantly share code, notes, and snippets.

@calavera
Created September 14, 2009 19:49
Show Gist options
  • Save calavera/186883 to your computer and use it in GitHub Desktop.
Save calavera/186883 to your computer and use it in GitHub Desktop.
david@MacSkull ~/dev/rubyspec$ git add core/io/gets_spec.rb
david@MacSkull ~/dev/rubyspec$ git ci -m "added specs for IO.gets with an integer as parameter to limit the outputs's size"
Created commit b12220d: added specs for IO.gets with an integer as parameter to limit the outputs's size
1 files changed, 26 insertions(+), 0 deletions(-)
david@MacSkull ~/dev/rubyspec$ git push origin master
Counting objects: 9, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 694 bytes, done.
Total 5 (delta 4), reused 0 (delta 0)
To git@github.com:rubyspec/rubyspec.git
26acc58..b12220d master -> master
david@MacSkull ~/dev/rubyspec$ git show b12220d
commit b12220d7cc076a1fd9ed23811d2e169546e73b8e
Author: David Calavera <david.calavera@gmail.com>
Date: Mon Sep 14 21:12:56 2009 +0200
added specs for IO.gets with an integer as parameter to limit the outputs's size
diff --git a/core/io/gets_spec.rb b/core/io/gets_spec.rb
index 0ea7bec..454ebab 100644
--- a/core/io/gets_spec.rb
+++ b/core/io/gets_spec.rb
@@ -189,4 +189,30 @@ describe "IO#gets" do
b.should == "\nB\n"
File.unlink(tmp("gets_specs"))
end
+
+ ruby_version_is "1.9" do
+ it "accepts an integer as first parameter to limit the output's size" do
+ f = File.open(tmp("gets_specs"), "w")
+ f.print("waduswadus")
+ f.close
+
+ f = File.new(tmp("gets_specs"), "r")
+ b = f.gets(5)
+ b.should == 'wadus'
+
+ File.unlink(tmp("gets_specs"))
+ end
+
+ it "accepts an integer as second parameter to limit the output's size" do
+ f = File.open(tmp("gets_specs"), "w")
+ f.print("wa\n\ndus\n\nwadus")
+ f.close
+
+ f = File.new(tmp("gets_specs"), "r")
+ b = f.gets('\n\n', 5)
+ b.should == "wa\n\nd"
+
+ File.unlink(tmp("gets_specs"))
+ end
+ end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment