Project

testdata

0.0
Low commit activity in last 3 years
No release in over a year
A test framework which accepts test data in a Polyrex format.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.1, >= 0.1.19
~> 0.1, >= 0.1.1
~> 0.2, >= 0.2.2
~> 1.3, >= 1.3.6
 Project Readme

How I use the testdata gem

The testdata gem is a test framework for unit testing. It uses a separate file for test data to keep things as simple as possible. Here's an example:

#!/usr/bin/env ruby

# file: test_gtk2html.rb

require 'testdata'
require 'requestor'

eval Requestor.read('http://rorbuilder.info/r/ruby') do |x|
  x.require 'gtk2html'
end

class TestGtk2HTML < Testdata::Base

  def tests()

    test 'Render to_a' do |html, width, height|
      
      doc = Htmle.new(html)
      Gtk2HTML::Render.new(doc, width, height).to_a.inspect
        
    end

  end
end


url = 'http://rorbuilder.info/r/gemtest/gtk2html/testdata_gtk2html.xml'

TestGtk2HTML.new(url).run
#=> {:passed=>true, :score=>"2/2", :failed=>[]}

To run a specific test, we enter the path number into the run method e.g.

TestGtk2HTML.new(url).run '1'

Note: The path number is simply the identifier for a specific test.

If the test failed, we can examine the expected results with the actual results using the debug flag e.g.

TestGtk2HTML.new(url).run '1', debug=true

Output:

inputs: 
  html: <html style="background-color:white;margin:0;padding:0;font-size:1.3em;color:red"><div style="background-color:white;margin:0;padding:0;font-size:1.3em;color:red"></div></html>
  width: 320
  height: 240

type or description:
 Render to_a: 

expected : 
  ["[[:draw_box, [0.0, 0.0, 0.0, 0.0], [0, 0, 320, 240], [0.0, 0.0, 0.0, 0.0], {:\"background-color\"=>\"white\", :margin=>{:top=>0.0, :right=>0.0, :bottom=>0.0, :left=>0.0}, :padding=>{:top=>0.0, :right=>0.0, :bottom=>0.0, :left=>0.0}, :\"font-size\"=>\"1.3em\", :color=>\"red\"}], [[:draw_box, [0.0, 0.0, 0.0, 0.0], [nil, nil, nil, nil], [0.0, 0.0, 0.0, 0.0], {:\"background-color\"=>\"white\", :margin=>{:top=>0.0, :right=>0.0, :bottom=>0.0, :left=>0.0}, :padding=>{:top=>0.0, :right=>0.0, :bottom=>0.0, :left=>0.0}, :\"font-size\"=>\"1.3em\", :color=>\"red\"}]]]"]

Resources

testdata test gem testing