swalberg / chef-f5

An F5 Chef cookbook to manage pools and VIPs on an F5 bigip
MIT License
5 stars 5 forks source link

fix failing tests #6

Closed davidalpert closed 7 years ago

davidalpert commented 7 years ago

Add in a missing require_relative link for gem_helper.rb (similar to those added in 2ca63b73)

Also in PR #5 ChefF5 was changed from a class name to a module name and the methods previously living in ChefF5 were moved to live inside a new class called ChefF5::Client.

This broke the mocking which was set up in the spec tests (e.g. test_create_pool_spec.rb):

      allow_any_instance_of(ChefF5).to receive(:pool_is_missing_node?).and_return(false)
      allow_any_instance_of(ChefF5).to receive(:node_is_missing?).and_return(false)
      allow_any_instance_of(ChefF5).to receive(:pool_is_missing_monitor?).and_return(false)

With those (and similar) expectations now targeting the wrong class all 7 tests were failing with errors about unmocked call chains on the doubles:

  1) f5_test::test_create_pool managing the pool the pool does not exist creates the pool
     Failure/Error: ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04', step_into: ['f5_pool']).converge(described_recipe)
       #<Double (anonymous)> received unexpected message :NodeAddressV2 with (no args)
     # ./libraries/chef_f5.rb:10:in `node_is_missing?'
     # /var/folders/q7/rcn_34yx7pvb0n7sch3flr5c0000gn/T/d20170824-38667-1n06w2a/cookbooks/f5/resources/pool.rb:21:in `block in class_from_file'
     # ./spec/unit/recipes/test_create_pool_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/unit/recipes/test_create_pool_spec.rb:41:in `block (4 levels) in <top (required)>'

This PR adjusts the mocking in the rspec contexts to correctly target the new ChefF5::Client class and all 7 specs are passing again.