This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Real implimentations: | |
# ===================== | |
# | |
# This isn't really testing anything but the point is, rather than | |
# reading the module to use from config and fixing the module for | |
# all tests here we inject the module in the function call and supply | |
# a default for normal operation. This is akin to dependency injection | |
# in OO. Not sure if this is a good idea but seems more flexible as | |
# different tests can pass in a different fake (if needed). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Originals | |
--------- | |
The Trouble With Tribbles | |
Space Seed | |
Originals Movies | |
---------------- | |
Wrath of Khan | |
Search for Spock | |
Voyage Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
In the template just use the @view object and call it's methods to clean up | |
the presentation logic. Maybe think about adding a helper method called `view` | |
that just returns `@view` so we can remove the noise of the `@`. | |
--> | |
<%= @view.users.each do |user| %> | |
<%= @view.user_link(user) %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FizzBuzz do | |
def convert_num(0, 0, _), do: "FizzBuzz" | |
def convert_num(0, _, _), do: "Fizz" | |
def convert_num(_, 0, _), do: "Buzz" | |
def convert_num(_, _, n), do: n | |
def fizz_buzz(n) do | |
convert_num rem(n, 3), rem(n, 5), n | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./config/environments/development.rb | |
config.eager_load = false | |
# ./lib/registry.rb | |
module Registry | |
def self.included(base) | |
base.send(:extend, ClassMethods) | |
end | |
module ClassMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Toolbox | |
@tools = {} | |
def self.register(tool) | |
@tools[tool.material] = tool | |
end | |
def self.tool_for(material) | |
@tools.fetch(material) { BareHands } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@samphippen: https://speakerdeck.com/samphippen/types-and-refactoring | |
@andypike: https://speakerdeck.com/andypike/take-the-pain-out-of-your-tdd | |
@benlovell: https://speakerdeck.com/benlovell/fast-testable-and-sane-json-apis-with-rails-api-et-al | |
@tenderlove: https://speakerdeck.com/tenderlove/brighton-ruby-conf-2014 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# defining various components of the system | |
# notice the classes know nothing about the container | |
# as they require the dependencies to operate, they should be passed into the constructor | |
class Nails | |
def to_s | |
"nails" | |
end | |
end | |
class Glue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# Instead of this simple_form 2.0.0.rc Twitter Bootstrap complication: | |
= form.input :savings, :label => "Your Savings:", :input_html => {:class => 'span2'}, :wrapper => :prepend do | |
%span.add-on= £ | |
= form.input_field :savings | |
%p.help-block Enter the amount of money you have in your savings account | |
-# I'd like to do something like this (simpler) |
NewerOlder