Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe Template do
- it "pulls out parameters from the template body" do
- template = Template.new("Look at my template with {Adjective} many {Noun}!")
- template.parameters.should == ["Adjective", "Noun"]
- message = Message.new(template)
- message.parameters.should == {
- "Adjective" => nil,
- "Noun" => nil
- }
- message.parameters["Adjective"] = "extremely"
- message.parameters["Noun"] = "parts"
- message.to_s.should == "Look at my template with extremely many parts!"
- end
- end
- describe TemplateHelper do
- it "builds a form with a field for each parameter" do
- include TemplateHelper
- message = Message.new
- message.parameters = {
- "MyParam" => "My Initial Value",
- "OtherParam" => "My Initial Value Too"
- }
- form = template_form_for(@message, "url", :method => :post)
- form.should == '
- <form action="url" method="post">
- <label>MyParam</label><input type="text" name="message[MyParam]" value="My Initial Value"/>
- <label>OtherParam</label><input type="text" name="message[OtherParam]" value="My Initial Value Too"/>
- </form>
- '
- end
- end
Add Comment
Please, Sign In to add comment