Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Set#join spec #862

Merged
merged 2 commits into from
Oct 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions library/set/join_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require_relative '../../spec_helper'
require 'set'

ruby_version_is "3.0" do
describe "Set#join" do
it "returns an empty string if the Set is empty" do
Set[].join.should == ''
end

it "returns a new string formed by joining elements after conversion" do
set = Set[:a, :b, :c]
set.join.should == "abc"
end

it "does not separate elements when the passed separator is nil" do
set = Set[:a, :b, :c]
set.join(nil).should == "abc"
end

it "returns a string formed by concatenating each element separated by the separator" do
set = Set[:a, :b, :c]
set.join(' | ').should == "a | b | c"
end

it "calls #to_a to convert the Set in to an Array" do
set = Set[:a, :b, :c]
set.should_receive(:to_a).and_return([:a, :b, :c])
set.join.should == "abc"
end
end
end