Skip to content

Instantly share code, notes, and snippets.

View JonRowe's full-sized avatar
💭
⛵️

Jon Rowe JonRowe

💭
⛵️
View GitHub Profile
@JonRowe
JonRowe / pure_rspec.md
Last active December 16, 2015 03:19
Ancestry of `let` definitions in `rspec-core` vs `rspec-rails`
RSpec::Core::ExampleGroup::Nested_1::Nested_1
RSpec::Core::ExampleGroup::Nested_1
>> **RSpec::Core::ExampleGroup::Nested_1::LetDefinitions** <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
RSpec::Core::ExampleGroup::Nested_1::NamedSubjectPreventSuper
>> **RequestHelpers** <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
RSpec::Core::ExampleGroup
RSpec::Matchers
RSpec::Core::MockFrameworkAdapter
RSpec::Core::SharedExampleGroup

RSpec::Core::Pending

require 'rspec'
spec_file = 'spec/sample_spec.rb'
File.open(spec_file, 'w') { |file| file.write 'describe { specify { expect(true).to eq false } }' }
1.upto(5) do |i|
puts "Running spec from within ruby runtime"
::RSpec::Core::Runner.run([spec_file], STDERR, STDOUT)
@JonRowe
JonRowe / class_detector.rb
Created March 14, 2013 01:40
Fetch all the classes in the Object namespace...
def blacklist
[
:Object, :Module, :Class, :BasicObject, :Kernel, :NilClass, :NIL, :Data,
:TrueClass, :TRUE, :FalseClass, :FALSE, :Encoding, :Comparable, :Method,
:String, :Symbol, :Exception, :SystemExit, :SignalException, :Interrupt,
:StandardError, :TypeError, :ArgumentError, :IndexError, :KeyError, :Dir,
:RangeError, :ScriptError, :SyntaxError, :LoadError, :NotImplementedError,
:NameError, :NoMethodError, :RuntimeError, :SecurityError, :NoMemoryError,
:EncodingError, :SystemCallError, :Errno, :ZeroDivisionError, :Enumerable,
:FloatDomainError, :Numeric, :Integer, :Fixnum, :Float, :Bignum, :Array,
@JonRowe
JonRowe / Gemfile.lock
Created March 8, 2013 04:35
Dependencies for middleman-sprockets
GIT
remote: git://github.com/middleman/middleman.git
revision: 3ce35149ec0ef33a52937e8f0ae11226810e04f6
branch: 3.0-stable
specs:
middleman (3.0.12)
middleman-core (= 3.0.12)
middleman-more (= 3.0.12)
middleman-sprockets (~> 3.0.8)
middleman-core (3.0.12)
#interestingly... this line fixes the issue...
include RSpec::Matchers
describe do
specify do
obj1 = Object.new
def obj1.blah?; true; end
obj1.should be_blah
obj2 = Object.new
@JonRowe
JonRowe / rspec-expectations_spec.rb
Created February 15, 2013 21:21
Snippet from rspec-expectations showing failure due to usage of `public_send`
let(:proxy_class) do
Class.new(BasicObject) do
def initialize(target)
@target = target
end
def proxied?
true
end
@JonRowe
JonRowe / challenge_spec.rb
Created January 18, 2013 01:32
The Drag & Drop Challenge.... Can you automate this? I can't... Have tried: phantomjs, capybara-webkit, selenium (firefox & chrome)...
describe 'dragging and dropping', type: :js do
let(:manually) { page.driver.browser.action }
specify do
visit 'http://html5demos.com/drag'
find('#two').drag_to find('#bin')
#doesn't work so try...
@JonRowe
JonRowe / git_prompt.sh
Created September 4, 2012 12:03
Git branch prompt
__git_ps1 ()
{
local g="$(git rev-parse --git-dir 2>/dev/null)"
if [ -n "$g" ]; then
local r
local b
if [ -d "$g/rebase-apply" ]
then
if test -f "$g/rebase-apply/rebasing"
then
@JonRowe
JonRowe / sketch.rb
Created June 29, 2012 16:04 — forked from mattwynne/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationResponder
$:.push File.expand_path '../../', __FILE__
module ActiveRecord
class RecordNotFound < StandardError; end
end
require 'action_controller'
require 'app/controllers/application_controller'
module ControllerSpecHelpers