Sha256: 3cf3f35306a90e6dd6bf477bde64cd5a9bc867fe1cb5c09b6ebab0151c35334c
Contents?: true
Size: 867 Bytes
Versions: 5
Compression:
Stored size: 867 Bytes
Contents
# frozen_string_literal: true module RSpecHTML # Convenience utility for loading a provided path in the operating system's default browser. # Used for inspecting documents while debugging tests. class Browser def self.open(path) new(path).open end def initialize(path) @path = path end def open log_launch_browser_event system `#{command} '#{path}'` end private attr_reader :path def log_launch_browser_event warn "\e[35m[rspec-html] Opening document in browser from: \e[32m#{caller[3]}\e[0m" end def command return 'start' if RUBY_PLATFORM =~ /mswin|mingw|cygwin/ return 'open' if RUBY_PLATFORM =~ /darwin/ return 'xdg-open' if RUBY_PLATFORM =~ /linux|bsd/ raise ArgumentError, "Unable to detect operating system from #{RUBY_PLATFORM}" end end end
Version data entries
5 entries across 5 versions & 1 rubygems