Skip to content

Commit

Permalink
Rename Changit::ConfigLoader to ConfigReader
Browse files Browse the repository at this point in the history
  • Loading branch information
aonemd committed Nov 27, 2016
1 parent 2f16924 commit 3a53aef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/changit/config_loader.rb → lib/changit/config_reader.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Changit
class ConfigLoader
class ConfigReader
DEFAULT_SEARCH_PATH = "#{Dir.pwd}/.gitconfig".freeze

attr_reader :search_path
Expand All @@ -10,7 +10,7 @@ def initialize(search_path: DEFAULT_SEARCH_PATH)
freeze
end

def load
def read
search_result = Dir.glob(@search_path)

if search_result.empty?
Expand Down
18 changes: 9 additions & 9 deletions test/config_loader_test.rb → test/config_reader_test.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
require 'test_helper'
require 'changit/config_loader'
require 'changit/config_reader'
require 'tempfile'

class ConfigLoaderTest < Minitest::Test
def test_load
class ConfigReaderTest < Minitest::Test
def test_read
file_contents = "[user]\n\tname = testname\n\temail = [email protected]\n[core]\n\teditor = vim\n[color]\n\tui = true\n[rebase]\n\tautosquash = true\n".freeze

Tempfile.open('.gitconfig') do |f|
f.write file_contents
f.close

assert Changit::ConfigLoader.new(search_path: f).load == file_contents
assert Changit::ConfigReader.new(search_path: f).read == file_contents
end
end

def test_load_file_not_found
assert_raises(RuntimeError, "File #{config_loader.search_path} not found.") do
config_loader.load
def test_read_file_not_found
assert_raises(RuntimeError, "File #{config_reader.search_path} not found.") do
config_reader.read
end
end

private

def config_loader
Changit::ConfigLoader.new
def config_reader
Changit::ConfigReader.new
end
end

0 comments on commit 3a53aef

Please sign in to comment.