Skip to content

Instantly share code, notes, and snippets.

import data_objects.drivers.DriverDefinition;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
import org.jruby.RubyModule;
module Foo
class Bar < Thor
desc "awesome", "say awesome"
def awesome
puts "Awesome"
end
end
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My First Document</title>
<style type="text/css"> b { color: green; } </style>
</head>
<body>
<p>
describe "a request to /foo/bar" do
def login
post("/account/login", "username=myuser&password=awesomepass")
end
def logout
post("/account/logout")
end
before(:each) do
@wycats
wycats / router.rb
Created September 13, 2008 19:48 — forked from carllerche/router.rb
Merb::Router.prepare do
namespace :admin do
match("/dashboard").to(:controller => "dashboard")
resources :users do
resources :comments
end
end
resources :users do
# Iteration 1
class Foo < Application
def awesome
"Awesome"
end
end
match("/foo/awesome").to(:controller => Foo, :action => :awesome).name(:awesome)
@wycats
wycats / flat.rb
Created September 16, 2008 10:45
$KCODE = 'UTF8'
require "merb-assets"
Merb.flat! do |url|
url.match('/').to(:controller => 'simple', :action =>'index')
end
class Simple < Merb::Controller
provides :json
self._template_root = Dir.pwd
Spec::Matchers.create(:be_successful) do
matches do |rack|
rack.status == 200
end
message do |not_string, rack|
"Expected #{describe_request(rack)}#{not_string} " \
"to be successful, but it returned a #{rack.status}"
end
end
Spec::Matchers.create(:have_xpath) do
matches do |rack, xpath|
document = rack.body
if rack.status < 200 || rack.status >= 300
@error_text = rack.body
false
else
@document = case document
when LibXML::XML::Document, LibXML::XML::Node
module Spec
module Matchers
def self.create(name, &block)
@guid ||= 0
mod = Module.new do
klass = Class.new(MatcherDSL) do
def initialize(expected_value)
@expected_value = expected_value
end