Skip to content

Mock class parameter doesn't work. #8

@worapojc

Description

@worapojc

I'm using mock class feature and I found that the parameter value is not useable in the test spec.

class my_class() {
include ref_class
$my_file = "${ref_class::config_dir}/my_config.cfg"
}

here is my test code

require 'spec_helper'
require 'rspec-puppet-utils'
describe 'another_class', :type => :class do
context 'default instantiation' do
describe 'instance class' do

  let(:pre_condition) {[
    "class ref_class() { $config_dir = '/home/my_user' }",
  ]}

  it { is_expected.to contain_file('/home/my_user/my_config.cfg') }

end

end
end

Then, I executed the test and it shows File[/my_config.cfg] in untouched resources (No prefix path).

NOTES: RSpec gems in my machine.

rspec (3.3.0)
rspec-core (3.4.4, 3.3.2)
rspec-expectations (3.4.0, 3.3.1)
rspec-mocks (3.4.1, 3.3.2)
rspec-puppet (2.2.0)
rspec-puppet-utils (2.2.1)
rspec-support (3.4.1, 3.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions