summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array/shared/join.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/array/shared/join.rb')
-rw-r--r--spec/ruby/core/array/shared/join.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb
new file mode 100644
index 0000000000..93d5329ee3
--- /dev/null
+++ b/spec/ruby/core/array/shared/join.rb
@@ -0,0 +1,15 @@
+require_relative '../fixtures/classes'
+require_relative '../fixtures/encoded_strings'
+
+describe :array_join_with_string_separator, shared: true do
+ it "returns a string formed by concatenating each element.to_str separated by separator" do
+ obj = mock('foo')
+ obj.should_receive(:to_str).and_return("foo")
+ [1, 2, 3, 4, obj].send(@method, ' | ').should == '1 | 2 | 3 | 4 | foo'
+ end
+
+ it "uses the same separator with nested arrays" do
+ [1, [2, [3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6"
+ [1, [2, ArraySpecs::MyArray[3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6"
+ end
+end