Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View futhr's full-sized avatar
:octocat:

Tobias Bohwalli futhr

:octocat:
View GitHub Profile
@futhr
futhr / select2_capybara_helper.rb
Created March 6, 2014 20:15
Select2 Capybara helper for forms.
# compact version from: https://github.com/spree/spree/blob/master/core/lib/spree/testing_support/capybara_ext.rb
# just drop file in spec/support
module CapybaraHelper
def select2_select(value, options)
find("#s2id_#{options[:from]} a").click
within(:xpath, '//body') do
find('div.select2-result-label', text: %r{#{Regexp.escape(value)}}i).click
end
end
end
@futhr
futhr / memorandum.sh
Created April 1, 2014 02:39
Terminal memorandum --simple as that but easy forgot.
#!/bin/sh
# if cronjob junk .local mailbox
mail
delete 1-10
q
@futhr
futhr / version.rb
Created April 4, 2014 14:10
Nice style for Gem version - pick from a rails/rails pull request.
module YourGem
# Returns the version of the currently loaded YourGem as a <tt>Gem::Version</tt>
def self.version
Gem::Version.new VERSION::STRING
end
module VERSION
MAJOR = 1
MINOR = 1
@futhr
futhr / hard_worker_spec.rb
Created April 23, 2014 00:57
Test sidetiq -- coderwall.com/p/nqpa-w
class HardWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { hourly }
def perform
# Do some work
end
end
@futhr
futhr / TechDecisions.md
Last active October 4, 2015 12:58 — forked from hardbap/TechDecisions.md
Choices to make in a new Rails project.

Team Support

Source Code Control

Github
Alternative: Bitbucket, git (private server)

Time Tracking

None

# updated from the original @ http://cheat.errtheblog.com/s/rspec_shoulda
# just a subset -- models -- is included here. I'll update this, and create cheat sheets for others, as I go along.
# I marked the ones I added with NEW and also added the links to the corresponding code, as I think it's useful.
# Any comments/corrections are welcome!
# ================= Data and Associations =======================
# https://github.com/thoughtbot/shoulda-matchers/tree/master/lib/shoulda/matchers/active_record
it { is_expected.not_to have_db_column(:admin).of_type(:boolean) }
it { is_expected.to have_db_column(:salary).
@futhr
futhr / badges
Last active December 19, 2015 03:58
Replace strings elgalu with your github user and boolean_class with your github repo name. Memo copy from http://elgalu.github.io/2013/add-achievement-badges-to-your-gem-readme
# TODO: Your gem name
[![Gem Version][GV img]][Gem Version]
[![Build Status][BS img]][Build Status]
[![Dependency Status][DS img]][Dependency Status]
[![Code Climate][CC img]][Code Climate]
[![Coverage Status][CS img]][Coverage Status]
## Description
@futhr
futhr / spree.rb
Last active December 19, 2015 05:39
Sample of more or less full config for Spree 2.x @ config/initializers/spree.rb
Spree.config do |config|
# Amazon S3
config.use_s3 = true
config.s3_bucket = 'mybucket'
config.s3_access_key = ENV['S3_ACCESS_KEY_ID']
config.s3_secret = ENV['S3_SECRET_ACCESS_KEY']
config.attachment_url = ':s3_eu_url'
config.s3_host_alias = 's3-eu-west-1.amazonaws.com' # EU
# Mail
@futhr
futhr / locale_spec.rb
Last active December 20, 2015 00:19
Standard locale testing for consistency using i18n-spec gem.
RSpec.describe 'locale:' do
Dir.glob('config/locales/*.yml') do |locale_file|
context locale_file do
it { is_expected.to be_parseable }
it { is_expected.to have_valid_pluralization_keys }
it { is_expected.not_to have_missing_pluralization_keys }
it { is_expected.to have_one_top_level_namespace }
it { is_expected.not_to have_legacy_interpolations }
it { is_expected.to have_a_valid_locale }
it { is_expected.to be_a_complete_translation_of 'config/locales/en.yml' }
@futhr
futhr / navigation_helper.rb
Created July 29, 2013 19:42
Extend Spree::Admin::NavigationHelper with new link button.
module Spree
module Admin
module NavigationHelper
def link_to_translation(resource)
link_to_with_icon 'icon-flag no-text', '',
admin_translations_path(resource.to_s.pluralize, resource.id),
title: Spree.t(:translations)
end
end
end