Sha256: 553e8ab77c8ac8227879e618a2169664f0779c9c296cb081fccc5e075cc6aa72

Contents?: true

Size: 1.79 KB

Versions: 9

Compression:

Stored size: 1.79 KB

Contents

module WatirSplash
  # class for common functionality
  class Util
    class << self
      # returns unique file path for use in the examples
      #
      # all file names generated with this method will
      # be shown on the report upon test failure.
      def file_path(file_name, description=nil)
        WatirSplash::Util.formatter.file_path(file_name, description)
      end

      # returns native file path
      # e.g. on Windows:
      #   file_native_path("c:/blah/blah2/file.txt") => c:\\blah\\blah2\\file.txt
      def file_native_path(file_path)
        File::ALT_SEPARATOR ? file_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) : file_path
      end

      def formatter
        @html_formatter ||= begin
                              formatter = RSpec.configuration.formatters.find {|formatter| formatter.kind_of? WatirSplash::HtmlFormatter}
                              raise "WatirSplash::HtmlFormatter is not loaded - are you sure that you have specified it in your .rspec file?" unless formatter
                              formatter
                            end
      end

      def framework= framework
        framework = framework.to_sym
        @framework = framework == :default ? default_framework : framework
      end

      def framework
        @framework
      end

      def load_framework
        self.framework = ENV["WATIRSPLASH_FRAMEWORK"] || framework || default_framework
        require "watirsplash/frameworks/#{framework}"
      end

      private

      def default_framework
        case RUBY_PLATFORM
        when /mswin|msys|mingw32/
          "watir"
        when /darwin|linux/
          "watir-webdriver/firefox"
        else
          raise "Unsupported platform: #{RUBY_PLATFORM}"
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
watirsplash-2.4.4 lib/watirsplash/util.rb
watirsplash-2.4.3 lib/watirsplash/util.rb
watirsplash-2.4.2 lib/watirsplash/util.rb
watirsplash-2.4.1 lib/watirsplash/util.rb
watirsplash-2.4.0 lib/watirsplash/util.rb
watirsplash-2.3.2 lib/watirsplash/util.rb
watirsplash-2.3.1 lib/watirsplash/util.rb
watirsplash-2.3.0 lib/watirsplash/util.rb
watirsplash-2.2.0 lib/watirsplash/util.rb