Permalink
Browse files

Add tests to @AndrewVos's pull request

  • Loading branch information...
1 parent ad292c4 commit cea19c705a4ca50727a8d3f700d4efb99f4ac22e @mattwynne mattwynne committed Oct 9, 2011
Showing with 20 additions and 2 deletions.
  1. +1 −1 lib/relish.rb
  2. +19 −1 spec/relish_spec.rb
View
@@ -14,7 +14,7 @@ def #{name} # def global_options_file
}
end
- setting :global_options_file, File.join(File.expand_path('~'), '.relish') rescue "~/.relish"
+ setting :global_options_file, (File.join(File.expand_path('~'), '.relish') rescue '~/.relish')
setting :local_options_file, '.relish'
setting :default_host, 'api.relishapp.com'
setting :default_ssl, 'on'
View
@@ -1,10 +1,28 @@
require 'spec_helper'
describe Relish do
+
it "has a .global_options_file setting" do
Relish.global_options_file.should_not be_nil
end
-
+
+ context "when $HOME is not set" do
+ before do
+ @original_home = ENV['HOME']
+ ENV['HOME'] = nil
+ Object.send(:remove_const, :Relish)
@AndrewVos
AndrewVos Oct 9, 2011

Does this undefine the Relish module?

@mattwynne
mattwynne Oct 9, 2011 collaborator

Yep. It's the only way I could figure out to run that code again. There's something wrong with the design if it's this hard to test, of course, but I'll have to fix that some other time.

+ load 'lib/relish.rb'
+ end
+
+ after do
+ ENV['HOME'] = @original_home
+ end
+
+ it "still returns the global_options file setting" do
+ Relish.global_options_file.should_not be_nil
+ end
+ end
+
it "allows global_options_file to be overwritten" do
Relish.global_options_file = 'foo'
Relish.global_options_file.should == 'foo'

1 comment on commit cea19c7

@AndrewVos

Very cool.

Please sign in to comment.