Skip to content

Commit ec90538

Browse files
committed
Improve specs for Symbol#to_proc
* dry-initializer relies on the arity being -1, see #1462 dry-rb/dry-initializer#52
1 parent e3a61d5 commit ec90538

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

spec/ruby/core/symbol/to_proc_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@
1212
:to_s.to_proc.call(obj).should == "Received #to_s"
1313
end
1414

15+
it "produces a proc with arity -1" do
16+
pr = :to_s.to_proc
17+
pr.arity.should == -1
18+
end
19+
1520
it "raises an ArgumentError when calling #call on the Proc without receiver" do
16-
lambda { :object_id.to_proc.call }.should raise_error(ArgumentError)
21+
lambda { :object_id.to_proc.call }.should raise_error(ArgumentError, "no receiver given")
1722
end
1823

1924
it "produces a proc that always returns [[:rest]] for #parameters" do
2025
pr = :to_s.to_proc
2126
pr.parameters.should == [[:rest]]
2227
end
23-
end
2428

25-
describe "Symbol#to_proc" do
26-
before :all do
27-
@klass = Class.new do
29+
it "passes along the block passed to Proc#call" do
30+
klass = Class.new do
2831
def m
2932
yield
3033
end
@@ -33,9 +36,6 @@ def to_proc
3336
:m.to_proc.call(self) { :value }
3437
end
3538
end
36-
end
37-
38-
it "passes along the block passed to Proc#call" do
39-
@klass.new.to_proc.should == :value
39+
klass.new.to_proc.should == :value
4040
end
4141
end

0 commit comments

Comments
 (0)