Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add basic specs for String#% %<foo> form. #120

Merged
merged 1 commit into from

1 participant

@headius

No description provided.

@headius headius merged commit de565d9 into rubyspec:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 13, 2012
  1. @headius
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 0 deletions.
  1. +14 −0 core/string/modulo_spec.rb
View
14 core/string/modulo_spec.rb
@@ -934,5 +934,19 @@ def obj.to_s() "obj" end
lambda {"%{foo}" % []}.should raise_error(ArgumentError)
end
end
+
+ describe "when format string contains %<> formats" do
+ it "uses the named argument for the format's value" do
+ ("%<foo>d" % {:foo => 1}).should == "1"
+ end
+
+ it "raises KeyError if key is missing from passed-in hash" do
+ lambda {"%<foo>d" % {}}.should raise_error(KeyError)
+ end
+
+ it "should raise ArgumentError if no hash given" do
+ lambda {"%<foo>" % []}.should raise_error(ArgumentError)
+ end
+ end
end
end
Something went wrong with that request. Please try again.