Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #----- libraries/helpers.rb -----
- module Creatures
- class Animal
- def initialize()
- print("Animal initialization run\n")
- print(getInfo())
- end
- def getInfo()
- return "Animal information returned\n"
- end
- end
- end
- #----- EOF -----
- #----- recipes/default.rb -----
- require_relative '../libraries/helpers'
- a = Creatures::Animal.new()
- #----- EOF -----
- #----- spec/spec_helper.rb
- require 'chefspec'
- require_relative '../libraries/helpers'
- #----- EOF -----
- #----- spec/default_spec.rb
- require 'spec_helper'
- describe 'stubwork::default' do
- before do
- allow_any_instance_of(Creatures::Animal)
- .to receive(:getInfo)
- .and_return("Fake information returned")
- end
- let(:chef_run) do
- ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe)
- end
- it 'runs successfully' do
- expect{chef_run}.to_not raise_error
- end
- end
- #----- EOF -----
- #----- CONSOLE RUN -----
- $ rspec --color --tty spec/default_spec.rb
- Animal initialization run
- Animal information returned
- .
- Finished in 2.18 seconds (files took 5.02 seconds to load)
- 1 example, 0 failures
- #----- EOF -----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement