Skip to content

Commit

Permalink
add an rc file
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed Mar 21, 2012
1 parent 08ace2d commit b4c952a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/urls/runner.rb
@@ -1,5 +1,6 @@
require 'urls'
require 'boson/runner'
ENV['BOSONRC'] = ENV['URLS_RC'] || '~/.urlsrc'

module Urls
class Runner < Boson::Runner
Expand Down
17 changes: 17 additions & 0 deletions spec/helper.rb
Expand Up @@ -5,13 +5,30 @@
require 'bahia'

ENV['URLS_HOME'] = File.dirname(__FILE__) + '/.urls'
ENV['URLS_RC'] = File.dirname(__FILE__) + '/.urlsrc'
ENV['TAG_HOME'] = File.dirname(__FILE__) + '/.tag'

module TestHelpers
# rc file for executables
def with_rc(body)
old = ENV['URLS_RC']
ENV['URLS_RC'] = File.dirname(__FILE__) + '/.urlsrc.temp'
File.open(ENV['URLS_RC'], 'w') {|f| f.write body }

yield

FileUtils.rm_f ENV['URLS_RC']
ENV['URLS_RC'] = old
end
end

class MiniTest::Unit::TestCase
include Bahia
include TestHelpers
end

MiniTest::Unit.after_tests do
FileUtils.rm_rf(ENV['URLS_HOME'])
FileUtils.rm_rf(ENV['TAG_HOME'])
FileUtils.rm_f(ENV['URLS_RC'])
end
9 changes: 9 additions & 0 deletions spec/runner_spec.rb
Expand Up @@ -62,4 +62,13 @@ def stderr
stdout.must_equal "http://dodo.com"
end
end

describe "$URLS_RC" do
it 'loads when defined' do
with_rc "puts 'RC in the house'" do
urls
stdout.must_match /RC in the house/
end
end
end
end

0 comments on commit b4c952a

Please sign in to comment.