Skip to content

Commit

Permalink
Add more specs
Browse files Browse the repository at this point in the history
  • Loading branch information
hunner committed May 1, 2014
1 parent f8bfe46 commit 80590a9
Show file tree
Hide file tree
Showing 27 changed files with 733 additions and 47 deletions.
53 changes: 53 additions & 0 deletions spec/acceptance/pick_default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require 'spec_helper_acceptance'

describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'pick_defaults a default value' do
pp = <<-EOS
$a = undef
$o = pick_default($a, 'default')
notice(inline_template('picked is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/picked is "default"/)
end
end
it 'pick_defaults with no value' do
pp = <<-EOS
$a = undef
$b = undef
$o = pick_default($a,$b)
notice(inline_template('picked is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/picked is ""/)
end
end
it 'pick_defaults the first set value' do
pp = <<-EOS
$a = "something"
$b = "long"
$o = pick_default($a, $b, 'default')
notice(inline_template('picked is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/picked is "something"/)
end
end
end
describe 'failure' do
it 'raises error with no values' do
pp = <<-EOS
$o = pick_default()
notice(inline_template('picked is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :expect_failures => true) do |r|
expect(r.stderr).to match(/Must receive at least one argument/)
end
end
end
end
35 changes: 35 additions & 0 deletions spec/acceptance/range_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper_acceptance'

describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'ranges letters' do
pp = <<-EOS
$o = range('a','d')
notice(inline_template('range is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/range is \["a", "b", "c", "d"\]/)
end
end
it 'ranges letters with a step' do
pp = <<-EOS
$o = range('a','d', '2')
notice(inline_template('range is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/range is \["a", "c"\]/)
end
end
it 'ranges letters with a negative step'
it 'ranges numbers'
it 'ranges numbers with a step'
it 'ranges numbers with a negative step'
it 'ranges numeric strings'
it 'ranges zero padded numbers'
end
describe 'failure' do
it 'fails with no arguments'
end
end
2 changes: 1 addition & 1 deletion spec/acceptance/reject_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/reject is \["aaa", "bbb", "ccc", "aaaddd"\]/)
expect(r.stdout).to match(/reject is \[\]/)
end
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/acceptance/reverse_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper_acceptance'

describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'reverses strings' do
pp = <<-EOS
$a = "the public art galleries"
# Anagram: Large picture halls, I bet
$o = reverse($a)
notice(inline_template('reverse is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles non strings or arrays'
end
end
33 changes: 33 additions & 0 deletions spec/acceptance/rstrip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper_acceptance'

describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'rstrips arrays' do
pp = <<-EOS
$a = [" the "," public "," art","galleries "]
# Anagram: Large picture halls, I bet
$o = rstrip($a)
notice(inline_template('rstrip is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/rstrip is \[" the", " public", " art", "galleries"\]/)
end
end
it 'rstrips strings' do
pp = <<-EOS
$a = " blowzy night-frumps vex'd jack q "
$o = rstrip($a)
notice(inline_template('rstrip is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/rstrip is " blowzy night-frumps vex'd jack q"/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles non strings or arrays'
end
end
33 changes: 33 additions & 0 deletions spec/acceptance/shuffle_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper_acceptance'

describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'shuffles arrays' do
pp = <<-EOS
$a = ["the","public","art","galleries"]
# Anagram: Large picture halls, I bet
$o = shuffle($a)
notice(inline_template('shuffle is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to_not match(/shuffle is \["the", "public", "art", "galleries"\]/)
end
end
it 'shuffles strings' do
pp = <<-EOS
$a = "blowzy night-frumps vex'd jack q"
$o = shuffle($a)
notice(inline_template('shuffle is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to_not match(/shuffle is "blowzy night-frumps vex'd jack q"/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles non strings or arrays'
end
end
8 changes: 4 additions & 4 deletions spec/acceptance/size_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
it 'single string size' do
pp = <<-EOS
$a = 'discombobulate'
$o =size($a)
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
EOS

Expand All @@ -16,7 +16,7 @@
it 'with empty string' do
pp = <<-EOS
$a = ''
$o =size($a)
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
EOS

Expand All @@ -27,7 +27,7 @@
it 'with undef' do
pp = <<-EOS
$a = undef
$o =size($a)
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
EOS

Expand All @@ -38,7 +38,7 @@
it 'strings in array' do
pp = <<-EOS
$a = ['discombobulate', 'moo']
$o =size($a)
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
EOS

Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/sort_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pp = <<-EOS
$a = ["the","public","art","galleries"]
# Anagram: Large picture halls, I bet
$o =sort($a)
$o = sort($a)
notice(inline_template('sort is <%= @o.inspect %>'))
EOS

Expand All @@ -17,7 +17,7 @@
it 'sorts strings' do
pp = <<-EOS
$a = "blowzy night-frumps vex'd jack q"
$o =sort($a)
$o = sort($a)
notice(inline_template('sort is <%= @o.inspect %>'))
EOS

Expand Down
46 changes: 46 additions & 0 deletions spec/acceptance/squeeze_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'spec_helper_acceptance'

describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'squeezes arrays' do
pp = <<-EOS
# Real words!
$a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
$o = squeeze($a)
notice(inline_template('squeeze is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]/)
end
end
it 'squeezez arrays with an argument'
it 'squeezes strings' do
pp = <<-EOS
$a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
$o = squeeze($a)
notice(inline_template('squeeze is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/squeeze is "wales laparohysterosalpingophorectomy br godeship"/)
end
end

it 'squeezes strings with an argument' do
pp = <<-EOS
$a = "countessship duchessship governessship hostessship"
$o = squeeze($a, 's')
notice(inline_template('squeeze is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/squeeze is "counteship ducheship governeship hosteship"/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles non strings or arrays'
end
end
30 changes: 30 additions & 0 deletions spec/acceptance/str2bool_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper_acceptance'

describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'works with "y"' do
pp = <<-EOS
$o = str2bool('y')
notice(inline_template('str2bool is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/str2bool is true/)
end
end
it 'works with "Y"'
it 'works with "yes"'
it 'works with "1"'
it 'works with "true"'
it 'works with "n"'
it 'works with "N"'
it 'works with "no"'
it 'works with "0"'
it 'works with "false"'
it 'works with undef'
end
describe 'failure' do
it 'handles no arguments'
it 'handles non arrays or strings'
end
end
21 changes: 21 additions & 0 deletions spec/acceptance/str2saltedsha512_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper_acceptance'

describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'works with "y"' do
pp = <<-EOS
$o = str2saltedsha512('password')
notice(inline_template('str2saltedsha512 is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/str2saltedsha512 is "[a-f0-9]{136}"/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles more than one argument'
it 'handles non strings'
end
end
21 changes: 21 additions & 0 deletions spec/acceptance/strftime_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper_acceptance'

describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'gives the Century' do
pp = <<-EOS
$o = strftime('%C')
notice(inline_template('strftime is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/strftime is "20"/)
end
end
it 'takes a timezone argument'
end
describe 'failure' do
it 'handles no arguments'
it 'handles invalid format strings'
end
end
33 changes: 33 additions & 0 deletions spec/acceptance/strip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper_acceptance'

describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'strips arrays' do
pp = <<-EOS
$a = [" the "," public "," art","galleries "]
# Anagram: Large picture halls, I bet
$o = strip($a)
notice(inline_template('strip is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/strip is \["the", "public", "art", "galleries"\]/)
end
end
it 'strips strings' do
pp = <<-EOS
$a = " blowzy night-frumps vex'd jack q "
$o = strip($a)
notice(inline_template('strip is <%= @o.inspect %>'))
EOS

apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/strip is "blowzy night-frumps vex'd jack q"/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles non strings or arrays'
end
end
Loading

0 comments on commit 80590a9

Please sign in to comment.