Sha256: d76daac1450ac0301436491f0cfe5dfc4dc5cc5dc945ff7abafeb4f41760d2fe

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require "active_support/inflector"

module Chop
  module DSL
    def create! klass, table, &block
      Create.create! klass, table, &block
    end

    def diff! selector, table, session: Capybara.current_session, as: nil, &block
      class_name = if as
        as.to_s
      elsif selector.respond_to?(:tag_name)
        selector.tag_name
      else
        session.find(selector).tag_name
      end.camelize
      klass = const_get("Chop::#{class_name}")
      klass.diff! selector, table, session: session, &block
    end

    def fill_in! table
      Form.fill_in! table
    end
  end
end

if defined?(Cucumber::MultilineArgument::DataTable)
  Cucumber::MultilineArgument::DataTable.prepend Module.new {
    def create! klass, &block
      Chop.create! klass, self, &block
    end

    def diff! other_table="table", options={}, &block
      if other_table.respond_to?(:tag_name) || (other_table.is_a?(String) && !other_table.include?("|"))
        Chop.diff! other_table, self, options, &block
      else
        super
      end
    end

    def fill_in!
      Chop.fill_in! self
    end
  }
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chop-0.26.0 lib/chop/dsl.rb
chop-0.25.2 lib/chop/dsl.rb
chop-0.25.1 lib/chop/dsl.rb
chop-0.25.0 lib/chop/dsl.rb