Skip to content

Instantly share code, notes, and snippets.

<?
public static function get_primary_entries($category, $limit = 20){
$entries = false;
if($category->primary_entries && count($category->primary_entries) >= $limit){
$entries = $category->primary_entries;
}
if(!$entries){
$used = array();
$entries = array();
ENV['ARS_ENV'] ||= 'development'
require 'rubygems'
require 'webrat'
require 'webrat/mechanize'
require 'spec'
class MechanizeWorld
include Spec::Matchers
include Webrat::Methods
<?
$latest_top_stories = new ResourceList(array(
'/apple/news/2009/01/asdf.php',
'/tech-policy/news/2007/12/foia-reform-bloggers-are-journalists-too.php',
'/security/news/2007/11/fbi-edu-security-partnership-trying-to-overcome-decades-of-mistrust.php'
));
?>
<?
public static function sort_categories($categories){
if(get_class($categories) == 'ResourceList'){
$categories = $categories->load();
}
$basename_indexes = array('news' => 0, 'guides' => 1, 'reviews' => 2, 'features' => 3);
$_sorted = array(4);
foreach($categories as $cat){
if(array_key_exists($cat->basename, $basename_indexes)){
$_sorted[$basename_indexes[$cat->basename]] = $cat;
Feature: Entry permalinks
In order to read content
Visitors should be able to
visit permalinks for entries
Scenario: View a short entry
Given I go to a short entry
Then I should see the standard entry elements
And I should not see the extended body
<?
$GLOBALS['entry'] = $entry;
$page_number = $_SERVER['PATH_INFO'];
$page_number = preg_replace("/[^0-9]/", '', $page_number);
if($page_number == '') $page_number = 1;
?>
<? $render->open_layout('standard'); ?>
<div id="news-item">
<?
$img = $entry->intro_image ? $entry->intro_image : $entry->listing_image;
Feature: Browse frontpage
In order to find new and interesting content
Visitors should be able to
view the front page
Scenario: A new visitor visits the frontpage
Given I go to the homepage
Then I should see "Ars Technica" in the title
# Comment out the next line if you don't want Cucumber Unicode support
require 'cucumber/formatter/unicode'
require 'webrat'
require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
Webrat.configure do |config|
config.mode = :mechanize
end
// ==UserScript==
// @name Ars User Admin Link
// @namespace ars
// @include http://civis.arstechnica.com/users/1
// ==/UserScript==
// Add jQuery
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
$VAR1 = bless( { '_content' => '500 Can\'t locate object method "new" via package "LWP::Protocol::https::Socket" ', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal response', 'client-date' => 'Thu, 20 Aug 2009 17:53:38 GMT', 'content-type' => 'text/plain' }, 'HTTP::Headers' ), '_msg' => 'Can\'t locate object method "new" via package "LWP::Protocol::https::Socket"', '_request' => bless( { '_content' => '<complimentary_subscription><duration_quanti ty>7</duration_quantity><duration_units>days< /duration_units><feature_level>365</feature_l evel></complimentary_subscription>', '_uri' => bless( do{\(my $o = 'https://spreedly.com/api/v4/arstechnica-test /subscribers/SpreedlySubs::App::Server/compli mentary_subscriptions.xml')}, 'URI::https' ), '_headers' => bless( { 'user-agent' => 'libwww-perl/5.808', 'content-type' => 'application/xml' }, 'HTTP::Headers' ), '_method' => 'POST' }, 'HTTP::Request' ) }, 'HTTP::Response' );