This file contains hidden or 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
# -*- encoding : utf-8 -*- | |
# attempting to get something like http://thunderboltlabs.com/blog/2013/03/27/testing-pundit-policies-with-rspec again | |
require 'rails_helper' | |
RSpec.describe AdminPolicy, type: :policy do | |
subject { AdminPolicy } | |
def self.permits(action) | |
permissions action do | |
it { expect(subject).to permit(current_admin, admin) } |
This file contains hidden or 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
# -*- encoding : utf-8 -*- | |
module PayStripeHelpers | |
# must be used with driver: :selenium (or :sauce?) | |
def pay_stripe | |
sleep(0.7) # wait for the js to create the popup in response to pressing the button | |
within_frame 'stripe_checkout_app' do # must be selenium | |
# fill_in 'card_number', with: '4242424242424242' no longer works | |
4.times {page.driver.browser.find_element(:id, 'card_number').send_keys('4242')} | |
# fill_in 'cc-exp', with: '5/2018' no longer works |
This file contains hidden or 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
RSpec.configure do |config| | |
config.filter_run_excluding :show_me_the_pages unless ENV["SHOW_ME_THE_PAGES"] | |
end | |
class Screenshots | |
include Capybara::DSL | |
attr_accessor :resolutions | |
attr_accessor :output_path |
This file contains hidden or 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
# last entry: | |
#static page routes | |
get '/home' => redirect('/') | |
root :to => 'static_pages#home' | |
get '*page', :to => 'static_pages#show', :constraints => {:page => %r{[\w\-\/]+}} |
This file contains hidden or 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
# -*- encoding : utf-8 -*- | |
class Sitemap | |
def self.static_view_templates | |
require 'fileutils' | |
template_paths = [] | |
FileUtils.cd Rails.root.join 'app', 'views', 'static_pages' do | |
erb_html_files = File.join "**", "*.html.erb" | |
template_paths = Dir.glob(erb_html_files) | |
end | |
remove_html_erb!(template_paths) |
This file contains hidden or 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
all: send-more-money donald | |
# use git clean -f for make clean, but confirm action | |
define gitCLEAN | |
puts 'ARE YOU SURE (git clean -f) ? y/n'; \ | |
puts %x(git clean -n); \ | |
exec('git clean -f') if gets.chomp =~ /^y/i | |
endef | |
clean: |
This file contains hidden or 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
Old tired programmers() -> | |
obviously trusted prolog, | |
others tried perl. | |
Oft they pondered() -> | |
of teams problems, | |
of telcos pains. | |
Onward they plodded() -> | |
obscure to programmers, |
This file contains hidden or 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
# Let's assume you're driving Capybara in both RSpec request specs & Cucumber, | |
# for example you're using Cucumber as a design/documentation tool, and RSpec | |
# for the more boring integration tests. | |
# You don't want to duplicate your click-this-click-that helpers to e.g. | |
# log_in(username, password). | |
# You may also have model state setup code which can be shared/reused. | |
# Where can it go? How can it be loaded? I've been using the following approach: | |
# |
This file contains hidden or 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
# run with Piece.xor_files 'output_filepath', ['infilepath1','infilepath2'] | |
require 'inline' | |
Class Piece | |
inline do |builder| | |
builder.include '<stdlib.h>' | |
builder.include '<stdio.h>' | |
builder.c_singleton <<-C_CODE | |
/* | |
rb_input_paths_array should be a ruby array of strings, |
This file contains hidden or 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
Then /^a static page cache file for #{capture_model} should not exist$/ do |pickle_ref| | |
page = model!(pickle_ref) | |
page_cache_exist?(page).should be_false | |
end | |
Then /^a static page cache file for #{capture_model} should exist$/ do |pickle_ref| | |
page = model!(pickle_ref) | |
page_cache_exist?(page).should be_true | |
end |