Sha256: 64643f8a2703b64d24b37503e356006a0b186491b60ae1a061ebfe4c7d6a458c

Contents?: true

Size: 1.69 KB

Versions: 16

Compression:

Stored size: 1.69 KB

Contents

#include <catch.hpp>
#include <leatherman/ruby/api.hpp>
#include <leatherman/util/scoped_env.hpp>
#include <leatherman/util/environment.hpp>
#include <internal/ruby/ruby_value.hpp>
#include "../ruby_helper.hpp"
#include "../../collection_fixture.hpp"
#include "../../fixtures.hpp"

using namespace std;
using namespace facter::testing;
using namespace facter::ruby;
using namespace leatherman::ruby;
using namespace leatherman::util;

SCENARIO("Windows custom facts written in Ruby") {
    collection_fixture facts;
    REQUIRE(facts.size() == 0u);

    // Setup ruby
    auto& ruby = api::instance();
    REQUIRE(ruby.initialized());
    ruby.include_stack_trace(true);

    GIVEN("a fact that loads win32ole") {
        REQUIRE(load_custom_fact("windows/ole.rb", facts));
        THEN("the value should be in the collection") {
            REQUIRE(ruby_value_to_string(facts.get<ruby_value>("foo")) == "\"bar\"");
        }
    }
}

SCENARIO("Run command with space in path") {
    collection_fixture facts;
    REQUIRE(facts.size() == 0u);

    // Setup ruby
    auto& ruby = api::instance();
    REQUIRE(ruby.initialized());
    ruby.include_stack_trace(true);

    GIVEN("a directory with a space on the PATH") {
        string path;
        environment::get("PATH", path);
        scoped_env var("PATH", path + environment::get_path_separator() + LIBFACTER_TESTS_DIRECTORY "/fixtures/execution/with space");
        environment::reload_search_paths();
        REQUIRE(load_custom_fact("command_with_space.rb", facts));
        THEN("the command should execute successfully") {
            REQUIRE(ruby_value_to_string(facts.get<ruby_value>("foo")) == "\"bar\"");
        }
    }
    environment::reload_search_paths();
}

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/tests/ruby/windows/ruby.cc
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/tests/ruby/windows/ruby.cc