Skip to content

Instantly share code, notes, and snippets.

@brianewing
Created June 8, 2013 16:47
Show Gist options
  • Save brianewing/5735832 to your computer and use it in GitHub Desktop.
Save brianewing/5735832 to your computer and use it in GitHub Desktop.
RSpec testing the parsing of various YML config options taking advantage of Ruby heredoc syntax with a block
# helper
def with_stubbed_yml_config(yml, &block)
# stub, yield, unstub
end
# in examples..
with_stubbed_yml_config(<<-YML) { url.should == 'http://test:5984' }
test:
:host: test
YML
with_stubbed_yml_config(<<-YML) { url.should == 'https://foo:bar@test:5984' }
test:
:host: test
:port: 5984
:ssl: true
:username: foo
:password: bar
YML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment