You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, it seems that in order to run rspec-puppet tests, i need to be outside of the spec directory. When I'm running rspec from within the spec directory (./spec, ./spec/classes, etc), I get errors like these:
Failure/Error: it { is_expected.to compile }
NameError:
undefined local variable or method `compile'
I've tried to look through the code to understand why but wasn't very successful.
The text was updated successfully, but these errors were encountered:
Hi @gerases, this is an expected behaviour from rspec-core itself. RSpec assumes that you're running your tests from the root directory of your project and automatically adds the lib and spec directories to the Ruby load path.
I'm guessing to get the output above you commented out the require 'spec_helper' line at the top of your spec file? Otherwise I would have expected you to get output like
semirhage :0: puppetlabs-motd/spec (git:master → upstream)$ bundle exec rspec classes/motd_spec.rb
An error occurred while loading ./classes/motd_spec.rb.
Failure/Error: require 'spec_helper'
LoadError:
cannot load such file -- spec_helper
# ./classes/motd_spec.rb:1:in `require'
# ./classes/motd_spec.rb:1:in `<top (required)>'
No examples found.
It is possible to work around this behaviour and I can help walk you through if you want, it but it's not really worth it in my opinion when it's easy enough to just run the tests from the project root.
Hi @rodjek, I include rspec_helper using include_relative and it's found ok. So the issue I'm seeing is only in the puppet specific methods missing.
I would be curious about the workaround because my situation is that I have a puppet repo with multiple modules, profiles, roles, etc. It's tiresome to find the closest spec directory upward of the spec file.
I'm also working on a Vim plugin (https://github.com/gerases/vim-rspec-puppet) that will run rspec on a given spec file, but because of this peculiarity, I had to add special code to find the closest spec dir.
So, I'm just curious what the solution could be. I realize it could be too much trouble.
Hi, it seems that in order to run rspec-puppet tests, i need to be outside of the spec directory. When I'm running rspec from within the spec directory (./spec, ./spec/classes, etc), I get errors like these:
I've tried to look through the code to understand why but wasn't very successful.
The text was updated successfully, but these errors were encountered: