Browse files

Consolidate describes

  • Loading branch information...
1 parent 39360ea commit 22112b4f8907a1d1f5d0bdf90f8d79e9916a6d9f @jfirebaugh jfirebaugh committed with Michal Bugno May 1, 2012
Showing with 17 additions and 21 deletions.
  1. +17 −21 spec/ruby/core/regexp/match_spec.rb
View
38 spec/ruby/core/regexp/match_spec.rb
@@ -12,11 +12,28 @@
describe "Regexp#=~" do
it_behaves_like(:regexp_match, :=~)
+
+ it "returns the index of the first character of the matching region" do
+ (/(.)(.)(.)/ =~ "abc").should == 0
+ end
end
describe "Regexp#match" do
it_behaves_like(:regexp_match, :match)
+ it "returns a MatchData object" do
+ /(.)(.)(.)/.match("abc").should be_kind_of(MatchData)
+ end
+
+ it "resets $~ if passed nil" do
+ # set $~
+ /./.match("a")
+ $~.should be_kind_of(MatchData)
+
+ /1/.match(nil)
+ $~.should be_nil
+ end
+
it "raises TypeError when the given argument cannot be coarce to String" do
f = 1
lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
@@ -43,24 +60,3 @@
(~ /at/).should == 7
end
end
-
-describe "Regexp#=~ on a successful match" do
- it "returns the index of the first character of the matching region" do
- (/(.)(.)(.)/ =~ "abc").should == 0
- end
-end
-
-describe "Regexp#match on a successful match" do
- it "returns a MatchData object" do
- /(.)(.)(.)/.match("abc").should be_kind_of(MatchData)
- end
-
- it "resets $~ if passed nil" do
- # set $~
- /./.match("a")
- $~.should be_kind_of(MatchData)
-
- /1/.match(nil)
- $~.should be_nil
- end
-end

0 comments on commit 22112b4

Please sign in to comment.