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

New Fixtures approach for better Guard support #103

Open
rauchrob opened this issue Dec 13, 2015 · 0 comments
Open

New Fixtures approach for better Guard support #103

rauchrob opened this issue Dec 13, 2015 · 0 comments

Comments

@rauchrob
Copy link
Contributor

The current support for the Guard is severely limited by statically symlinking spec/fixtures/modules/<my-module> to the project root. See here for a more detailed discussion on the problem.

For example, I would like to speed up the whole rspec-puppet workflow by using something like the following in my Guardfile:

guard :rspec, cmd: 'rspec', cmd_additional_args: '--fail-fast' do
  watch %r{^spec/classes/.*_spec\.rb$}
  watch %r{^manifests\/(.*)\.pp$} do |m|
    spec = "spec/classes/#{m[1]}_spec.rb"
    spec if File.exists? spec
  end
end

This simple example would call, e.g., rspec --fail-fast spec/classes/install_spec.rb whenever either manifests/install.pp or spec/classes/install_spec.rb changes on disk, which is kind of cool. However the problem is that guard will fail with complaining about the inifinite symlink look created by the symlink I mentioned above.

A possible approach would be to remove the symlinks stanza from .fixtures.yml and instead create these links only during the actual rspec run, for example with something like the following in spec/spec_helper.rb:

RSpec.configure do |config|
  config.before :suite do
    File.symlink('../../..', 'spec/fixtures/modules/<my-module>')
  end

  config.after :suite do
    File.delete('spec/fixtures/modules/<my-module>')
  end
end

Update: In fact, we would have to ensure there are no symlink loops in the whole project directory. Unfortunately, there are ill modules on GitHub containing such symlinks, for example puppetlabs/puppetlabs-stdlib. Thus if such ill modules are listed in .fixtures.yml we would get even more symlink loops somewhere below spec/fixtures/modules/<ill-module> after running rake spec_prep. These symlinks should probably removed upstream in the puppetlabs_spec_helper gem, where the spec_prep rake task is defined.

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

1 participant