Skip to content

Instantly share code, notes, and snippets.

@dougneal
dougneal / gist:cad41d0e4066a151de11
Created February 26, 2016 12:14
rspec: socket mocking
socket = class_double(TCPSocket)
expect(socket).to receive(:is_a?).with(TCPSocket) { true }
expect(TCPSocket).to receive(:new) { socket }
@dougneal
dougneal / package_spec.rb
Created January 18, 2016 15:41
Ensure that a specific provider is selected during an rspec test
# If your test depends on a specific provider being used, or a provider which has
# a specific attribute, such as versionable, the provider will fail the selection
# round if its commands aren't present on the system that the test is running on.
# For example, if running your rspec tests on your OS X development machine,
# and your manifests include :
# package { 'java':
# ensure => '1.7.0+update67'
# }
#
# The test will fail with the error: