Skip to content

Commit

Permalink
Merge 011228f into 23257c3
Browse files Browse the repository at this point in the history
  • Loading branch information
hartmantis committed Nov 10, 2015
2 parents 23257c3 + 011228f commit 0f41162
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 158 deletions.
3 changes: 3 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
source 'https://supermarket.chef.io'

metadata

cookbook 'microsoft_remote_desktop_app_test',
path: 'spec/support/cookbooks/microsoft_remote_desktop_app_test'
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Microsoft Remote Desktop Cookbook CHANGELOG
v?.?.? (????-??-??)
-------------------
- Update the pinned version of `mac-app-store`
- Update to Chef 12.5-style custom resources (breaking compatibility with Chef
< 12.5)

v0.1.0 (2015-04-20)
-------------------
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This cookbook offers a recipe-based and a resource-based install. Use of the
resource requires that you open a `mac_app_store` resource prior in your Chef
run.

As of version 1.0.0, this cookbook requires Chef 12.5 or newer.

Usage
=====

Expand Down
26 changes: 0 additions & 26 deletions libraries/provider_mapping.rb

This file was deleted.

23 changes: 13 additions & 10 deletions libraries/resource_microsoft_remote_desktop_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@
# limitations under the License.
#

require 'chef/resource'

class Chef
class Resource
# A Chef resource for the Microsoft Remote Desktop app.
#
# @author Jonathan Hartman <j@p4nt5.com>
class MicrosoftRemoteDesktopApp < MacAppStoreApp
self.resource_name = :microsoft_remote_desktop_app
class MicrosoftRemoteDesktopApp < Resource
provides :microsoft_remote_desktop_app, platform_family: 'mac_os_x'

#
# Overload the app name with the one for this app.
#
attribute :app_name, kind_of: String, default: 'Microsoft Remote Desktop'
Chef::Resource::MacAppStoreApp.allowed_actions.each do |a|
action a do
include_recipe 'mac-app-store' unless a == :nothing

#
# Overload the bundle ID with the one for this app
#
attribute :bundle_id, kind_of: String, default: 'com.microsoft.rdc.mac'
mac_app_store_app 'Microsoft Remote Desktop' do
bundle_id 'com.microsoft.rdc.mac'
action a
end
end
end
end
end
end
28 changes: 0 additions & 28 deletions spec/libraries/provider_mapping_spec.rb

This file was deleted.

27 changes: 0 additions & 27 deletions spec/libraries/resource_microsoft_remote_desktop_app_spec.rb

This file was deleted.

30 changes: 30 additions & 0 deletions spec/resources/microsoft_remote_desktop_app/mac_os_x/10_10_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative '../../../spec_helper'

describe 'resource_microsoft_remote_desktop_app::mac_os_x::10_10' do
let(:action) { nil }
let(:runner) do
ChefSpec::SoloRunner.new(step_into: 'microsoft_remote_desktop_app',
platform: 'mac_os_x',
version: '10.10')
end
let(:chef_run) do
runner.converge("microsoft_remote_desktop_app_test::#{action}")
end

context 'the default action (:install)' do
let(:action) { :default }

it 'configures the Mac App Store' do
expect(chef_run).to include_recipe 'mac-app-store'
end

it 'installs the Microsoft Remote Desktop app' do
expect(chef_run).to install_microsoft_remote_desktop_app('default')
end

it 'installs via the App Store' do
expect(chef_run).to install_mac_app_store_app('Microsoft Remote Desktop')
.with(bundle_id: 'com.microsoft.rdc.mac')
end
end
end
38 changes: 2 additions & 36 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'chef'
require 'chefspec'
require 'chefspec/berkshelf'
require 'json'
require 'tempfile'
require 'simplecov'
Expand All @@ -10,52 +11,17 @@
require 'tmpdir'
require 'fileutils'
require_relative '../libraries/matchers'
require_relative 'support/resource/mac_app_store_app'
require_relative 'support/provider/mac_app_store_app'

RSpec.configure do |c|
c.color = true

c.before(:suite) do
COOKBOOK_PATH = Dir.mktmpdir('chefspec')
metadata = Chef::Cookbook::Metadata.new
metadata.from_file(File.expand_path('../../metadata.rb', __FILE__))
link_path = File.join(COOKBOOK_PATH, metadata.name)
FileUtils.ln_s(File.expand_path('../..', __FILE__), link_path)
c.cookbook_path = COOKBOOK_PATH
end

c.before(:each) do
# Don't worry about external cookbook dependencies
allow_any_instance_of(Chef::Cookbook::Metadata).to receive(:depends)

# Prep lookup() for the stubs below
allow_any_instance_of(Chef::ResourceCollection).to receive(:lookup)
.and_call_original

# Test each recipe in isolation, regardless of includes
@included_recipes = []
allow_any_instance_of(Chef::RunContext).to receive(:loaded_recipe?)
.and_return(false)
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe) do |_, i|
allow_any_instance_of(Chef::RunContext).to receive(:loaded_recipe?)
.with(i)
.and_return(true)
@included_recipes << i
end
allow_any_instance_of(Chef::RunContext).to receive(:loaded_recipes)
.and_return(@included_recipes)
end

c.after(:suite) { FileUtils.rm_r(COOKBOOK_PATH) }
end

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
Coveralls::SimpleCov::Formatter,
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console
]
SimpleCov.minimum_coverage 90
SimpleCov.minimum_coverage(100)
SimpleCov.start

at_exit { ChefSpec::Coverage.report! }
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Encoding: UTF-8
#
# rubocop:disable SingleSpaceBeforeFirstArg
name 'microsoft_remote_desktop_app_test'
maintainer 'Jonathan Hartman'
maintainer_email 'j@p4nt5.com'
license 'apache2'
description 'microsoft_remote_desktop_app resource test wrapper'
long_description 'microsoft_remote_desktop_app resource test wrapper'
version '0.0.1'

depends 'microsoft-remote-desktop'

supports 'mac_os_x'
# rubocop:enable SingleSpaceBeforeFirstArg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Encoding: UTF-8

microsoft_remote_desktop_app 'default'
13 changes: 0 additions & 13 deletions spec/support/provider/mac_app_store_app.rb

This file was deleted.

18 changes: 0 additions & 18 deletions spec/support/resource/mac_app_store_app.rb

This file was deleted.

0 comments on commit 0f41162

Please sign in to comment.