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

tmp directory cleanup after running generator #5

Open
EppO opened this issue Oct 14, 2011 · 4 comments
Open

tmp directory cleanup after running generator #5

EppO opened this issue Oct 14, 2011 · 4 comments

Comments

@EppO
Copy link
Contributor

EppO commented Oct 14, 2011

When I run my specs on this gem, the tmp directory used to test the generator remains after spec finishes, and contains app, config and db folders, along with the files generated by the generator. I don't know if it comes from my specs code or if it's a bug.

@alexrothenberg
Copy link
Owner

Its intentional that it leaves the files there. I find it useful when something goes wrong to be able to look at the generated files to see what happened. Typically I add tmp to my .gitignore so it doesn't what gets committed. You could also add an after { delete_the_generated_stuff } to your spec if you don't want it sticking around.

@EppO
Copy link
Contributor Author

EppO commented Oct 14, 2011

I agree it's a nice feature if something goes wrong but it would be neat to just delete it if all tests pass successfully. It's not really a big deal, if you prefer to keep it in all cases, I will call the method in an after block. Can I know from rspec if the tests pass in the after block ?

@alexrothenberg
Copy link
Owner

Hmm that's an interesting idea to conditionally leave the files there when there's a failure. But I'm not sure it would give you what you want unless the failure is the last spec to run. The way it currently works doesn't leave the "bad" files around either though.

It looks like rspec does support what you'd like to do rspec/rspec-core#401. You can write

after(:each) do
  if example.exception
    prepare_destination
  end
end

This will rm_rf then do a mkdir so you'll be left with a tmp but it'll be empty.

Is your suggestion that I add something like this into ammeter so you it becomes the default behavior?

@EppO
Copy link
Contributor Author

EppO commented Oct 14, 2011

Yeah you are right, it would be only useful if you use --fail-fast option when running rspec.
I don't know if that should be the default behaviour or not for ammeter, but it would be nice if it was optional

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

2 participants