Thanks for tracking this down. Do you think you could try this alternate patch and let me know if it works?
- dir = File.dirname(Rake.application.rakefile_location)
+ dir = caller.find{|c| /Rakefile:/}[/^(.*?)\/Rakefile:/, 1]
— Andre
That's a good point. We'll probably have to come up with an approach that combines both options.
> If I wanted to write various testcases, for example test with various Rakefile names, how would I do this in Bundler? The only Ruby-related testing I've done is with Cucumber (the reason I'm using Bundler in the first place).
Bundler has a somewhat... idiosyncratic test setup. The tests for the GemHelper class are located in bundler/spec/other/gem_helper_spec.rb. I would be happy to include testcases for this if you feel like writing them. :)
— Andre
Bundler's tests are generally written integration-style, so I imagine you could try setting up a test directory with a rakefile, and then execute `rake -T` and validate the output to determine whether the test passed or failed. If you have more questions, feel free to email me directly or visit #bundler on irc.freenode.net. I'm there at some point on most days.
— Andre
— Andre
--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To post to this group, send email to ruby-b...@googlegroups.com.
To unsubscribe from this group, send email to ruby-bundler...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ruby-bundler?hl=en.
Hi Arve,
Bundler doesn't allow system gems to be used inside tests. However, it sets up its own pretend system gems repository that you can use while the tests run. As you can see in spec/support/rubygems_ext.rb, the rake gem is included in that list.
In order to use the rake gem in your tests, I think you can do something like this:
describe "the bundler gem helper rake tasks" do
before(:each) do
install_gemfile <<-G
gem "rake"
G
end
it "should work with rake" do
bundle "gem foo"
Dir.chdir(bundled_app("foo")) do
`rake build`.should == "Gem built"
end
end
end
I haven't tested that, so it's probably not completely right, but that should be the right general idea.
— Andre
The latter. The tests provide a helper method called ruby(), defined in the same file as sys_exec(), that sets up the bundled environment and then runs a ruby interpreter to execute whatever ruby code you pass as the arguments. Give that a shot?
— Andre
Bundler disables rubygems and the gem method. You just need to ruby("require 'rake'; puts Rake") or whatever.
— Andre