Sha256: 469c2b1f1587874562effd7b6c2ac53217f61706bbae6b741819bd3c5ed810c1

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'tbpgr_utils'

describe Array do
  context :together_last do
    cases = [
      {
        case_no: 1,
        case_title: 'not args case',
        inputs: [[*1..5], [*6..10]],
        method_name: :together_last,
        expected: [5, 10],
        has_args: false
      },
      {
        case_no: 2,
        case_title: 'has args 2 case',
        inputs: [[*1..5], [*6..10]],
        args: 2,
        method_name: :together_last,
        expected: [[4, 5], [9, 10]],
        has_args: true
      },
      {
        case_no: 3,
        case_title: 'has args 0 case',
        inputs: [[*1..5], [*6..10]],
        args: 0,
        method_name: :together_last,
        expected: [[], []],
        has_args: true
      },
      {
        case_no: 4,
        case_title: 'has args over size case',
        inputs: [[*1..5], [*6..10]],
        args: 6,
        method_name: :together_last,
        expected: [[*1..5], [*6..10]],
        has_args: true
      },
      {
        case_no: 5,
        case_title: 'not args case(alias tlast)',
        inputs: [[*1..5], [*6..10]],
        method_name: :tlast,
        expected: [5, 10],
        has_args: false
      }
    ]

    cases.each do |c|
      it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
        begin
          case_before c

          # -- given --
          # nothing

          # -- when --
          if c[:has_args]
            actual = c[:inputs].send c[:method_name], c[:args]
          else
            actual = c[:inputs].send c[:method_name]
          end

          # -- then --
          expect(actual).to eq(c[:expected])
        ensure
          case_after c
        end
      end

      def case_before(c)
        # implement each case before
      end

      def case_after(c)
        # implement each case after
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 spec/open_classes/array/together_last_spec.rb