Skip to content

Instantly share code, notes, and snippets.

@tennety
tennety / 1_string_page_object.rb
Last active October 10, 2019 17:11
Light weight page objects for HTML strings
# If you need to simply test an HTML string for content,
# but don't want (or have) an entire Capybara session to
# render it, Capybara gives you a way to wrap the HTML in
# a Capybara::Node::Simple object with the Capybara.string
# class method. With a little Ruby sprinkled on top, you
# can have a lightweight PageObject pattern for your tests
module Pages
class Base < DelegateClass(Capybara::Node::Simple)
include RSpec::Matchers
@tennety
tennety / reserve_modal--before.html.haml
Last active October 10, 2019 14:24
A Case for View Specs in Rails
.modal_content
- if @book.on_hold?
- # No action needed, user will be notified on availability
- else
- if @book.available_here?
- # Allow user to check it out
- else
- # Allow user to pick a different location to check out from
@tennety
tennety / ElmCheckbox.elm
Last active October 31, 2015 02:11
understanding graphics checkboxes in Elm
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Graphics.Input exposing (..)
import Signal exposing (..)
import Color exposing (..)
checkRed : Signal.Mailbox Bool
checkRed = Signal.mailbox False
checkBlue : Signal.Mailbox Bool
checkBlue = Signal.mailbox False
@tennety
tennety / IntroClues.md
Last active August 29, 2015 14:01
Intro to Ruby clues

Across

  1. Method on Hash that yields each key-value pair to the given block

  2. Method in Enumerable that takes an object, then iterates each element in the collection, returning the object

  3. Method in Enumerable that repeats a block a given number of times or forever if given nothing or nil

  4. Method in Enumerable that separates an array in two based on the truth value of the given block

  5. Method on Array that returns a new, shuffled array