<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'spec_helper'

describe "Chef::Platform supports" do
  [
    :mac_os_x,
    :mac_os_x_server,
    :freebsd,
    :ubuntu,
    :debian,
    :centos,
    :fedora,
    :suse,
    :redhat,
    :oracle,
    :gentoo,
    :arch, 
    :solaris,
    :mswin,
    :mingw32,
    :windows,
    :gcel
  ].each do |platform|
    it "#{platform}" do
      Chef::Platform.platforms.should have_key(platform)
    end
  end
end

describe Chef::Platform do

  before :all do
    @original_platform_map = Chef::Platform.platforms
  end
  
  after :all do ||
    Chef::Platform.platforms = @original_platform_map
  end
  
  before(:each) do
    Chef::Platform.platforms = {
      :darwin => {
        ">= 10.11" => {
          :file => "new_darwinian"
        },
        "9.2.2" => {
          :file => "darwinian",
          :else => "thing"
        },
        :default => {
          :file => "old school",
          :snicker => "snack"
        }
      },
      :mars_volta => {
      },
      :default => {
        :file => Chef::Provider::File,
        :pax => "brittania",
        :cat => "nice"
      }
    }
    @events = Chef::EventDispatch::Dispatcher.new
  end
  
  it "should allow you to look up a platform by name and version, returning the provider map for it" do
    pmap = Chef::Platform.find("Darwin", "9.2.2")
    pmap.should be_a_kind_of(Hash)
    pmap[:file].should eql("darwinian")
  end
  
  it "should allow you to look up a platform by name and version using \"greater than\" style comparators" do
    pmap = Chef::Platform.find("Darwin", "11.1.0")
    pmap.should be_a_kind_of(Hash)
    pmap[:file].should eql("new_darwinian")
  end

  it "should use the default providers for an os if the specific version does not exist" do
    pmap = Chef::Platform.find("Darwin", "1")<commit_msg>[CHEF-3919] platform_spec s/comparator/operator/<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'spec_helper'

describe "Chef::Platform supports" do
  [
    :mac_os_x,
    :mac_os_x_server,
    :freebsd,
    :ubuntu,
    :debian,
    :centos,
    :fedora,
    :suse,
    :redhat,
    :oracle,
    :gentoo,
    :arch, 
    :solaris,
    :mswin,
    :mingw32,
    :windows,
    :gcel
  ].each do |platform|
    it "#{platform}" do
      Chef::Platform.platforms.should have_key(platform)
    end
  end
end

describe Chef::Platform do

  before :all do
    @original_platform_map = Chef::Platform.platforms
  end
  
  after :all do ||
    Chef::Platform.platforms = @original_platform_map
  end
  
  before(:each) do
    Chef::Platform.platforms = {
      :darwin => {
        ">= 10.11" => {
          :file => "new_darwinian"
        },
        "9.2.2" => {
          :file => "darwinian",
          :else => "thing"
        },
        :default => {
          :file => "old school",
          :snicker => "snack"
        }
      },
      :mars_volta => {
      },
      :default => {
        :file => Chef::Provider::File,
        :pax => "brittania",
        :cat => "nice"
      }
    }
    @events = Chef::EventDispatch::Dispatcher.new
  end
  
  it "should allow you to look up a platform by name and version, returning the provider map for it" do
    pmap = Chef::Platform.find("Darwin", "9.2.2")
    pmap.should be_a_kind_of(Hash)
    pmap[:file].should eql("darwinian")
  end
  
  it "should allow you to look up a platform by name and version using \"greater than\" style operators" do
    pmap = Chef::Platform.find("Darwin", "11.1.0")
    pmap.should be_a_kind_of(Hash)
    pmap[:file].should eql("new_darwinian")
  end

  it "should use the default providers for an os if the specific version does not exist" do
    pmap = Chef::Platform.find("Darwin", "1")
{'fraction_non_alphanumeric': 0.12467428342353178, 'fraction_numerical': 0.011625576267789137, 'mean_word_length': 2.6718175128771153, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3190265', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1619, 'n_words': 493}