Skip to content

Instantly share code, notes, and snippets.

View jonnyom's full-sized avatar

Jonathan O'Mahony jonnyom

View GitHub Profile
@jonnyom
jonnyom / customer-page.js
Last active October 19, 2022 10:15
Experimenting with using JavaScript service workers hosted on a separate CDN
importScripts('https://cdn.evervault.com/serviceWorker.js');
@jonnyom
jonnyom / rspec_descriptions.rb
Created February 7, 2020 10:27
An Rspec it block that pulls out all the descriptions of the test, with a regex to match "#method_name" describe blocks. Useful for testing that all public methods of a class have been tested in a spec.
it "pulls out the specs descriptions" do
parent_groups = self.class.instance_eval { @parent_groups }
descriptions = parent_groups.each(&:children).map do |child_group|
child_group.instance_eval { @descendant_filtered_examples }.map do |example|
example.full_description
end
end.flatten
matched_descriptions = descriptions.map { |description| description.match(/#([[:word:]]*\??)/) }.compact.map { |match| match[1] }.uniq
expect(matched_descriptions.first).to eq("test_method")
end
## Running this file locally
# Save this file to intercom_webhooks.rb
# In the same directory as the file type "gem install sinatra" and "gem install json" into your command line.
# Install Ngrok (Webhook testing software) blogpost on using it here: https://www.intercom.com/blog/how-to-get-up-and-running-with-messenger-apps-using-ngrok/
# In your command line type "ruby intercom_webhook.rb"
# Once ngrok is installed you can type "ngrok http 4567" in your command line to start Ngrok.
# Now create a new webhook in your developer hub (app.intercom.com/developers/_/webhooks) pointing to the URL that Ngrok gives you
# Save the webhook once you have selected the topic you want notifications for
# Trigger the action to send the webhook notification. For example closing a conversation