Skip to content

Instantly share code, notes, and snippets.

@idengager
Created November 25, 2013 12:06
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 idengager/7640336 to your computer and use it in GitHub Desktop.
Save idengager/7640336 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe 'Create event' do
before do
stub_request(:get, "http://calendar-api.shellyapp.com/events/new?token=")
.to_return(status: 200, body: { message: {}.to_json }, headers: {})
end
it 'should render new event form' do
visit '/events/new'
subject { page }
expect(page).to have_content("Create new event")
end
context 'for valid event params' do
let(:event) {
{
name: "Party Rock!",
description: "Awesome Party With Chicks ;D",
category: "party",
subcategory: "alcohol",
start_time: "2013-11-22T22:00:00+00:00",
end_time: "2013-11-25T09:00:00+00:00",
city: "New York",
address: "35th, Ave",
country: "America",
private: 'false',
owner: 'fake_id',
token: '12345'
}
}
before do
stub_request(:post, "http://calendar-api.shellyapp.com/event?" +
"address=35th,%20Ave&category=party&city=New%20York&country=America&description=Awesome%20Party%20With%20Chicks%20%3BD&end_time=2013-11-25T09:00:00%2B00:00&name=Party%20Rock!&private=0&start_time=2013-11-22T22:00:00%2B00:00&subcategory=alcohol&token=")
.to_return(
status: 200,
body: { message: "Event successfully added" }.to_json,
headers: {}
)
stub_request(:get, "http://calendar-api.shellyapp.com//events?token=").
to_return(:status => 200, :body => "", :headers => {})
visit '/events/new'
fill_in 'event_name', with: event[:name]
fill_in 'event_description', with: event[:description]
fill_in 'event_category', with: event[:category]
fill_in 'event_subcategory', with: event[:subcategory]
fill_in 'event_start_time', with: event[:start_time]
fill_in 'event_end_time', with: event[:end_time]
fill_in 'event_city', with: event[:city]
fill_in 'event_address', with: event[:address]
fill_in 'event_country', with: event[:country]
click_on("Create Event")
end
subject { page }
it { should have_content('Event succesfully added') }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment