Sha256: a64383e043a0139e460da4ecc4eb859fa6c4c0ceef08c3acecab26666134e639
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. require 'spec/helper' class SpecSimpleCaptcha < Ramaze::Controller helper :simple_captcha map '/' def ask_question question = simple_captcha end def answer_question(with) check_captcha(with) ? 'correct' : 'wrong' end end class SpecCustomCaptcha < SpecSimpleCaptcha map '/fish' trait :captcha => lambda{ ["the answer to everything", 42] } end describe Ramaze::Helper::SimpleCaptcha do behaves_like :session should 'ask question' do session do |mock| question = mock.get('/ask_question').body question.should =~ /^\d+ [+-] \d+$/ lh, m, rh = question.split answer = lh.to_i.send(m, rh.to_i) mock.get("/answer_question/#{answer}").body.should == 'correct' end end should 'ask custom question' do session do |mock| question = mock.get('/fish/ask_question') question.body.should == 'the answer to everything' mock.get('/fish/answer_question/42').body.should == 'correct' end end end
Version data entries
3 entries across 3 versions & 2 rubygems