Say you normally use the great database_cleaner gem. Per the README the standard setup is:
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)| require "benchmark" | |
| require "benchmark/ips" | |
| def arr | |
| Array.new(1_000, 1) | |
| end | |
| def arr_of_arrs | |
| Array.new(1_000){ (1..1000).to_a } | |
| end |
| CHRUBY_VERSION="0.3.8" | |
| RUBIES=() | |
| for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do | |
| [[ -d "$dir" && -n "$(ls -A "$dir")" ]] && RUBIES+=("$dir"/*) | |
| done | |
| unset dir | |
| function chruby_reset() | |
| { |
| cat_with_name() { for i in $* ; do echo ; echo "=== $i ===" ; cat $i ; done } |
Say you normally use the great database_cleaner gem. Per the README the standard setup is:
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)| #!/usr/bin/env ruby | |
| # | |
| # Little ditty to untar a bunch of mongo bson dumps, | |
| # and then restore them. | |
| # | |
| # Remembers if something was processed before and doesn't | |
| # process it again. (Though mongo will basically due this | |
| # for you 😬) | |
| # | |
| # I'm a bad person and I should feel bad for writing this |
| #!/usr/bin/env ruby | |
| # A simply utility to show character counts for each line of input and | |
| # highlight lines longer than 80 characters. | |
| # | |
| # Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html | |
| # | |
| # Examples: | |
| # | |
| # $ hilong Gemfile |
| # spec/support/feature_sigin_helpers.rb | |
| # Just some useful namespace | |
| module KrackenFeatures | |
| module SignInHelpers | |
| def sign_in(person) | |
| visit new_user_session_path | |
| fill_in 'Email', with: person.email | |
| fill_in 'Password', with: person.password |
| "Words" * 2 | |
| # => "WordsWords" | |
| 2 * "Words" | |
| # TypeError: String can't be coerced into Fixnum | |
| # Oops what just happened? | |
| # In Ruby, virtually everything is a message to another object. | |
| # Above we would say: |
| FactoryGirl.define do | |
| factory :user do | |
| email 'myuser@test.com' | |
| password 'this IS a BAd passowrds1234!!' | |
| trait :confirmed do | |
| confirmed_at { Time.now } | |
| confirmation_token nil | |
| end |
| describe MyClass do | |
| context "with a barish foo" do | |
| let(:foo) { :bar } | |
| context "doing thing 1" do # #instance_method_1 | |
| # ... | |
| end | |
| context "doing thing 2" do # #instance_method_2 |