Sha256: 3e76e5e2768afd97ae7a8a539ecc88f5237d42a132e9942205d39e4ffcc2484a

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

gem "minitest"      # don't use bundled minitest
require "minitest/autorun"

Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) 

Dir.chdir(File.dirname(__FILE__))

class Rp5Test < Minitest::Test
  
  def test_normal    
    out, err = capture_io do
      open("|../bin/rp5 run basic.rb", "r") do |io|
        while l = io.gets
          puts(l.chop) 
        end      
      end
    end
    assert_match %r%ok%, out, "Failed Basic Sketch"    
  end
  
  def test_p2d    
    out, err = capture_io do
      open("|../bin/rp5 run p2d.rb", "r") do |io|
        while l = io.gets
          puts(l.chop) 
        end      
      end
    end
    assert_match %r%ok%, out, "Failed P2D sketch"     
  end
  
  def test_p3d    
    out, err = capture_io do
      open("|../bin/rp5 run p3d.rb", "r") do |io|
        while l = io.gets
          puts(l.chop) 
        end      
      end
    end
    assert_match %r%ok%, out, "Failed P3D sketch"     
  end
  
  def test_graphics    
    out, err = capture_io do
      open("|../bin/rp5 run graphics.rb", "r") do |io|
        while l = io.gets
          puts(l.chop) 
        end      
      end
    end
    assert out[0].to_i >= 3, "Graphics capability #{out} may be sub-optimal" 
  end
  
  def test_setup_exception
    out, err = capture_io do
      open("|../bin/rp5 run setup_ex.rb", "r") do |io|
        while l = io.gets
          puts(l.chop) 
        end      
      end
    end
    assert out.index("undefined method `unknown_method'"), "Failed to raise exception?" 
  end
  
  def test_draw_exception
    out, err = capture_io do
      open("|../bin/rp5 run draw_ex.rb", "r") do |io|
        while l = io.gets
          puts(l.chop) 
        end      
      end
    end
    assert out.index("undefined method `unknown_method'"), "Failed to raise exception"
  end  
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-processing-2.4.1 test/rp5_test.rb