Sha256: 833c60c6bbfae8acb7394dd70489e10d406bffe21cfc4844e17ceba535a431be

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

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

describe String do

  context :justify_table do
    SAMPLE_TABLE = <<-EOS
|* first name|* family name|
|eiichiro|oda|
|akira|toriyama|
|yusei|matsui|
    EOS

    SAMPLE_NOT_TABLE = <<-EOS
csv_column1_1, csv_column1_2
csv_column2_1, csv_column2_2
    EOS

    SAMPLE_JUSTIFIED_TABLE = <<-EOS
|* first name|* family name|
|eiichiro    |oda          |
|akira       |toriyama     |
|yusei       |matsui       |
    EOS

    cases = [
      {
        case_no: 1,
        case_title: 'valid justify case',
        input: SAMPLE_TABLE,
        expected: SAMPLE_JUSTIFIED_TABLE,
      },
      {
        case_no: 2,
        case_title: 'not table case',
        input: SAMPLE_NOT_TABLE,
        expected: SAMPLE_NOT_TABLE,
      },
      {
        case_no: 3,
        case_title: 'empty case',
        input: '',
        expected: '',
      },
    ]

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

          # -- given --
          # nothing

          # -- when --
          actual = c[:input].justify_table

          # -- 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

8 entries across 8 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.8 spec/string_spec.rb
tbpgr_utils-0.0.7 spec/string_spec.rb
tbpgr_utils-0.0.6 spec/string_spec.rb
tbpgr_utils-0.0.5 spec/string_spec.rb
tbpgr_utils-0.0.4 spec/string_spec.rb
tbpgr_utils-0.0.3 spec/string_spec.rb
tbpgr_utils-0.0.2 spec/string_spec.rb
tbpgr_utils-0.0.1 spec/string_spec.rb