Sha256: 8be1ec98b082a880e579cff9cdbf0933a408eb15950a43852254937e13791be6

Contents?: true

Size: 1.65 KB

Versions: 36

Compression:

Stored size: 1.65 KB

Contents

require 'yaml'
require 'json'


module TestCentricity

  XL_PRIMARY_DATA_PATH  ||= 'features/test_data/'
  XL_PRIMARY_DATA_FILE  ||= "#{XL_PRIMARY_DATA_PATH}data.xls"


  class DataObject
    attr_accessor :current
    attr_accessor :context
    attr_accessor :hash_table

    def initialize(data)
      @hash_table = data
    end

    def self.set_current(current)
      @current = current
    end

    def self.current
      @current
    end
  end


  class DataSource
    attr_accessor :current

    def read_yaml_node_data(file_name, node_name)
      data = YAML.load_file("#{XL_PRIMARY_DATA_PATH}#{file_name}")
      data[node_name]
    end

    def read_json_node_data(file_name, node_name)
      raw_data = File.read("#{XL_PRIMARY_DATA_PATH}#{file_name}")
      data = JSON.parse(raw_data)
      data[node_name]
    end
  end


  class ExcelDataSource < TestCentricity::DataSource
    def pick_excel_data_source(sheet, row_name)
      environment = ENV['TEST_ENVIRONMENT']
      data_file = "#{XL_PRIMARY_DATA_PATH}#{environment}_data.xls"
      data_file = XL_PRIMARY_DATA_FILE unless ExcelData.rowspec_exists?(data_file, sheet, row_name)
      data_file
    end

    def read_excel_row_data(sheet, row_name)
      ExcelData.read_row_data(pick_excel_data_source(sheet, row_name), sheet, row_name)
    end

    def read_excel_pool_data(sheet, row_name)
      ExcelData.read_row_from_pool(pick_excel_data_source(sheet, row_name), sheet, row_name)
    end

    def read_excel_range_data(sheet, range_name)
      ExcelData.read_range_data(pick_excel_data_source(sheet, range_name), sheet, range_name)
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
testcentricity_web-0.9.9.7 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9.6 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9.5 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9.4 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9.3 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9.2 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9.1 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.9 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.8 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.7 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.6.3 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.6.2 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.6.1 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.6 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.5.1 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.5 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.4 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.3.4 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.3 lib/testcentricity_web/data_objects_helper.rb
testcentricity_web-0.9.2 lib/testcentricity_web/data_objects_helper.rb