Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.27 KB | None | 0 0
  1. #----- libraries/helpers.rb -----
  2. module Creatures
  3.     class Animal
  4.         def initialize()
  5.             print("Animal initialization run\n")
  6.             print(getInfo())
  7.         end
  8.        
  9.         def getInfo()
  10.             return "Animal information returned\n"
  11.         end
  12.     end
  13. end
  14. #----- EOF -----
  15.  
  16.  
  17.  
  18. #----- recipes/default.rb -----
  19. require_relative '../libraries/helpers'
  20. a = Creatures::Animal.new()
  21. #----- EOF -----
  22.  
  23.  
  24.  
  25. #----- spec/spec_helper.rb
  26. require 'chefspec'
  27. require_relative '../libraries/helpers'
  28. #----- EOF -----
  29.  
  30.  
  31.  
  32. #----- spec/default_spec.rb
  33. require 'spec_helper'
  34.  
  35. describe 'stubwork::default' do
  36.     before do
  37.         allow_any_instance_of(Creatures::Animal)
  38.             .to receive(:getInfo)
  39.             .and_return("Fake information returned")
  40.     end
  41.    
  42.     let(:chef_run) do
  43.         ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe)
  44.     end
  45.  
  46.     it 'runs successfully' do
  47.         expect{chef_run}.to_not raise_error
  48.     end
  49. end
  50. #----- EOF -----
  51.  
  52.  
  53.  
  54. #----- CONSOLE RUN -----
  55. $ rspec --color --tty spec/default_spec.rb
  56. Animal initialization run
  57. Animal information returned
  58. .
  59.  
  60. Finished in 2.18 seconds (files took 5.02 seconds to load)
  61. 1 example, 0 failures
  62. #----- EOF -----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement