Guest User

Untitled

a guest
Jul 17th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. describe Template do
  2. it "pulls out parameters from the template body" do
  3. template = Template.new("Look at my template with {Adjective} many {Noun}!")
  4. template.parameters.should == ["Adjective", "Noun"]
  5.  
  6. message = Message.new(template)
  7. message.parameters.should == {
  8. "Adjective" => nil,
  9. "Noun" => nil
  10. }
  11.  
  12. message.parameters["Adjective"] = "extremely"
  13. message.parameters["Noun"] = "parts"
  14.  
  15. message.to_s.should == "Look at my template with extremely many parts!"
  16. end
  17. end
  18.  
  19. describe TemplateHelper do
  20. it "builds a form with a field for each parameter" do
  21. include TemplateHelper
  22.  
  23. message = Message.new
  24. message.parameters = {
  25. "MyParam" => "My Initial Value",
  26. "OtherParam" => "My Initial Value Too"
  27. }
  28.  
  29. form = template_form_for(@message, "url", :method => :post)
  30.  
  31. form.should == '
  32. <form action="url" method="post">
  33. <label>MyParam</label><input type="text" name="message[MyParam]" value="My Initial Value"/>
  34. <label>OtherParam</label><input type="text" name="message[OtherParam]" value="My Initial Value Too"/>
  35. </form>
  36. '
  37. end
  38. end
Add Comment
Please, Sign In to add comment