Skip to content

Instantly share code, notes, and snippets.

@lucywyman
Created September 6, 2017 16:58
Show Gist options
  • Save lucywyman/fe61303a6ed546dc10851e925b97fe90 to your computer and use it in GitHub Desktop.
Save lucywyman/fe61303a6ed546dc10851e925b97fe90 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'octokit'
require 'git'
require 'json'
require 'fileutils'
require 'sinatra/base'
require_relative 'helpers/helpers.rb'
class Kukla < Sinatra::Base
helpers Sinatra::Kukla::Helpers
get '/' do
erb :index
end
post '/' do
# Stuff
end
run!
end
require 'rubygems'
require 'bundler'
require './app.rb'
Bundler.require
run Kukla
module Sinatra
module Kukla
module Helpers
# Some functions here
end
end
end
require_relative '../../app.rb'
require 'spec_helper'
describe Kukla do
include Rack::Test::Methods
def app
Kukla
end
it 'displays the home page' do
get '/'
expect(last_response.status).to eq 200
end
it 'accepts POST with JSON' do
contents = File.read('webhook_data.json')
json = JSON.parse(contents)
post '/', json, {'CONTENT_TYPE' => 'application/json'}
expect(last_response.status).to eq 200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment