summaryrefslogtreecommitdiff
path: root/spec/ruby/language
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/def_spec.rb33
-rw-r--r--spec/ruby/language/delegation_spec.rb14
-rw-r--r--spec/ruby/language/fixtures/delegation.rb4
-rw-r--r--spec/ruby/language/predefined_spec.rb2
4 files changed, 30 insertions, 23 deletions
diff --git a/spec/ruby/language/def_spec.rb b/spec/ruby/language/def_spec.rb
index 82c89a0d08..a589b4750b 100644
--- a/spec/ruby/language/def_spec.rb
+++ b/spec/ruby/language/def_spec.rb
@@ -306,32 +306,21 @@ end
describe "Redefining a singleton method" do
it "does not inherit a previously set visibility" do
o = Object.new
+ sc = o.singleton_class
- class << o; private; def foo; end; end;
-
- class << o; should have_private_instance_method(:foo); end
-
- class << o; def foo; end; end;
-
- class << o; should_not have_private_instance_method(:foo); end
- class << o; should have_instance_method(:foo); end
-
- end
-end
-
-describe "Redefining a singleton method" do
- it "does not inherit a previously set visibility" do
- o = Object.new
-
- class << o; private; def foo; end; end;
-
- class << o; should have_private_instance_method(:foo); end
+ class << o
+ private
+ def foo; end
+ end
- class << o; def foo; end; end;
+ sc.private_instance_methods(false).should.include?(:foo)
- class << o; should_not have_private_instance_method(:foo); end
- class << o; should have_instance_method(:foo); end
+ class << o
+ def foo; end
+ end
+ sc.private_instance_methods(false).should_not.include?(:foo)
+ sc.should.method_defined?(:foo)
end
end
diff --git a/spec/ruby/language/delegation_spec.rb b/spec/ruby/language/delegation_spec.rb
index 3d917993f5..efcf37aabc 100644
--- a/spec/ruby/language/delegation_spec.rb
+++ b/spec/ruby/language/delegation_spec.rb
@@ -59,6 +59,20 @@ describe "delegation with def(...)" do
a.new.delegate(1, b: 2).should == Range.new([[], {}, nil], nil, true)
end
+
+ it "passes non-keyword trailing hash through without modification" do
+ a = Class.new(DelegationSpecs::Target)
+ a.class_eval(<<-RUBY)
+ def delegate(...)
+ target_single(...)
+ end
+ RUBY
+
+ h = {a:1}
+ h.freeze
+ h2 = a.new.delegate(h)
+ h2.should.equal?(h)
+ end
end
describe "delegation with def(x, ...)" do
diff --git a/spec/ruby/language/fixtures/delegation.rb b/spec/ruby/language/fixtures/delegation.rb
index da2b024791..049a923e66 100644
--- a/spec/ruby/language/fixtures/delegation.rb
+++ b/spec/ruby/language/fixtures/delegation.rb
@@ -7,5 +7,9 @@ module DelegationSpecs
def target_block(*args, **kwargs)
yield [kwargs, args]
end
+
+ def target_single(arg)
+ arg
+ end
end
end
diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb
index d57b924bcf..f14f8ba93e 100644
--- a/spec/ruby/language/predefined_spec.rb
+++ b/spec/ruby/language/predefined_spec.rb
@@ -1103,7 +1103,7 @@ describe "Execution variable $:" do
end
describe "Global variable $\"" do
- it "is an alias for $LOADED_FEATURES" do
+ it "is an alias of $LOADED_FEATURES" do
$".should.equal? $LOADED_FEATURES
end