Sha256: 84e00c4d7b5e12a9a9e30336bd9fe57ad5bbe985f29adbecffb3bd612fba48bc

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

module Pickles

  class << self
    def configure
      yield config
    end

    def config
      @_configuration ||= Pickles::Config.new
    end
  end

end

class Pickles::Config

  using HashSymbolizeKeys

  attr_accessor :css_node_map, :xpath_node_map, :log_xhr_response

  def initialize
    @css_node_map = {}
    @log_xhr_response = false
    @xpath_node_map = {}
    @fill_tag_steps_map = { 'select' => FillIN::Select }
    @check_tag_steps_map = { 'text' => CheckIn::Text }
  end

  def css_node_map=(map)
    raise(ArgumentError, "Node map must be a hash") unless map.is_a?(Hash)

    @css_node_map = map.stringify_keys
  end

  def xpath_node_map=(map)
    raise(ArgumentError, "Node map must be a hash") unless map.is_a?(Hash)

    @xpath_node_map = map.stringify_keys
  end

  def fill_tag_steps_map=(map)
    raise(ArgumentError, "Node map must be a hash") unless map.is_a?(Hash)

    @fill_tag_steps_map.merge!(map)
  end

  def check_tag_steps_map=(map)
    raise(ArgumentError, "Node map must be a hash") unless map.is_a?(Hash)

    @check_tag_steps_map.merge!(map)
  end

  def step_by_tag(tag)
    @fill_tag_steps_map[tag]
  end

  def check_step_by_tag(tag)
    @check_tag_steps_map[tag]
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pickles-0.1.8 lib/cucumber/pickles/config.rb
pickles-0.1.7 lib/cucumber/pickles/config.rb
pickles-0.1.6 lib/cucumber/pickles/config.rb
pickles-0.1.5 lib/cucumber/pickles/config.rb
pickles-0.1.4 lib/cucumber/pickles/config.rb
pickles-0.1.3 lib/cucumber/pickles/config.rb
pickles-0.1.2 lib/cucumber/pickles/config.rb