Skip to content

Instantly share code, notes, and snippets.

View manlycode's full-sized avatar

Chris Rittersdorf manlycode

  • Collective Idea
  • Grand Rapids, MI
View GitHub Profile
locations = Location.all.select {|l| l.geocode.nil? }
market_addresses = MarketAddress.all.select {|l| l.geocode.nil? }
locations.each {|l| l.save! }
market_addresses {|ma| ma.save! }
#!upstart
description "pickaxe game server"
author "Chris Rittersdorf"
env NOTIFY_URL="http://pickaxe-staging.herokuapp.com"
env PORT=3000
env HOME="/root/game-server"
start on started net-device-up
SELECT DISTINCT(products.id), products.updated_at
FROM products
INNER JOIN lots
ON (lots.product_id = products.id)
GROUP BY products.id
HAVING SUM(lots.quantity) > 100;
def seller_confirmation(order, seller)
@market = order.market
@order = SellerOrder.new(order, seller) # Selling users organizations only see
mail(
to: lambda { seller.users.map(:email) },
subject: "You have a new order!"
)
end
def initialize(order, seller)
@order = order
if seller.is_a?(User)
@items = order.items.select("order_items.*").joins(:product).where('products.organization_id' => seller.organization_ids)
elsif seller.is_a?(Organization)
@items = order.items.select("order_items.*").joins(:product).where('products.organization_id' => seller.id)
end
end
[
BankAccount,
Cart,
CartItem,
Category,
Delivery,
DeliverySchedule,
Location,
Lot,
ManagedMarket,
@import "mixins";
.updated input {
background-color: #bfd9ad;
@include transition("background-color 0.1s ease-in");
.updated.finished input {
background-color: white;
@include transition("background-color 0.1s ease-out");
}
class CartLink < Domino
selector "header .cart"
def counter
node.find(".counter").text.to_i
end
end
expect(Dom::CartLink.first.counter).to eql(3)

Rails Testing Anti-patterns: Domino
I enjoy integration testing Rails applications. Not only because it’s anessential practice, but because I’m too lazy to have to click through anapplication on my browser if I don’t have to. I enjoy clean integration testseven more. My job is very easy when I can jump onto a new project and clearlyunderstand what an integration test is trying to prove.

Recently, I was shown a tool to improve the clarity of tests. The"Domino":https://github.com/ngauthier/domino Rubygem. Domino lets you seperateDOM selectors from your Capybara integration tests, and makes DOM assertionslook like a clean DSL than selector string scattered throughout your tests.

Being a fan of DLS and abstraction, I went bananas writing DSLs with Domino. Butquickly found out that made more work for myself. The following catalogs a fewof these pitfalls, and offer simpler alternatives.

Starting With Good Intentions

Starting out writing Domino classes, I understood the basics: a domelement has a selecto

Rails Testing Anti-patterns: Domino

I enjoy integration testing Rails applications. Not only because it’s an
essential practice, but because I’m too lazy to have to click through an
application on my browser if I don’t have to. I enjoy clean integration tests
even more. My job is very easy when I can jump onto a new project and clearly
understand what an integration test is trying to prove.

Recently, I was shown a tool to improve the clarity of tests. The
Domino Rubygem. Domino lets you seperate