require File.expand_path(File.dirname(__FILE__)+'/test_helper') require 'action_controller' require 'action_view' class NotesController < ActionController::Base; end class Template < ActionView::Base def protect_against_forgery?; false; end end describe 'TextcaptchaHelper' do before(:each) do @controller = NotesController.new @note = Note.new @note.textcaptcha end def render_template(assigns = { :note => @note }) template = <<-ERB <%= form_for(@note, :url => '/') do |f| %> <%= textcaptcha_fields(f) do %>
<%= f.label :textcaptcha_answer, @note.textcaptcha_question %>
<%= f.text_field :textcaptcha_answer, :value => '' %>
<% end %> <% end %> ERB Template.new([], assigns, @controller).render(:inline => template) end it 'should render question and answer fields, with hidden textcaptcha_key field' do html = render_template assert_match(/\