Sha256: e9ca6e9c19b3bba5a4b882e0f92c80d3be0b000a1c21e883e05680ecf217e416

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true
require_relative 'test_helper'


require_relative '../lib/propane/creators/sketch_class'

CLASS_SKETCH = <<~CODE
# frozen_string_literal: false
require 'propane'

class FredSketch < Propane::App
  def settings
    size 200, 200
  end

  def setup
    sketch_title 'Fred Sketch'
  end

  def draw

  end
end

FredSketch.new

CODE

BARE_SKETCH = <<~CODE
def settings
  size 200, 200, P2D
end

def setup
  sketch_title 'Fred Sketch'
end

def draw

end

CODE

class SketchClassTest < Minitest::Test

  def setup
    @basic = SketchClass.new(name: 'fred_sketch', width: 200, height: 200)
    @sketch = SketchClass.new(name: 'fred_sketch', width: 200, height: 200, mode: 'p2d')
  end

  def test_class
    result = CLASS_SKETCH.split(/\n/, -1)
    class_lines = @sketch.lines
    class_lines.each_with_index do |line, i|
      assert_equal result[i], line
    end
  end

  def test_indent
    assert_equal '  indent', @sketch.indent('indent')
  end

  def test_size
    assert_equal '    size 200, 200, P2D', @sketch.size
    assert_equal '    size 200, 200', @basic.size
  end

  def test_sketch_title
    assert_equal "    sketch_title 'Fred Sketch'", @sketch.sketch_title
  end

  def test_class
    assert_equal "FredSketch", @sketch.sketch_class
  end

  def test_class_new
    assert_equal "FredSketch.new", @sketch.sketch_new
  end

  def test_method_lines
    result = CLASS_SKETCH.split(/\n/, -1)
    @basic.method_lines('settings', @basic.size).each_with_index do |line, i|
      assert_equal result[i + 4], line
    end
  end


  def test_sketch_class
    assert_equal "class FredSketch < Propane::App", @basic.class_sketch
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
propane-2.3.0-java test/test_create.rb
propane-2.1.1-java test/test_create.rb