Skip to content

Instantly share code, notes, and snippets.

View ctweney's full-sized avatar

Chris Tweney ctweney

View GitHub Profile
{"tasks":[{"course_code":"API101","emitter":"bCourses","linkDescription":"View in bCourses","linkUrl":"https://ucberkeley.instructure.com/courses/767330/assignments/2588302","sourceUrl":"https://ucberkeley.instructure.com/courses/767330/assignments/2588302","status":"inprogress","title":"Past Discussion","type":"assignment","dueDate":{"epoch":1427871540,"dateTime":"2015-03-31T23:59:00-07:00","dateString":"3/31","hasTime":true},"bucket":"Overdue"},{"course_code":"API101","emitter":"bCourses","linkDescription":"View in bCourses","linkUrl":"https://ucberkeley.instructure.com/courses/767330/assignments/2588242","sourceUrl":"https://ucberkeley.instructure.com/courses/767330/assignments/2588242","status":"inprogress","title":"Online-Submission Past Assignment","type":"assignment","dueDate":{"epoch":1427958300,"dateTime":"2015-04-02T00:05:00-07:00","dateString":"4/02","hasTime":true},"bucket":"Overdue"},{"course_code":"API101","emitter":"bCourses","linkDescription":"View in bCourses","linkUrl":"https://ucberkeley.i
def mock_request
# Webmock match criteria need an adjustment because of basic authentication.
feed_uri = URI.parse(@settings.base_url)
{
method: :any,
uri: /.*#{feed_uri.hostname}#{feed_uri.path}.*/
}
end
4) Bearfacts::Telebears it should behave like a student data proxy server error returns an error status
Failure/Error: expect(lines[0]).to match(/url: http/)
expected "SLOW PROXY duration: 13ms {:url=>\"https://apis-dev.berkeley.edu/bearfacts-apis/student/11667051/reg/appointments\", :class=>Bearfacts::Telebears, :exception=>[\"Errors::ProxyError\", \"Errors::ProxyError\"]} " to match /url: http/
Diff:
@@ -1,2 +1,2 @@
-/url: http/
+"SLOW PROXY duration: 13ms {:url=>\"https://apis-dev.berkeley.edu/bearfacts-apis/student/11667051/reg/appointments\", :class=>Bearfacts::Telebears, :exception=>[\"Errors::ProxyError\", \"Errors::ProxyError\"]} "
Shared Example Group: "a student data proxy" called from ./spec/models/bearfacts/telebears_spec.rb:6
# ./spec/support/proxy_shared_examples.rb:8:in `(root)'
@ctweney
ctweney / calendar.rb
Created October 30, 2014 20:07
Batch API calls don't observe auto_refresh_token setting
require 'rubygems'
require 'google/api_client'
require 'google/api_client/client_secrets'
require 'google/api_client/auth/file_storage'
require 'sinatra'
require 'logger'
enable :sessions
CREDENTIAL_STORE_FILE = "#{$0}-oauth2.json"
@ctweney
ctweney / date_time_bug.rb
Created April 7, 2014 20:38
Demonstration of bug in Rails DateTime.to_i function
require 'test_helper'
class DateTimeBugTest < ActiveSupport::TestCase
test "a PDT parsed DateTime should convert to_i and back again" do
original_date=DateTime.parse('2014-04-05T23:59:59-07:00')
assert original_date == DateTime.strptime(original_date.to_i.to_s, '%s')
end
test "a GMT parsed DateTime should convert to_i and back again" do