Skip to content

Instantly share code, notes, and snippets.

View adkron's full-sized avatar

Amos King adkron

View GitHub Profile
require "test_helper"
describe TornamentsController do
let(:tornament) { tornaments :one }
it "gets index" do
get :index
assert_response :success
assert_not_nil assigns(:tornaments)
require "test_helper"
describe TornamentsController do
let(:tornament) { tornaments :one }
it "gets index" do
get :index
assert_response :success
assert_not_nil assigns(:tornaments)
class TornamentsController < ApplicationController
before_action :authenticate_user!, only: [:new, :edit, :update, :destroy]
before_action :set_tornament, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@tornaments = Tornament.all
respond_with(@tornaments)
end
class Reaction
def initialize(yield_to)
self.yield_to = yield_to
end
def method_missing(method_name, *)
if yieldable?(method_name)
yield if block_given?
end
end
# From http://blog.boochtek.com/2015/02/23/hexagonal-rails-controllers
class OrderController < ApplicationController
def index
interactor.on(:display) { |orders| render orders }
interactor.list
end
def show
interactor.on(:display) { |order| render order }
@adkron
adkron / ViewController.swift
Last active March 23, 2016 03:37
Estimate Nearable
//
// ViewController.swift
// Airport
//
// Created by Amos King on 3/22/16.
// Copyright © 2016 Binary Noggin. All rights reserved.
//
import UIKit
# == Schema Information
#
# Table name: cached_open_items
#
# id :integer not null, primary key
# company_id :integer not null
# project_id :integer
# login_information_id :integer not null
# open_item_id :integer not null
# open_item_type :string(255) not null
class PasswordFormatValidator < ActiveModel::EachValidator
def validate_each(record, attr_name, value)
PasswordValidationRules.new(value).errors.each do |error|
record.errors.add(attr_name, error)
end
#if value != record.password_confirmation
#record.errors.add(:password_confirmation, I18n.t('views.project.flash_messages.password_does_not_match_confirmation'))
#end
end
end
- if @changeset.action do
.alert.alert-danger
%p
Oops, something isn't quite right. Please correct the errors below.
= form_for @changeset, registration_path(@conn, :create), fn(f) ->
.form-group
= text_input f, :email, placeholder: "Name", class: "form-control"
= error_tag f, :email
.form-group
require "rspec"
RSpec.describe "before after" do
before do
raise "failed"
end
after do
puts "hey"
end