require 'helper' describe Bearcat::Client::Conferences do before do @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token") end context 'GET' do it "lists calendar_events" do stub_get(@client, "/api/v1/calendar_events").to_return(json_response("calendar_events.json")) calendar_events = @client.calendar_events calendar_events.count.should == 2 first_event = calendar_events.first last_event = calendar_events.last first_event['title'].should == "Paintball Fight!" last_event['title'].should == "Bear Wrestling" end it "gets a calendar_event" do stub_get(@client, "/api/v1/calendar_events/234").to_return(json_response("calendar_event.json")) event = @client.calendar_event(234).first event['title'].should == "Paintball Fight!" end end context 'POST' do it "creates a calendar_event" do body = { id: "234", title: "Paintball Fight!", start_at: "2012-07-19T15:00:00-06:00", end_at: "2012-07-19T16:00:00-06:00", description: "It's that time again!", location_name: "Greendale Community College", location_address: "Greendale, Colorado", context_code: "course_123", all_day_date: "2012-07-19", all_day: "false", reserved: "false" } stub_post(@client, "/api/v1/calendar_events").with(body: body).to_return(json_response("calendar_event.json")) event = @client.create_calendar_event(body).first event['title'].should == "Paintball Fight!" end end context 'PUT' do it "updates a calendar_event" do body = { id: "234", title: "Paintball Fight!", start_at: "2012-07-19T15:00:00-06:00", end_at: "2012-07-19T16:00:00-06:00", description: "It's that time again!", location_name: "Greendale Community College", location_address: "Greendale, Colorado", context_code: "course_123", all_day_date: "2012-07-19", all_day: "false", reserved: "false" } stub_put(@client, "/api/v1/calendar_events/234").with(body: body).to_return(json_response("calendar_event.json")) event = @client.update_calendar_event(234, body).first event['title'].should == "Paintball Fight!" end end context 'DELETE' do it "updates a calendar_event" do stub_delete(@client, "/api/v1/calendar_events/234").to_return({}) event = @client.delete_calendar_event(234) event.should == "" end end end