Skip to content

Instantly share code, notes, and snippets.

@brianewing
Created June 8, 2013 16:47
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 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