Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:pre_condition seems to fail with anything in spec/defines #26

Closed
rtyler opened this issue Apr 15, 2012 · 1 comment
Closed

:pre_condition seems to fail with anything in spec/defines #26

rtyler opened this issue Apr 15, 2012 · 1 comment
Milestone

Comments

@rtyler
Copy link

rtyler commented Apr 15, 2012

Per the hacking on IRC, first we tried this:

describe 'haproxy::global' do
  let(:pre_condition) { '$haproxy::config_file = "some crap"' }

  # other examples down here
end

And that raised the following

  2) haproxy::global 
     Failure/Error: it { should include_class('concat::setup') }
     Puppet::Error:
       Could not parse for environment production: Cannot assign to variables in other namespaces at line 2 on node kiwi.coupleofllamas.com
     # ./spec/defines/global_spec.rb:11:in `block (2 levels) in <top (required)>'

Finished in 0.01426 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/defines/global_spec.rb:11 # haproxy::global 
rspec ./spec/defines/global_spec.rb:11 # haproxy::global 
/home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/formatters/documentation_formatter.rb:41:in `failure_output': undefined method `strip' for nil:NilClass (NoMethodError)
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/formatters/documentation_formatter.rb:37:in `example_failed'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/reporter.rb:98:in `block in notify'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/reporter.rb:97:in `each'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/reporter.rb:97:in `notify'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/reporter.rb:68:in `example_failed'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example.rb:193:in `finish'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example.rb:166:in `fail_with_exception'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example_group.rb:363:in `block in fail_filtered_examples'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example_group.rb:363:in `each'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example_group.rb:363:in `fail_filtered_examples'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example_group.rb:341:in `rescue in run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/example_group.rb:346:in `run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:28:in `map'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:28:in `block in run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/reporter.rb:34:in `report'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:25:in `run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
        from /home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Even when commenting out the actual setting of the variable, but leaving the :pre_condition block in, I receive the following error:

Failures:

  1) haproxy::global 
     Failure/Error: it { should include_class('concat::setup') }
     NoMethodError:
       undefined method `+' for nil:NilClass
     # ./spec/defines/global_spec.rb:12:in `block (2 levels) in <top (required)>'

  2) haproxy::global 
     Failure/Error: it { should include_class('concat::setup') }
     NoMethodError:
       undefined method `+' for nil:NilClass
     # ./spec/defines/global_spec.rb:12:in `block (2 levels) in <top (required)>'

Finished in 0.00408 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/defines/global_spec.rb:12 # haproxy::global 
rspec ./spec/defines/global_spec.rb:12 # haproxy::global 
/home/tyler/.rvm/gems/ruby-1.9.2-p290@puppet-haproxy/gems/rspec-core-2.9.0/lib/rspec
/core/formatters/documentation_formatter.rb:41:in `failure_output': undefined method
 `strip' for nil:NilClass (NoMethodError)

@dcarley
Copy link
Contributor

dcarley commented Apr 24, 2012

For anyone using params classes this can be worked around (hacked, at best) presently by specifying the surrounding class for the variable.

  let(:pre_condition) { 'class haproxy { $config_file = "some crap"' }

@rodjek rodjek closed this as completed in 433b303 Feb 26, 2013
ekohl pushed a commit to ekohl/rspec-puppet that referenced this issue Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants