Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathew Trivett mathewtrivett

View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mathewtrivett
mathewtrivett / media_queries.scss
Last active Jan 11, 2021
Testing Print CSS - media_queries.scss
View media_queries.scss
/* Learn more about media queries
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media
*/
@media all {
/*
* Styling rules for all media
*/
}
@mathewtrivett
mathewtrivett / spec_helper.rb
Created Jan 11, 2021
Testing Print CSS - spec/spec_helper.rb
View spec_helper.rb
RSpec.configure do |config|
.... # The rest of your Rspec configuration
# Here we are going to precompile our assets any time
# we encounter a feature spec group
config.before(:all) do |_config|
case self.class.metadata[:type]
when :feature
@mathewtrivett
mathewtrivett / webpacker.yml
Last active Jan 11, 2021
Testing Print CSS - config/webpacker.yml
View webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
# ....
# The rest of your webpacker.yml config
test:
<<: *default
# The rest of your test config
@mathewtrivett
mathewtrivett / print_styles.rb
Created Jan 11, 2021
Testing Print CSS - spec/features/print_styles.rb
View print_styles.rb
# Capybara is designed to test visible HTML elements, i.e. your user interface.
# The link tags used for stylesheets are not visible to Capybara by default.
# We need to pass visible: false to `have_selector` to tell Capybara the link element is not visible.
RSpec.describe 'Print CSS', type: :feature do
context 'with params[:medium] == "print"' do
it 'loads the print stylesheet with the media=screen' do
is_expected.to have_selector(
'link[id="print_styles"][media="screen"]',
visible: false
@mathewtrivett
mathewtrivett / application.html.erb
Last active Jan 11, 2021
Testing Print CSS - app/views/layouts/application.html.erb
View application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Testing Print CSS</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<% if params[:medium] == 'print' %>
<!-- Load your print.css file with media attribute equal to screen -->
<%= stylesheet_packs_with_chunks_tag 'print', media: 'screen', 'data-turbolinks-track': 'reload', id: 'print_styles' %>
@mathewtrivett
mathewtrivett / keybase.md
Created Sep 6, 2016
Keybase Github Proof
View keybase.md

Keybase proof

I hereby claim:

  • I am mathewtrivett on github.
  • I am mathewtrivett (https://keybase.io/mathewtrivett) on keybase.
  • I have a public key ASBy2H23Lv_wrYLSBN_h_Q7KcKgnFFfzVG51uK0YIx170Ao

To claim this, I am signing this object: