|
218 | 218 | expect(data["load_paths"][plugin_name]).to eq([File.join(plugin_name, "lib")]) |
219 | 219 | end |
220 | 220 |
|
221 | | - it "expands relative paths when the plugin root changes" do |
222 | | - old_index_file = index.index_file |
| 221 | + it "expands relative paths to absolute on load" do |
| 222 | + require_relative "../../../bundler/lib/bundler/yaml_serializer" |
223 | 223 |
|
224 | | - new_root = tmp.join("moved_plugin_root") |
225 | | - FileUtils.mkdir_p(new_root) |
226 | | - FileUtils.cp(old_index_file, new_root.join("index")) |
| 224 | + plugin_root = Bundler::Plugin.root |
227 | 225 |
|
228 | | - Bundler::Plugin.reset! |
229 | | - Bundler::Plugin.instance_variable_set(:@root, nil) |
230 | | - allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) |
231 | | - allow(Bundler::Plugin).to receive(:root).and_return(new_root) |
232 | | - allow(Bundler::Plugin).to receive(:local_root).and_return(new_root) |
| 226 | + relative_index = { |
| 227 | + "commands" => {}, |
| 228 | + "hooks" => {}, |
| 229 | + "load_paths" => { plugin_name => [File.join(plugin_name, "lib")] }, |
| 230 | + "plugin_paths" => { plugin_name => plugin_name }, |
| 231 | + "sources" => {}, |
| 232 | + } |
233 | 233 |
|
234 | | - new_index = Index.new |
| 234 | + File.open(index.index_file, "w") {|f| f.puts Bundler::YAMLSerializer.dump(relative_index) } |
235 | 235 |
|
236 | | - expect(new_index.plugin_path(plugin_name)).to eq(new_root.join(plugin_name)) |
237 | | - expect(new_index.load_paths(plugin_name)).to eq([new_root.join(plugin_name, "lib").to_s]) |
| 236 | + new_index = Index.new |
| 237 | + expect(new_index.plugin_path(plugin_name)).to eq(plugin_root.join(plugin_name)) |
| 238 | + expect(new_index.load_paths(plugin_name)).to eq([plugin_root.join(plugin_name, "lib").to_s]) |
238 | 239 | end |
239 | 240 |
|
240 | 241 | it "keeps paths outside the plugin root as absolute" do |
|
0 commit comments