Sha256: f383e75dd4f0e4517464e9ea7970c0b4f23125c0c274b894b5b641a57857b7c9

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

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-1.4.3 spec/util_spec.rb
watirsplash-1.4.2 spec/util_spec.rb
watirsplash-1.4.1 spec/util_spec.rb
watirsplash-1.4.0 spec/util_spec.rb
watirsplash-1.3.0 spec/util_spec.rb
watirsplash-1.2.1 spec/util_spec.rb
watirsplash-1.2.0 spec/util_spec.rb
watirsplash-1.1.2 spec/util_spec.rb
watirsplash-1.1.1 spec/util_spec.rb
watirsplash-1.1.0 spec/util_spec.rb
watirsplash-1.0.0 spec/util_spec.rb