Trying to solve this problem in my unit tests: ```...
# bolt
y
Trying to solve this problem in my unit tests:
Copy code
Puppet::Pops::Types::TypeAssertionError(value returned from function '<...>' has wrong type, references an unresolved type 'Result')
. I’m testing a Ruby function that returns a Bolt::Result. As I see here e.g. here and here no magic is required.. so
return_type 'Result'
should just work. Though it doesn’t work in my PDK-managed Bolt module repo somehow.. 🤔
1
@Cas Donoghue sorry for poking you but it blocks my work now 🙂 Do you have any idea what can be missing?
The only difference is that I’m using (PDK default) RSpec mocks, not Mocha mocks as in the Bolt repo
hmm.. it seems because
compiler
object doesn’t have the Bolt datatypes in the RSpec somehow.. 🤔
well.. boltlib tests are good because they have all the datatypes just in
lib/puppet/datatypes
it seems.. tests fails when running out of tree
the solution is:
Copy code
include BoltSpec::BoltContext

  around(:each) do |example|
    in_bolt_context do
      example.run
    end
  end
also
require 'bolt_spec/bolt_context'
c
y
yay! actually I started to think about including the boltlib reference to the .fixtures.yaml 😄 but somehow I accidentally had a look into this file: https://github.com/puppetlabs/bolt/blob/main/lib/bolt_spec/bolt_context.rb