Skip to content

Instantly share code, notes, and snippets.

John Wakeling johnwake

Block or report user

Report or block johnwake

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ex_spec.rb
describe Example do
context '.create' do
it 'receives a call to create method' do
expect(described_class.create).to
receive(create)
.with('something')
end
end
context '.example' do
@johnwake
johnwake / Example Rails API test.rb
Last active Aug 29, 2015
Example Rails API test
View Example Rails API test.rb
describe 'Tasks API' do
before :each do
FactoryGirl.create :project
Project.last.integrations << Integration.last
end
# GET /tasks/:id
it 'should return a single task' do
api_get "tasks/#{Task.last.id}", {token: Integration.last.user.api_key.token}
View gist:8829455
require 'rubygems'
require 'sinatra'
get '/' do
home = Dir.chdir("/features")
File.read(File.join('home', "#{home}"))
end
@johnwake
johnwake / gist:8453320
Last active Jan 3, 2016
response error return
View gist:8453320
module ApiRequests
def self.post_json_to_url input_url, json_body
begin
@response = RestClient.post(input_url, json_body, :content_type => 'application/json')
rescue Exception => e
raise e.response
end
parse_response_body(@response)
end
@johnwake
johnwake / ftp.rb
Created Aug 30, 2012
Simple Ruby FTP file script
View ftp.rb
require 'uri'
require 'open-uri'
require 'net/ftp'
uri = URI.parse('ftp://User@Server')
Net::FTP.open(uri.host) do |ftp|
ftp.login 'username', 'password'
ftp.passive = true
puts ftp.pwd
ftp.chdir('home/test')
@johnwake
johnwake / greeter_says_hello.feature
Created Aug 1, 2012
BDD Cucumber example Feature File
View greeter_says_hello.feature
Feature: greeter says hello
In order to start learning RSpec and Cucumber
As a reader of The RSpec Book
I want a greeter to say Hello
Scenario: Greeter says hello
Given a greeter
When I send it the greet message
Then I should see "Hello Cucumber!"
You can’t perform that action at this time.