Project

pig-spec

0.0
No commit activity in last 3 years
No release in over 3 years
PigSpec is a PigUnit-like program implemented in Ruby. It can be easily included into RSpec for running integration tests of existing Pig scripts.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

PigSpec README

Copyright (C) 2010-2014 Think Big Analytics, Inc. All Rights Reserved.

Summary/Description

PigSpec is a Ruby gem which can be used to test Pig scripts. It was designed to be easily integrated with the RSpec framework. It is loosely based on PigUnit (see: https://pig.apache.org/docs/r0.8.1/pigunit.html).

Building the gem:

The PigSpec gem can be built with the following command:

gem build pig-spec.gemspec

Example usage:

require 'pig-spec'

describe 'something to be tested' do
  include PigSpec

  it 'should run the pig script and produce a single line of output' do
    test_pig_script 'pig-0.6.0-core.jar', 'fake_script.pig', { "generated_file.txt" => "PigSpec creates this file. Current time is: #{Time.now}" }, { "output.csv" => "1,2,3,4" }, { "param1" => "foo", "param2" => "bar" }
    verify_output(false).should == true
  end
end

If PigSpec is properly installed, you will see the following line (along with standard RSpec output) when the spec is run:

Running the following command: java -jar pig-0.6.0-core.jar -x local -p param1=foo -p param2=bar fake_script.pig

Unless you've made some modifications to the above example (e.g. pointing it to an actual Pig JAR & script on your system), the above example will fail and produce output that looks like:

Running the following command: java -jar pig-0.6.0-core.jar -x local -p param1=foo -p param2=bar fake_script.pig
Unable to access jarfile pig-0.6.0-core.jar
Pig script exited with non-zero exit code: 256.
----------------------------------
| Verifying Pig script output... |
----------------------------------
Pig script exited with non-zero exit code: 256.
F

Failures:

  1. something to be tested should run the pig script and produce a single line of output
    Failure/Error: verify_output(false).should == true
    expected: true
    got: false (using ==)

    ./spec/example_spec.rb:8

Finished in 0.0131 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/example_spec.rb:6 # something to be tested should run the pig script and produce a single line of output