[rspec-users] How to specify current directory for specs?

Daniel Lidström dlidstrom at gmail.com
Fri Nov 12 05:48:13 EST 2010


On 10 Nov, 22:50, Rhett Sutphin <rh... at detailedbalance.net> wrote:
> Hi Daniel,
>
[...]
> As an alternative, you might also consider having a helper like this:
>
> # again, in spec/spec_helper.rb
> def spec_path(path)
>   File.expand_path("../spec", __FILE__)
> end
>
> which you would use like so:
>
> book = Book.new spec_path("data/JA_s12.book")
>
> This has the benefit of being more explicit / less surprising to other developers (including your future self), since the relative path for spec execution is usually the project root.

Hi Rhett,

the above alternative looks very promising to me. Thanks for the
suggestion!

Daniel


More information about the rspec-users mailing list