Skip to content

Instantly share code, notes, and snippets.

@bilus
bilus / gist:4367281
Last active December 10, 2015 02:28
Here's a slightly cleaned-up version that also supports Webkit. DISCLAIMER: It's based on the code above so it's supposed to work with Selenium & RackTest *but* I've only tested it against Webkit. It does not support the @announce tag.
module CookieStepHelper
class Cookies
def Cookies.for(session)
case session.driver
when Capybara::Driver::Selenium
SeleniumCookies.new(session.driver)
when Capybara::Driver::RackTest
RackTestCookies.new(session.driver)
when Capybara::Webkit::Driver
def normalized_experiments
if @experiments.nil?
nil
else
experiment_config = {}
@experiments.keys.each do | name |
experiment_config[name] = {}
end
@experiments.each do | experiment_name, settings|
experiment_config[experiment_name][:alternatives] = normalize_alternatives(settings[:alternatives]) if settings[:alternatives]
== CreateCopywritings: migrating =============================================
-- create_table(:copywriting_phrases)
-> 0.0015s
-- add_index(:copywriting_phrases, [:name, :scope])
-> 0.0005s
== CreateCopywritings: migrated (0.0021s) ====================================
== CreateCopywritingTranslationTable: migrating ==============================
-- rename_column("copywriting_phrase_translations", :copywriting_phrase_id, :refinery_copywriting_phrase_id)
rake aborted!
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
@bilus
bilus / gist:10641276
Created April 14, 2014 11:55
Call to ActiveRecord::AssociationRelation#empty? returns false for an empty result set.
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
@bilus
bilus / test.rb
Created June 3, 2015 12:52
Capybara vs RSpec 3 within issue
require 'sinatra'
get '/' do
<<HTML
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
@bilus
bilus / pools.clj
Last active June 30, 2016 16:25
Channel pool vs LinkedBlockingQueue
(require '[clojure.core.async :as a])
(defn fill-pool
[pool n]
(doseq [_ (range n)]
(a/>!! pool 6)))
(defmacro with-client-from-pool
[[client-binding pool] & body]
`(let [~client-binding (a/<!! ~pool)]
module Sequel
module OpenStructValues
# Set overrides/defaults for inserting Openstruct
def insert_sql(*values)
p "Should get called"
end
end
Dataset.register_extension(:open_struct_values, OpenStructValues)
end
RSpec.describe Package do
let(:package) { described_class.new(owner: owner) }
describe '#company_owned?' do
subject { package.company_owned? }
context 'when owned by User' do
let(:owner) { User.new }
it { is_expected.to be_truthy }
class User; end
class Company; end
class Package
def initialize(owner:)
end
def cost(distance)
end
end
RSpec.shared_examples 'cheap package' do