Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
Ģ Groups Home
Message from discussion Testing prawn nil.downcase
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
SteveQ  
View profile  
 More options Jun 5 2009, 8:02 am
From: SteveQ <steve.quin...@gmail.com>
Date: Fri, 5 Jun 2009 05:02:48 -0700 (PDT)
Local: Fri, Jun 5 2009 8:02 am
Subject: Re: Testing prawn nil.downcase
Just came across the same problem. You can get around it by modding/
patching 'ssl_required?' in 'compile_support.rb' of prawnto. The
server protocol variable needs a nil check.

      def ssl_request?
        @controller.request.env['SERVER_PROTOCOL'].try(:downcase) ==
"https"
      end

Alternatively you could try stubbing out ssl_request? in your test

Steve

On May 28, 12:32 pm, David Siņuela Pastor (Siu) <siu.

4cod...@gmail.com> wrote:
> Hello,

> I'm having problems testing prawn/prawnto inside my rails application.
> I added a simple test to check if the controller is generating a pdf
> file, but I'm having a weird error, it is complaining about a
> nil.downcase exception, even with an empty template. BUT it is working
> in the web browser, so the problem must be in the test code, can you
> help me?

> Versions:

> prawn (0.4.1)
> prawn-format (0.1.1)
> rails (2.3.2)
> prawnto plugin latest version from github

> I made a new rails project with the following code:

>   1) Error:
> test_should_show_book_pdf(BooksControllerTest):
> ActionView::TemplateError: You have a nil object when you didn't
> expect it!
> The error occurred while evaluating nil.downcase
>     On line #1 of app/views/books/show.pdf.prawn

>         1: pdf.text "Book"

>         app/views/books/show.pdf.prawn:1:in
> `_run_prawn_app47views47books47show46pdf46prawn'
>         app/controllers/books_controller.rb:21:in `show'
>         app/controllers/books_controller.rb:18:in `show'
>         /test/functional/books_controller_test.rb:29:in
> `test_should_show_book_pdf'
>         /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
>         /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
>         /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
>         /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
>         /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
>         /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
>         /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in
> `run_suite'
>         /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in
> `start_mediator'
>         /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in
> `start'
>         /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in
> `run'
>         /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
>         /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
>         /usr/lib/ruby/1.8/test/unit.rb:278
>         rake (0.8.7) lib/rake/rake_test_loader.rb:5

> In environment.rb I have:
>   config.gem "prawn"
>   config.gem "prawn-format", :lib => 'prawn/format'

> application/views/books/show.pdf.prawn:
> pdf.text "Book"

> application/controllers/books_controller.rb:
>   # GET /books/1
>   # GET /books/1.xml
>   def show
>     @book = Book.find(params[:id])

>     respond_to do |format|
>       format.html # show.html.erb
>       format.xml  { render :xml => @book }
>       format.pdf  { render :layout => false }
>     end
>   end

> test/functionals/books_controller_test.rb:
>   test "should show book pdf" do
>     get :show, {:id => books(:one).to_param, :format => 'pdf'}
>     assert_response :success
>   end

> I tried with:
>   test "should show book pdf" do
>     get :show, {:id => books(:one).to_param, :format => :pdf}
>     assert_response :success
>   end
> And it was replying with a 406 response code.

> I don't know what else I could try. Can you give me some advice?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.