Skip to content

Instantly share code, notes, and snippets.

View mattwynne's full-sized avatar

Matt Wynne mattwynne

View GitHub Profile
@mattwynne
mattwynne / composer.rb
Last active December 24, 2015 14:19 — forked from dchelimsky/composer.rb
require 'wrong/adapters/rspec'
require 'facets/proc/compose'
# (apply comp fns) in clojure
module Composer
def compose(lambdas)
lambdas.reduce(:*) || lambda {|x| x}
end
@mattwynne
mattwynne / defines_interface.rb
Created October 11, 2012 19:22 — forked from stevecj/defines_interface.rb
Interfaces for Ruby
# total pseudocode
class StickyNotePlacer < Role
messages :call, :user, :message, :color?
end
class ApplicationApi < Role
messages :sticky_note_placer
end
File.open("test.html", "w") { |file| file << "<h1>hello</h1>" }
url = "file://#{File.expand_path '../test.html', __FILE__}"
require 'capybara'
browser = Capybara::Session.new(:selenium)
browser.visit url
puts browser.find("h1").text
class CommentsController < ApplicationController
def create
app.create_comment(params)
end
private
def app
MyRailsApp.new
@mattwynne
mattwynne / sketch.rb
Created June 23, 2012 22:22 — forked from lukemelia/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
@mattwynne
mattwynne / sketch.rb
Created June 23, 2012 22:21 — forked from lukemelia/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationCreator
git log --all -M -C --name-only | grep -E '^(app|lib|spec|features)/' | uniq | sort | uniq -c | sort
# this would be in a helper somewhere
def stub_find(entity)
result = mock_model(entity)
entity.stub(:find).with(result.id).and_return(result)
result
end
let(:params) do
{:these => 'params'}
end
[bar, dog, foo, { c => [rat, cat, dog] }, a, b]
- bar
- dog
- foo
- c:
- rat
- cat
- dog
- a
#create_club.feature
Scenario: Admin adds a club with valid information
Given I am signed in as an admin with the email "admin@admin.com"
And the city "Barcelona" already exists
And I go to the new club page
When I fill in the following:
| Nombre | Ribelinos |
| Calle | Avda. Diagonal |
| Número | 661 |