Sha256: 84691960495a0acf7093d89fc2440aa3a9ceeac5cbbf3c307ac32e6db425df78

Contents?: true

Size: 510 Bytes

Versions: 3

Compression:

Stored size: 510 Bytes

Contents

String.class_eval do
  unless method_defined? :dirname
    def dirname
      File.expand_path(File.dirname(self))
    end
  end

  # Convert string to HTML node.
  def to_xhtml css = nil
    require 'rspec_ext/nokogiri'

    node = Nokogiri::HTML(self)
    unless css
      node
    else
      nodes = node.css(css)
      raise "Elements for '#{css}' CSS query not found!" if nodes.size < 1
      raise "Found more than one elment for '#{css}' CSS query!" if nodes.size > 1
      nodes.first
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_ext-4.0.3 lib/rspec_ext/misc.rb
ruby_ext-4.0.2 lib/rspec_ext/misc.rb
ruby_ext-4.0.1 lib/rspec_ext/misc.rb