diff --git a/.gitignore b/.gitignore index 81c2534..5c5818a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ pkg/* # YARD .yardoc yardoc/ + +test/example* +.ruby-* \ No newline at end of file diff --git a/lib/simple_config.rb b/lib/simple_config.rb index 67db1c1..e72f1b0 100644 --- a/lib/simple_config.rb +++ b/lib/simple_config.rb @@ -102,7 +102,7 @@ def unset(key) # @param [Symbol] The key to check. # @return [Boolean] True if the key is set. def exists?(key) - @settings.key?(key) + @settings.key?(key) || @groups.key?(key) end def set?(key) diff --git a/test/simple_config_test.rb b/test/simple_config_test.rb index 9e4ad53..4dc5028 100644 --- a/test/simple_config_test.rb +++ b/test/simple_config_test.rb @@ -57,6 +57,11 @@ def test_exists_should_return_whether_variable_isset assert(@config.exists?(:foo)) @config.unset(:foo) assert(!@config.exists?(:foo)) + @config.group(:bats) do + set :foo, 'bar' + end + assert(@config.exists?(:bats)) + assert(@config.bats.exists?(:foo)) end def test_exists_should_consider_empty_values_as_set @@ -103,7 +108,7 @@ def test_should_load_and_parse_external_config_as_ruby_in_context_of_config_inst @config.load('external_config.rb') end - def test_should_laod_and_parse_external_config_as_yaml_in_context_of_config_instance + def test_should_load_and_parse_external_config_as_yaml_in_context_of_config_instance parser = stub('YAMLParser') SimpleConfig::YAMLParser.stubs(:parse_contents_of_file).with('external_config.yml').returns(parser) parser.expects(:parse_into).with(@config)