Skip to content

Instantly share code, notes, and snippets.

@xaviervia
Created November 8, 2011 23:28
Show Gist options
  • Save xaviervia/1349687 to your computer and use it in GitHub Desktop.
Save xaviervia/1349687 to your computer and use it in GitHub Desktop.
Example of Piano spec suite
require "mechanize"
module Environment
def self.server
"http://localhost:4567/"
end
module Setup
def self.file donde, que
File.open donde, "w" do |file|
file.write que
end
end
module SimpleController
def self.setup
destroy
FileUtils.mkdir "arena"
FileUtils.mkdir "arena/controllers"
Setup.file "arena/controllers/un.controller", "get '/' do
'#{expectation}'
end"
end
def self.expectation
"Hello!"
end
def self.url
Environment.server
end
def self.destroy
FileUtils.rm_r "arena" if Dir.exist? "arena"
end
end
end
end
module Mecha
def self.go url
@@page = agent.get url
end
def self.page
@@page
end
def self.agent
@@agent ||= Mechanize.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment