Skip to content

Instantly share code, notes, and snippets.

@thomasjo
Forked from dtchepak/gist:665388
Created November 8, 2010 06:21
Show Gist options
  • Select an option

  • Save thomasjo/667430 to your computer and use it in GitHub Desktop.

Select an option

Save thomasjo/667430 to your computer and use it in GitHub Desktop.
require 'spec'
class DocsToCode
def initialize()
puts "hello"
end
def docs_in(path)
[]
end
def code_in(doc)
""
end
def extract(path)
code = []
docs_in(path).each { |doc| code << code_in(doc) }
code
end
end
describe DocsToCode do
describe "when convertings docs to code" do
docs = ["first doc", "second doc"]
samples = ["first sample", "second sample"]
subject do
@@docs = docs
@@samples = samples
sut = DocsToCode.new
def sut.docs_in(path); @@docs; end
def sut.code_in(doc)
code = @@samples[0] if doc == @@docs[0]
code = @@samples[1] if doc == @@docs[1]
code
end
sut
end
it "should extract code sample from each doc" do
subject.extract("a path").should == samples
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment