Skip to content

Instantly share code, notes, and snippets.

@davefp
Created April 9, 2014 14:57
Show Gist options
  • Save davefp/10280008 to your computer and use it in GitHub Desktop.
Save davefp/10280008 to your computer and use it in GitHub Desktop.
How would you format this line of ruby to be more readable?
#One liner?
assert_requested(:post, url, body: hash_including({name: 'web', events: ['release'], active: true, config: {url: 'http://example.com/webhooks/release', content_type: 'json'}}))
# Params aligned with the structure they're part of?
assert_requested(:post, url,
body: hash_including({name: 'web', events: ['release'], active: true,
config: {url: 'http://example.com/webhooks/release', content_type: 'json'}}))
# Something else?
@kurtfunai
Copy link

body_hash = {
  name: 'web',
  events: ['release'],
  active: true, 
  config: {
    url: 'http://example.com/webhooks/release', 
    content_type: 'json'
    }
  }

assert_requested(:post, url, body: hash_including(body_hash))

@aybabtme
Copy link

aybabtme commented Apr 9, 2014

like Kurt said, except the indentation is off

@phoet
Copy link

phoet commented Apr 10, 2014

👍 for @kurtfunai

i did not even know about hash_including!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment