Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Pelusa::Configuration#present?

  • Loading branch information...
commit 5ae37c271f7c186d59de3e63d0e0b7e70212ad39 1 parent fadc801
@solnic solnic authored
Showing with 19 additions and 1 deletion.
  1. +8 −1 lib/pelusa/configuration.rb
  2. +11 −0 test/pelusa/configuration_test.rb
View
9 lib/pelusa/configuration.rb
@@ -11,7 +11,14 @@ class Configuration
#
# @api public
def initialize(yaml_path = YAML_PATH)
- @_configuration = YAML.load_file(yaml_path).freeze
+ if File.exist?(yaml_path)
+ @_configuration = YAML.load_file(yaml_path).freeze
+ end
+ end
+
+ # @api public
+ def present?
+ not @_configuration.nil?
end
# @api public
View
11 test/pelusa/configuration_test.rb
@@ -6,6 +6,17 @@ module Pelusa
Pelusa::Configuration.new("#{FIXTURES_PATH}/sample_config_one.yml")
end
+ describe "#present?" do
+ it "returns false when configuration doesn't file exists" do
+ configuration = Pelusa::Configuration.new("#{FIXTURES_PATH}/not_here.yml")
+ configuration.present?.must_equal(false)
+ end
+
+ it "returns false when configuration file exists" do
+ configuration.present?.must_equal(true)
+ end
+ end
+
describe '#sources' do
it 'returns path to sources' do
configuration.sources.must_equal 'lib/**/*.rb'
Please sign in to comment.
Something went wrong with that request. Please try again.