Sha256: 5f7b3bbca7109ab2c79a3312f59e174f0097f1e583d901d5655306d83c23d427

Contents?: true

Size: 827 Bytes

Versions: 13

Compression:

Stored size: 827 Bytes

Contents

module RSpec
  module Parameterized
    class Table
      attr_reader :last_row

      def initialize
        @rows = []
        @last_row = nil
      end

      def add_row(row)
        unless @rows.find {|r| r.object_id == row.object_id}
          @rows << row
          @last_row = row
        end
        self
      end

      def add_param_to_last_row(param)
        last_row.add_param(param)
        self
      end
      alias :| :add_param_to_last_row

      def to_a
        @rows.map(&:to_a)
      end
      alias :to_params :to_a

      class Row
        def initialize(param)
          @params = [param]
        end

        def add_param(param)
          @params << param
        end

        def to_a
          @params
        end

        def to_params
          [@params]
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rspec-parameterized-0.5.3 lib/rspec/parameterized/table.rb
rspec-parameterized-0.5.2 lib/rspec/parameterized/table.rb
rspec-parameterized-0.5.1 lib/rspec/parameterized/table.rb
rspec-parameterized-0.5.0 lib/rspec/parameterized/table.rb
rspec-parameterized-0.4.2 lib/rspec/parameterized/table.rb
rspec-parameterized-0.4.1 lib/rspec/parameterized/table.rb
rspec-parameterized-0.4.0 lib/rspec/parameterized/table.rb
rspec-parameterized-0.3.2 lib/rspec/parameterized/table.rb
rspec-parameterized-0.3.1 lib/rspec/parameterized/table.rb
rspec-parameterized-0.3.0 lib/rspec/parameterized/table.rb
rspec-parameterized-0.2.0 lib/rspec/parameterized/table.rb
rspec-parameterized-0.1.3 lib/rspec/parameterized/table.rb
rspec-parameterized-0.1.2 lib/rspec/parameterized/table.rb