Skip to content

Instantly share code, notes, and snippets.

class Plantilla
attr_accessor :body, :title
def initialize strategy
self.strategy = strategy
end
def strategy= strategy
@strategy = strategy.new(self)
@noili
noili / gist:7cd28459a79aac92121d
Last active August 29, 2015 14:05
step_controller.rb
test "shold return all file records that are currently in an office" do
file_records = [file_records(:legal), file_records(:armas)]
get :index, file_record:
{q: {step_office_name_cont: 'Archivo'}}
assert response.body == file_records.to_json
end
@noili
noili / README.md
Last active August 29, 2015 14:05
Archivo v3

Modelo

FileRecord

  • has many steps
  • has and belongs to many tags
  • has many assets - paperclip (el otro que no me acuerdo el nombre, algo con wave)
  • belongs to topic (puede ser)

User

@noili
noili / gist:07aedc468907a4f6f7a7
Last active August 29, 2015 14:06
steps_test.rb
class StepTest < ActiveSupport::TestCase
test "create step with unexistant office" do
step = Step.create name: 'Computo'
assert step.office.name == 'Computo'
end
test "create step with existant office" do
office = offices :computo
step = Step.create office: office
@noili
noili / food_chain.rb
Created July 15, 2015 16:28
food_chain for exercism
require 'pry'
class FoodChain
ANIMALS = {'fly' => 'I don\'t know why she swallowed the fly. Perhaps she\'ll die.',
'spider' => 'that wriggled and jiggled and tickled inside her.',
'bird' => 'How absurd to swallow a bird!',
'cat' => 'Imagine that, to swallow a cat!',
'dog' => 'What a hog, to swallow a dog!',
'goat' => 'Just opened her throat and swallowed a goat!',
class SumOfMultiples
attr_accessor :args
def initialize *args
self.args = args
end
def self.to n
new(3,5).to n
class School
def to_hash
school.sort.to_h
end
def add name, grade
if school[grade]
(school[grade] << name).sort!
else
class Series
attr_accessor :series
def initialize series
self.series = series
end
def slices n
raise ArgumentError.new("Length greater than series") if n > series.size
@noili
noili / prime_factors.rb
Last active September 5, 2015 05:22
prime_factors.rb
class PrimeFactors
attr_accessor :n, :primes
def initialize n
self.n = n
self.primes = prime_divisors
end
def self.for n
@noili
noili / prime_factors_test.rb
Last active September 5, 2015 05:22
test for prime_factors
#!/usr/bin/env ruby
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'prime_factors'
require 'pry'
require 'prime'
class PrimeFactorsTest < Minitest::Test
def test_prime_factors