Skip to content

Instantly share code, notes, and snippets.

@EtienneDepaulis
Last active December 8, 2018 16:32
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 EtienneDepaulis/92633d46f2f9868f1331e63caa7aa27f to your computer and use it in GitHub Desktop.
Save EtienneDepaulis/92633d46f2f9868f1331e63caa7aa27f to your computer and use it in GitHub Desktop.
CircleCi notifications article - basic Gemfile
# spec/circleci-notifications_spec.rb
require 'spec_helper'
describe 'handler' do
let(:event_payload) { File.read("spec/events/#{filename}.json") }
let(:event) { {'body' => event_payload} }
let(:response) { handler(event: event, context: {}) }
let(:parsed_body) { JSON.parse(response[:body]) }
context 'failed' do
let(:filename) { 'sample_body_failed' }
it 'works' do
expect(parsed_body['message']).to eq "Failure detected"
end
end
context 'success' do
let(:filename) { 'sample_body_success' }
it 'works' do
expect(parsed_body['message']).to eq "No failure detected"
end
end
context 'success after failed' do
let(:filename) { 'sample_body_success_after_failed' }
it 'works' do
expect(parsed_body['message']).to eq "No failure detected"
end
end
end
source 'https://rubygems.org'
gem 'rspec'
gem 'webmock'
gem 'awesome_print'
# spec/spec_helper.rb
require_relative '../circleci-notifications'
require 'rspec'
require 'webmock/rspec'
require 'awesome_print'
RSpec.configure do |config|
config.order = :random
WebMock.disable_net_connect!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment