Report abuse

application

class Main
  attr_accessor :screen , :font , :bgcolor , :fgcolor , :size , :fname , :background , :x , :y , :cursor , :flags
  def initialize
    @screen = screen
    @background = background
    @font = font
    @bgcolor = bgcolor
    @fgcolor = fgcolor
    @size = size
    @fname = fname
    @x = x
    @y = y
    @cursor = cursor
    @cursor =  true
    @flags = flags
    @flags = [Rubygame::HWSURFACE, Rubygame::DOUBLEBUF]
  end
  #setup screen
  def set_new x = @x, y = @y, cursor = @cursor
    @x = x
    @y = y
    @cursor = cursor
    screenmode()
  end
  def screenmode
    @screen = Rubygame::Screen.set_mode([@x,@y],0, @flags)
    @screen.show_cursor = @cursor
    @background = Rubygame::Surface.new(@screen.size)
  end
  #Load a TTF file and set the size of the TFF file provided
  def font_set location , size
    @size = size
    @fname = location
    @font = TTF.new("#{location}",@size)
  end
  def screen_clear
    @background.blit(@screen, [0,0])
  end
  def background_cleanup
    @background.draw_filled_box([0,0], [@x,@y] , [0,0,0] )
  end
  def add n
    case n
    when 1
      @flags << Rubygame::FULLSCREEN
    end
    screenmode()
  end
end

test

class MainScreenTest < Test::Unit::TestCase
  def setup
    @main = Main.new
  end
  def test_return_new_size
    @main.set_new(800,600)
    assert @main.screen.size == [800,600]
  end
  def test_return_same_size
    @main.set_new(800,600)
    @main.set_new()
    assert @main.screen.size == [800,600]
  end
  def test_return_false
    @main.set_new(800,600,false)
    @main.set_new()
    assert @main.cursor == false
  end
  def test_screen_return_extra_flags
    @main.set_new(800,600)
    @main.add(1)
    assert @main.screen.flags[-1] == Rubygame::FULLSCREEN
    Rubygame.quit()
  end
end

result

  1) Failure:
test_screen_return_extra_flags(MainScreenTest) [./rbgooey/test/test_main_screen.rb:43]:
 is not true.

9 tests, 15 assertions, 1 failures, 0 erro