Sha256: aed0245209dd312f7bc7e43d2f3af2da5a28d0bf954d5260ea582d0c43bfca99

Contents?: true

Size: 1.51 KB

Versions: 26

Compression:

Stored size: 1.51 KB

Contents

# encoding: utf-8

require 'helper'

class TestCursor < MiniTest::Test

  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

26 entries across 26 versions & 2 rubygems

Version Path
sportdb-models-1.18.0 test/test_cursor.rb
sportdb-models-1.17.0 test/test_cursor.rb
sportdb-models-1.16.2 test/test_cursor.rb
sportdb-models-1.16.1 test/test_cursor.rb
sportdb-models-1.16.0 test/test_cursor.rb
sportdb-models-1.15.2 test/test_cursor.rb
sportdb-models-1.15.1 test/test_cursor.rb
sportdb-models-1.15.0 test/test_cursor.rb
sportdb-models-1.14.2 test/test_cursor.rb
sportdb-models-1.14.1 test/test_cursor.rb
sportdb-models-1.14.0 test/test_cursor.rb
sportdb-models-1.13.0 test/test_cursor.rb
sportdb-models-1.12.0 test/test_cursor.rb
sportdb-models-1.11.2 test/test_cursor.rb
sportdb-models-1.11.1 test/test_cursor.rb
sportdb-models-1.11.0 test/test_cursor.rb
sportdb-models-1.10.1 test/test_cursor.rb
sportdb-models-1.10.0 test/test_cursor.rb
sportdb-1.9.16 test/test_cursor.rb
sportdb-1.9.15 test/test_cursor.rb