Sha256: 1f3a927e80d3bd47b004bf1a796f037041774c69f79083e935c85aba4760da66

Contents?: true

Size: 1.84 KB

Versions: 114

Compression:

Stored size: 1.84 KB

Contents

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

describe Array do
  context :together_first do
    cases = [
      {
        case_no: 1,
        case_title: 'not args case',
        inputs: [[*1..5], [*6..10]],
        method_name: :together_first,
        expected: [1, 6],
        has_args: false,
      },
      {
        case_no: 2,
        case_title: 'has args 2 case',
        inputs: [[*1..5], [*6..10]],
        args: 2,
        method_name: :together_first,
        expected: [[1, 2], [6, 7]],
        has_args: true,
      },
      {
        case_no: 3,
        case_title: 'has args 0 case',
        inputs: [[*1..5], [*6..10]],
        args: 0,
        method_name: :together_first,
        expected: [[], []],
        has_args: true,
      },
      {
        case_no: 4,
        case_title: 'has args over size case',
        inputs: [[*1..5], [*6..10]],
        args: 6,
        method_name: :together_first,
        expected: [[*1..5], [*6..10]],
        has_args: true,
      },
      {
        case_no: 5,
        case_title: 'not args case(alias tfirst)',
        inputs: [[*1..5], [*6..10]],
        method_name: :tfirst,
        expected: [1, 6],
        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

114 entries across 114 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.90 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.89 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.88 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.87 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.86 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.85 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.84 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.83 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.82 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.81 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.80 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.79 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.78 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.77 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.76 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.75 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.74 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.73 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.72 spec/open_classes/array/together_first_spec.rb
tbpgr_utils-0.0.71 spec/open_classes/array/together_first_spec.rb