source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/acceptance/parsejson_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 8 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper_acceptance'
3
4describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5 describe 'success' do
6 it 'parses valid json' do
7 pp = <<-EOS
8 $a = '{"hunter": "washere", "tests": "passing"}'
9 $ao = parsejson($a)
10 $tests = $ao['tests']
11 notice(inline_template('tests are <%= @tests.inspect %>'))
12 EOS
13
14 apply_manifest(pp, :catch_failures => true) do |r|
15 expect(r.stdout).to match(/tests are "passing"/)
16 end
17 end
18 end
19
20 describe 'failure' do
21 it 'raises error on incorrect json' do
22 pp = <<-EOS
23 $a = '{"hunter": "washere", "tests": "passing",}'
24 $ao = parsejson($a, 'tests are using the default value')
25 notice(inline_template('a is <%= @ao.inspect %>'))
26 EOS
27
28 apply_manifest(pp, :catch_failures => true) do |r|
29 expect(r.stdout).to match(/tests are using the default value/)
30 end
31 end
32
33 it 'raises error on incorrect json' do
34 pp = <<-EOS
35 $a = '{"hunter": "washere", "tests": "passing",}'
36 $ao = parsejson($a)
37 notice(inline_template('a is <%= @ao.inspect %>'))
38 EOS
39
40 apply_manifest(pp, :expect_failures => true) do |r|
41 expect(r.stderr).to match(/expected next name/)
42 end
43 end
44
45 it 'raises error on incorrect number of arguments' do
46 pp = <<-EOS
47 $o = parsejson()
48 EOS
49
50 apply_manifest(pp, :expect_failures => true) do |r|
51 expect(r.stderr).to match(/wrong number of arguments/i)
52 end
53 end
54 end
55end
Note: See TracBrowser for help on using the repository browser.