Skip to content

Instantly share code, notes, and snippets.

@paul
Created September 5, 2008 21:49
Show Gist options
  • Save paul/9034 to your computer and use it in GitHub Desktop.
Save paul/9034 to your computer and use it in GitHub Desktop.
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
describe Templates, "index action" do
before :all do
create_template_xml 'simple', <<-"XML"
<template name="simple" description="The simplest template possible" />
XML
end
before do
end
def get_index
dispatch_to(Templates, :index)
end
it "should be successful" do
get_index.should be_successful
end
it "should get all the templates" do
get_index.assigns(:templates).should have(1).object
end
it "SHOULD DO A LOT MORE" # TODO
after :all do
wipe_templates
end
end
class Templates < Application
provides :html, :sscj1
def index
@templates = Template.all
display @templates
end
def show
@template = Template.get(params[:id])
raise NotFound unless @template
display @template
end
end # Templates
<?xml version="1.0"?>
<template name="Questions Template Test" description="For testing various question types">
<questions>
<question name="empty">
<text>This question has no default, regex or choices</text>
</question>
<question name="with-default">
<text>This question has a default answer</text>
<default>1.0</default>
</question>
<question name="regex-validation">
<text>This question has a regex to validate the answer</text>
<regex>^\d+$</regex>
</question>
<question name="choices">
<text>This question has some choices</text>
<choice-list>
<choice title="No" value="0"/>
<choice title="Yes" value="1"/>
</choice-list>
</question>
</questions>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment