Hi,
I would love to hear your opinion on the idea of “combining RDoc and RSpec to create testable documentation”. Let me explain:
Given you have several RDoc files like this one:
= Examples Some example code snippets.
<soapenv:Envelope | |
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" | |
xmlns:bfex="http://www.betfair.com/publicapi/v5/BFExchangeService/" | |
xmlns:v5="http://www.betfair.com/publicapi/types/exchange/v5/"> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<bfex:getAllMarkets> | |
<bfex:request> | |
<header> | |
<clientStamp>stamp</clientStamp> |
Hi,
I would love to hear your opinion on the idea of “combining RDoc and RSpec to create testable documentation”. Let me explain:
Given you have several RDoc files like this one:
= Examples Some example code snippets.
SOAP request: | |
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://v1_0.validation.ws.chief.blau.de/"> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<v1:validateName> | |
<validationRequest> | |
<names> | |
<firstName>David</firstName> | |
<lastName>Hasselhoff</lastName> |
class DecimalValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
precision = options[:precision] | |
scale = options[:scale] | |
if !precision || !scale | |
raise ArgumentError, "#{self.class.name} expects :precision and :scale option" | |
end |
class ApplicationController < ActionController::Base | |
before_action :set_return_to | |
def set_return_to | |
if !request.xhr? && request.format.html? && request.get? | |
session[:return_to] = request.url | |
end | |
end | |
end |
# rubygems.org/gems/savon by examples | |
# overview of examples at: http://gist.github.com/gists/427837 | |
require "savon" | |
# HTTP basic authentication | |
client = Savon::Client.new do | |
wsdl.location = "http://users.example.com?wsdl" | |
request.basic_auth "username", "password" | |
end |
# rubygems.org/gems/savon by examples | |
# overview of examples at: http://gist.github.com/gists/427837 | |
require "savon" | |
# = Instantiation without a WSDL | |
# | |
# Retrieving and parsing the WSDL is a pretty slow operation. And even though it's cached after the first time, | |
# it's still a pretty slow operation. | |
# | |
# When working without a WSDL you have to set the SOAP namespace and endpoint manually. Also Savon does not know |
require "crack" | |
require "nokogiri" | |
module NokogiriParser | |
class Document < Nokogiri::XML::SAX::Document | |
def stack | |
@stack ||= [] | |
end |
// Takes a screenshot from a given Tweet. | |
// Usage: phantomjs twitter_screenshot.js https://twitter.com/Snowden/status/777557723118440448 | |
var system = require("system"), | |
args = system.args; | |
var url = args[1]; | |
if (!url) { | |
console.log("Please provide the URL to a Tweet."); |
$ rspec --format MacVimFormatter --color spec |