From 5d67de54b3738a7b8e91ee51228633cdacd5ec04 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 26 Jun 2015 14:05:23 -0400 Subject: [PATCH] Do not raise error when Gemfile does not exist This is to allow user to run `appraisal help` to get the help message. Note that there is no test for this, as it's impossible to trick Bundler to run the executable without a Gemfile. I tested it locally and it works, so that has to be enough. Fix #98 --- lib/appraisal/gemfile.rb | 4 +++- spec/appraisal/file_spec.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/appraisal/gemfile.rb b/lib/appraisal/gemfile.rb index 0c41e508..b24116ff 100644 --- a/lib/appraisal/gemfile.rb +++ b/lib/appraisal/gemfile.rb @@ -10,7 +10,9 @@ module Appraisal # Load bundler Gemfiles and merge dependencies class Gemfile < BundlerDSL def load(path) - run(IO.read(path)) + if ::File.exist?(path) + run(IO.read(path)) + end end def run(definitions) diff --git a/spec/appraisal/file_spec.rb b/spec/appraisal/file_spec.rb index f99f7863..585a07dc 100644 --- a/spec/appraisal/file_spec.rb +++ b/spec/appraisal/file_spec.rb @@ -7,6 +7,7 @@ describe Appraisal::File do it "complains when no Appraisals file is found" do + allow(::File).to receive(:exist?).with(/Gemfile/).and_return(true) allow(::File).to receive(:exist?).with("Appraisals").and_return(false) expect { described_class.new }.to raise_error(Appraisal::AppraisalsNotFound) end