Skip to content

Instantly share code, notes, and snippets.

@johnwake
johnwake / greeter_says_hello.feature
Created August 1, 2012 19:01
BDD Cucumber example Feature File
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!"
@johnwake
johnwake / ftp.rb
Created August 30, 2012 12:18
Simple Ruby FTP file script
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 / gist:8453320
Last active January 3, 2016 10:59
response error return
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 / gist:8829455
Created February 5, 2014 17:51
Publish features
require 'rubygems'
require 'sinatra'
get '/' do
home = Dir.chdir("/features")
File.read(File.join('home', "#{home}"))
end
@johnwake
johnwake / Example Rails API test.rb
Last active August 29, 2015 14:07
Example Rails API test
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}
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