Sha256: bed31d198d4ed994f880953064e7d17e5ebdd633780d120fde6f29091ba9fae1

Contents?: true

Size: 1.65 KB

Versions: 11

Compression:

Stored size: 1.65 KB

Contents

require "spec"

describe WatirSplash::Util do

  it "loads ui-test-common" do
    ui_test_common_dir = "../ui-test-common"
    raise "ui-test-common directory should not exist due to testing!" if File.exists?(ui_test_common_dir)
    begin
      FileUtils.mkdir(ui_test_common_dir)
      File.open(File.join(ui_test_common_dir, "environment.rb"), "w") do |f|
        f.puts "
module GlobalApplication
  LOADED = true
end"
      end

      lambda {GlobalApplication::LOADED}.should raise_exception
      lambda {WatirSplash::Util.load_common}.should_not raise_exception
      GlobalApplication::LOADED.should be_true
    ensure
      FileUtils.rm_rf(ui_test_common_dir)
    end
  end

  it "raises exception if ui-test-common is not found" do
    lambda {WatirSplash::Util.load_common}.
            should raise_exception(RuntimeError,
                                   "ui-test-common 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

  it "loads project's environment.rb automatically" do
    env_file = "../environment.rb"
    raise "environment.rb file should not exist due to testing!" if File.exists?(env_file)
    begin
      File.open(env_file, "w") do |file|
        file.puts "
module GlobalApplication
  ENVIRONMENT_LOADED = true
end"
      end

      lambda {GlobalApplication::ENVIRONMENT_LOADED}.should raise_exception
      lambda {WatirSplash::Util.load_environment}.should_not raise_exception
      GlobalApplication::ENVIRONMENT_LOADED.should be_true
    ensure
      FileUtils.rm_rf(env_file)
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
watirsplash-0.2.14 spec/util_spec.rb
watirsplash-0.2.12 spec/util_spec.rb
watirsplash-0.2.11 spec/util_spec.rb
watirsplash-0.2.10 spec/util_spec.rb
watirsplash-0.2.9 spec/util_spec.rb
watirsplash-0.2.8 spec/util_spec.rb
watirsplash-0.2.7 spec/util_spec.rb
watirsplash-0.2.6 spec/util_spec.rb
watirsplash-0.2.5 spec/util_spec.rb
watirsplash-0.2.4 spec/util_spec.rb
watirsplash-0.2.3 spec/util_spec.rb