This file contains 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
x = "some file name.with dots.html.markdown" | |
x.split(".").reverse.inject([x, []]) do |(file, exts), part| | |
if part =~ /\s/ || part == file | |
break [file, exts] | |
else | |
[file.chomp(".#{part}"), exts.push(part)] | |
end | |
end |
This file contains 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
var http = require("http"); | |
var port = process.env.PORT || 8000; | |
var listeners = []; | |
function server(request, response) { | |
switch (request.method) { | |
case "GET": | |
listen(request, response); |
This file contains 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
1) HTTPSpec::Clients::CGI issues requests to the app | |
69 Failure/Error: Unable to find matching line from backtrace | |
70 Java::JavaLang::NullPointerException: | |
71 # org.jruby.util.ShellLauncher.getCurrentEnv(ShellLauncher.java:235) | |
72 # org.jruby.util.ShellLauncher.popenShared(ShellLauncher.java:712) | |
73 # org.jruby.util.ShellLauncher.popenShared(ShellLauncher.java:689) | |
74 # org.jruby.util.ShellLauncher.popen(ShellLauncher.java:673) | |
75 # org.jruby.RubyIO.popen19(RubyIO.java:3722) | |
76 # org.jruby.RubyIO$s$0$1$popen19.call(RubyIO$s$0$1$popen19.gen:65535) | |
77 # org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:219) |
This file contains 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
require "rack" | |
require "capybara/rspec" | |
App = Rack::Builder.new do | |
map "/" do | |
run proc { |env| | |
request = Rack::Request.new(env) | |
response = Rack::Response.new | |
if request.cookies["logged_in"] | |
response.write "Logged in!" |
This file contains 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
require "httparty" | |
class FacebookTestUser | |
include HTTParty | |
base_uri "graph.facebook.com:443" | |
attr_reader :email, :password | |
def initialize(options) | |
@email = options["email"] |
This file contains 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
require "html" | |
require "html/list" | |
require "html/map" | |
module HTML | |
class Article < Struct.new(:article) | |
def to_html | |
HTML.build(article) do |article| | |
tag(:article, tag(:h2, article.title) + map(:section, article.sections), id: article.id) | |
end |
This file contains 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
require "webmachine" | |
require "webmachine/adapters/rack" | |
class TestResource < Webmachine::Resource | |
def to_html | |
parts = %w{Hello, World!} | |
Fiber.new do | |
parts.each do |part| | |
Fiber.yield part | |
sleep 0.5 |
This file contains 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
active record | |
role built from a context | |
context | |
should eq #<Context id: 1, type: nil> | |
role built from a role through context | |
context | |
should eq #<Context id: 2, type: nil> (FAILED - 1) | |
student built from a program | |
program | |
should eq #<Program id: 3, type: "Program"> |
This file contains 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
class Tests | |
extend Process | |
def self.passing? | |
fork do | |
begin | |
require "rspec/autorun" | |
Dir["spec/**/*_spec.rb"].each do |spec| | |
require_relative spec | |
end |
This file contains 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
module RackTestHelpers | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def self.define_action(action) | |
define_method action do |*args, &block| | |
options = args.extract_options! | |
options[:http_method] = action | |
options[:controller_method] = args[0] | |
args[0] = [action.to_s.upcase, "#" + options[:controller_method].to_s].join(" ") |