Sha256: ab347f0e3ea42e3cc22b46d03bd0c353c4b49cf40a774184c09cd08f3b6e3f50

Contents?: true

Size: 1.52 KB

Versions: 33

Compression:

Stored size: 1.52 KB

Contents

# encoding: utf-8

require 'helper'

class TestCursor < MiniTest::Unit::TestCase

  def test_games
    games = []
    
    games << Game.new( score1: 3, score2: 1, play_at: DateTime.new(2013, 8, 9) )
    games << Game.new( score1: 1, score2: 3, play_at: DateTime.new(2013, 8, 10) )
    games << Game.new( score1: 2, score2: 0, play_at: DateTime.new(2013, 8, 10) )
    games << Game.new( score1: 3, score2: 2, play_at: DateTime.new(2013, 8, 12) )  # new_week

    GameCursor.new( games ).each do |game,state|
      if state.index == 0
        assert_equal 3, game.score1
        assert_equal 1, game.score2
        assert_equal true, state.new_date?
        assert_equal true, state.new_year?
        assert_equal true, state.new_week?
      end

      if state.index == 1
        assert_equal 1, game.score1
        assert_equal 3, game.score2
        assert_equal true, state.new_date?
        assert_equal false, state.new_year?
        assert_equal false, state.new_week?
      end

      if state.index == 2
        assert_equal 2, game.score1
        assert_equal 0, game.score2
        assert_equal false, state.new_date?
        assert_equal false, state.new_year?
        assert_equal false, state.new_week?
      end

      if state.index == 3
        assert_equal 3, game.score1
        assert_equal 2, game.score2
        assert_equal true,  state.new_date?
        assert_equal true,  state.new_week?
        assert_equal false, state.new_year?
      end
    end
  end

end # class TestCursor

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
sportdb-1.9.8 test/test_cursor.rb
sportdb-1.9.7 test/test_cursor.rb
sportdb-1.9.6 test/test_cursor.rb
sportdb-1.9.5 test/test_cursor.rb
sportdb-1.9.4 test/test_cursor.rb
sportdb-1.9.3 test/test_cursor.rb
sportdb-1.9.2 test/test_cursor.rb
sportdb-1.9.1 test/test_cursor.rb
sportdb-1.9.0 test/test_cursor.rb
sportdb-1.8.29 test/test_cursor.rb
sportdb-1.8.28 test/test_cursor.rb
sportdb-1.8.27 test/test_cursor.rb
sportdb-1.8.26 test/test_cursor.rb
sportdb-1.8.25 test/test_cursor.rb
sportdb-1.8.24 test/test_cursor.rb
sportdb-1.8.23 test/test_cursor.rb
sportdb-1.8.22 test/test_cursor.rb
sportdb-1.8.21 test/test_cursor.rb
sportdb-1.8.20 test/test_cursor.rb
sportdb-1.8.19 test/test_cursor.rb