source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/functions/convert_base_spec.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 1.6 KB
Line 
1require 'spec_helper'
2
3describe 'convert_base' do
4 it { is_expected.not_to eq(nil) }
5 it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
6 it { is_expected.to run.with_params("asdf").and_raise_error(ArgumentError) }
7 it { is_expected.to run.with_params("asdf","moo","cow").and_raise_error(ArgumentError) }
8 it { is_expected.to run.with_params(["1"],"2").and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) }
9 it { is_expected.to run.with_params("1",["2"]).and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) }
10 it { is_expected.to run.with_params("1",1).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) }
11 it { is_expected.to run.with_params("1",37).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) }
12
13 it "should raise a ParseError if argument 1 is a string that does not correspond to an integer in base 10" do
14 is_expected.to run.with_params("ten",6).and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/)
15 end
16
17 it "should raise a ParseError if argument 2 is a string and does not correspond to an integer in base 10" do
18 is_expected.to run.with_params(100,"hex").and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/)
19 end
20
21 it { is_expected.to run.with_params("11",'16').and_return('b') }
22 it { is_expected.to run.with_params("35",'36').and_return('z') }
23 it { is_expected.to run.with_params(5, 2).and_return('101') }
24end
Note: See TracBrowser for help on using the repository browser.