Sha256: b7095d9d85595b59418010f827fd134271ed9d3af73000c661d88ada54bbf46d
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module SideToCapybara class Base attr_reader :side_command def initialize(side_command) @side_command = side_command end def target @side_command['target'] end def targets @side_command['targets'] end def value @side_command['value'] end def command @side_command['command'] end def comment @side_command['comment'] end def id @side_command['id'] end def selector_type _selector_type(target) end def selector _selector(target) end # returns the translation of the command or a warning if the command can't be translated def translate method_id = command.gsub(/([a-z])([A-Z])/, '\1_\2').downcase if self.class.public_method_defined?(method_id) # the translation itself translation = [public_send(method_id)] # add the alternative selectors as comments translation.unshift(commented_targets.join("\n")) if targets.size > 1 translation.join("\n") else "# WARNING: Conversion for '#{command}' not found." end end private def split_target(target) /^(\w+)=(.*)$/.match(target)[1..2] end def _selector(target) split_target(target).last end def _selector_type(target) split_target(target).first end def commented_targets targets.map { |target| "# #{_selector_type(target.first)}: #{_selector(target.first)}" }.uniq end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
side_to_capybara-0.1.0 | lib/side_to_capybara/base.rb |