summaryrefslogtreecommitdiff
path: root/spec/ruby/language/match_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/match_spec.rb')
-rw-r--r--spec/ruby/language/match_spec.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/ruby/language/match_spec.rb b/spec/ruby/language/match_spec.rb
index 81604e94b2..096ebee022 100644
--- a/spec/ruby/language/match_spec.rb
+++ b/spec/ruby/language/match_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/match_operators', __FILE__)
+require_relative '../spec_helper'
+require_relative 'fixtures/match_operators'
describe "The !~ operator" do
before :each do
@@ -46,6 +46,21 @@ describe "The =~ operator with named captures" do
matched.should == "foo"
unmatched.should == nil
end
+
+ it "sets existing local variables if declared in a higher scope" do
+ a = 42
+ 1.times do
+ /(?<a>foo)/ =~ @string
+ end
+ a.should == "foo"
+ end
+ end
+
+ describe "on syntax of 'string_literal' =~ /regexp/" do
+ it "does not set local variables" do
+ 'string literal' =~ /(?<matched>str)(?<unmatched>lit)?/
+ local_variables.should == []
+ end
end
describe "on syntax of string_variable =~ /regexp/" do