Sha256: 7d79ed6c484af283c977f99a88c83ac4a42b64657762c15275b018284684b2ca

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

module WatiRspec
  # class for common functionality
  class Util
    @@ui_test_common_dir = "ui-test-common"

    class << self

      # loads ui-test-common/environment.rb
      #
      # ui-test-common has to be located at some higher level within directory
      # structure compared to project/ui-test directory
      def load_common
        dir = common_dir
        puts "Loading ui-test-common from #{dir}..."
        require File.join(dir, "environment.rb")
      end

      private

      def common_dir
        Dir.chdir("..") do
          dirs = Dir.entries(Dir.pwd).find_all {|entry| File.directory?(entry)}
          if dirs.include?(@@ui_test_common_dir) && File.exists?(@@ui_test_common_dir + "/environment.rb")
            File.join(Dir.pwd, @@ui_test_common_dir)
          elsif dirs.include?("..")
            common_dir
          else
            raise "#{@@ui_test_common_dir} directory was not found! It has to exist somewhere higher in directory tree than your project's directory and it has to have environment.rb file in it!"
          end
        end
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
watirspec-0.1.9.1 lib/watirspec/util.rb
watirspec-0.1.8 lib/watirspec/util.rb
watirspec-0.1.7 lib/watirspec/util.rb
watirspec-0.1.6 lib/watirspec/util.rb
watirspec-0.1.5 lib/watirspec/util.rb
watirspec-0.1.4 lib/watirspec/util.rb
watirspec-0.1.3 lib/watirspec/util.rb
watirspec-0.1.2 lib/watirspec/util.rb
watirspec-0.1.1 lib/watirspec/util.rb
watirspec-0.1.0 lib/watirspec/util.rb