factory(factory_name)
to define a factory
factory(:user) do
%User{name: "John"}
end
create(:user, name: "Jane")
build(:user, name: "Jane")
assoc(:author, factory: :user)
(can only be used inside factory definition)
factory(factory_name)
to define a factoryfactory(:user) do
%User{name: "John"}
end
create(:user, name: "Jane")
build(:user, name: "Jane")
assoc(:author, factory: :user)
(can only be used inside factory definition)
# This is a bit more flexible. Worried people will try to call it directly :S | |
# Also throws warnings if you put functions in between the function definitions | |
def factory(:user, attrs) do | |
%User{ | |
first_name: "Paul" , | |
last_name: "Smith" | |
email: put_new_email(attrs) | |
} | |
end |
defmodule MyApp.Factory do | |
use ExMachina.Ecto, repo: MyApp.Repo | |
def factory(:interest, attrs) do | |
%Interest{ | |
name: sequence(:interest_name, &"interest-#{&1}") | |
} | |
end | |
def factory(:user, attrs) do |
defmodule MyApp.AnnouncementTraits do | |
def with_subscriber(announcement, user) do | |
create(:subscription, announcement: announcement, user: user) | |
announcement | |
end | |
def tag_with_interest(announcement, interest) do | |
create(:announcement_interest, announcement: announcement, interest: interest) | |
announcement | |
end |
Bypass fake_stripe do | |
get "soemthing" do | |
send_resp conn, "" | |
end | |
end |
" Type jj in insert mode to escape to command mode | |
:imap jj <Esc> | |
" Type j; in insert mode to escape to command mode with a : already typed | |
:imap j; <Esc>: | |
" Type ;w in insert mode to escape to command mode with :w already typed | |
:imap ;w <Esc>:w | |
" Use semicolon instead of colon. Don't have to hit shift now | |
map ; : |
module Colleague::Classes | |
class CitizenshipStatus | |
include Processor | |
def process_field(value) | |
AlienStatus.find_code( value ) | |
end | |
end | |
end |
# Something like this might make testing simpler | |
def assert_email_delivered(email) do | |
email = email |> Bamboo.Mailer.normalize_addresses | |
assert_received({:delivered_bamboo_email, ^email}) | |
end |
<head> | |
<!-- you could put a helper in the Layout View but it's probably not necessary --> | |
<%= render_existing(@view_module, "seo." <> @view_template, assigns) || render("default_seo.html") %> | |
</head> |