Sha256: 1cffaa5e77c199777e745adeb8d07b1a0cf8f83168064f3da8879b845e2dd70f

Contents?: true

Size: 1.61 KB

Versions: 60

Compression:

Stored size: 1.61 KB

Contents

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

describe Array do
  context :to_table do
    cases = [
      {
        case_no: 1,
        case_title: 'valid case',
        inputs: [
          ['header1', 'header2', 'header3'],
          ['line1_1', 'line1_2', 'line1_3'],
        ],
        expected: <<-EOS
<table>
  <tr>
    <th>header1</th>
    <th>header2</th>
    <th>header3</th>
  </tr>
  <tr>
    <td>line1_1</td>
    <td>line1_2</td>
    <td>line1_3</td>
  </tr>
</table>
        EOS
      },
      {
        case_no: 2,
        case_title: 'no header option case',
        inputs: [
          ['not_header1', 'not_header2', 'not_header3'],
          ['line1_1', 'line1_2', 'line1_3'],
        ],
        options: { no_header: true },
        expected: <<-EOS
<table>
  <tr>
    <td>not_header1</td>
    <td>not_header2</td>
    <td>not_header3</td>
  </tr>
  <tr>
    <td>line1_1</td>
    <td>line1_2</td>
    <td>line1_3</td>
  </tr>
</table>
        EOS
      },
    ]

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

          # -- given --
          # nothing

          # -- when/then --
          actual = c[:options] ? c[:inputs].to_html_table(c[:options]) : c[:inputs].to_html_table

          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

60 entries across 60 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.150 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.149 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.148 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.147 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.146 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.145 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.144 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.143 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.142 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.141 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.140 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.139 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.138 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.137 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.136 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.135 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.134 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.133 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.132 spec/open_classes/array/to_html_table_spec.rb
tbpgr_utils-0.0.131 spec/open_classes/array/to_html_table_spec.rb