Skip to content

Commit

Permalink
Don't use Ruby keyword as method name
Browse files Browse the repository at this point in the history
Possible fix to #63.
  • Loading branch information
sferik committed Aug 14, 2012
1 parent 9feac67 commit 9227bd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions lib/t/rcfile.rb
Expand Up @@ -2,14 +2,13 @@

module T
class RCFile
FILE_NAME = '.trc'
attr_reader :path

include Singleton
attr_reader :path
FILE_NAME = '.trc'

def initialize
@path = File.join(File.expand_path("~"), FILE_NAME)
@data = load
@data = load_file
end

def [](username)
Expand Down Expand Up @@ -59,7 +58,7 @@ def empty?
@data == default_structure
end

def load
def load_file
require 'yaml'
YAML.load_file(@path)
rescue Errno::ENOENT
Expand All @@ -68,7 +67,7 @@ def load

def path=(path)
@path = path
@data = load
@data = load_file
@path
end

Expand Down
6 changes: 3 additions & 3 deletions spec/rcfile_spec.rb
Expand Up @@ -160,19 +160,19 @@
end
end

describe '#load' do
describe '#load_file' do
context 'when file exists at path' do
it 'should load data from file' do
rcfile = T::RCFile.instance
rcfile.path = fixture_path + "/.trc"
rcfile.load['profiles']['testcli']['abc123']['username'].should == 'testcli'
rcfile.load_file['profiles']['testcli']['abc123']['username'].should == 'testcli'
end
end
context 'when file does not exist at path' do
it 'should load default structure' do
rcfile = T::RCFile.instance
rcfile.path = File.expand_path('../fixtures/foo', __FILE__)
rcfile.load.keys.sort.should == ['configuration', 'profiles']
rcfile.load_file.keys.sort.should == ['configuration', 'profiles']
end
end
end
Expand Down

0 comments on commit 9227bd4

Please sign in to comment.