Sha256: ee080f5e761e34d22646d78b880755bc4a9132c5e9cfa6f7bb09d56bae5b4d72
Contents?: true
Size: 921 Bytes
Versions: 4
Compression:
Stored size: 921 Bytes
Contents
# encoding: utf-8 require 'spec_helper' describe TTY::Vector, '#new' do let(:object) { described_class } subject(:vector) { object.new(argument) } context 'with no arguments' do subject(:vector) { object.new } it 'sets elements to empty array' do expect(vector.to_a).to eq([]) end end context 'with nil argument' do let(:argument) { nil } it 'throws type error' do expect(vector.to_a).to eq([]) end end context 'with an argument that is a hash' do let(:argument) { {:value => 'Piotr'} } it 'sets elements' do expect(vector.to_a).to eq([[:value, 'Piotr']]) end end context 'with an argument that respond to #to_ary' do let(:argument) { Custom = Class.new do def to_ary ['Piotr'] end end Custom.new } it 'sets elements' do expect(vector.to_a).to eq(['Piotr']) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tty-0.2.1 | spec/tty/vector/new_spec.rb |
tty-0.2.0 | spec/tty/vector/new_spec.rb |
tty-0.1.3 | spec/tty/vector/new_spec.rb |
tty-0.1.2 | spec/tty/vector/new_spec.rb |