File: partial_iteration_test.rb

package info (click to toggle)
rails 2%3A6.1.7.10%2Bdfsg-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 39,756 kB
  • sloc: ruby: 290,662; javascript: 19,241; yacc: 46; sql: 43; makefile: 32; sh: 18
file content (35 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require "abstract_unit"
require "action_view/renderer/collection_renderer"

class PartialIterationTest < ActiveSupport::TestCase
  def test_has_size_and_index
    iteration = ActionView::PartialIteration.new 3
    assert_equal 0, iteration.index, "should be at the first index"
    assert_equal 3, iteration.size, "should have the size"
  end

  def test_first_is_true_when_current_is_at_the_first_index
    iteration = ActionView::PartialIteration.new 3
    assert iteration.first?, "first when current is 0"
  end

  def test_first_is_false_unless_current_is_at_the_first_index
    iteration = ActionView::PartialIteration.new 3
    iteration.iterate!
    assert_not iteration.first?, "not first when current is 1"
  end

  def test_last_is_true_when_current_is_at_the_last_index
    iteration = ActionView::PartialIteration.new 3
    iteration.iterate!
    iteration.iterate!
    assert iteration.last?, "last when current is 2"
  end

  def test_last_is_false_unless_current_is_at_the_last_index
    iteration = ActionView::PartialIteration.new 3
    assert_not iteration.last?, "not last when current is 0"
  end
end