Skip to content

Instantly share code, notes, and snippets.

@yohm
Created September 14, 2011 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohm/1216219 to your computer and use it in GitHub Desktop.
Save yohm/1216219 to your computer and use it in GitHub Desktop.
require 'rspec'
# ------- OK case ----------
describe "env X=1" do
before(:all) do
ENV['X'] = '1'
end
after(:all) do
ENV.clear
end
it "find an ENV" do
ENV['X'].should == '1'
end
end
# ------- NG case ----------
def describe_env( env, val)
describe "env #{env}=#{val}" do
before(:all) do
ENV[env] = val
end
after(:all) do
ENV.clear
end
yield
end
end
describe_env( 'X', '1') do
it "find an ENV" do
ENV['X'].should == '1'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment