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
Testing prawn nil.downcase
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
Siu David Siņuela Pastor  
View profile  
 More options May 28 2009, 7:32 am
From: David Siņuela Pastor (Siu) <siu.4cod...@gmail.com>
Date: Thu, 28 May 2009 04:32:56 -0700 (PDT)
Local: Thurs, May 28 2009 7:32 am
Subject: Testing prawn nil.downcase
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.
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.


 
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.
Siu David Siņuela Pastor  
View profile  
 More options Jun 5 2009, 12:38 pm
From: David Siņuela Pastor (Siu) <siu.4cod...@gmail.com>
Date: Fri, 5 Jun 2009 09:38:08 -0700 (PDT)
Local: Fri, Jun 5 2009 12:38 pm
Subject: Re: Testing prawn nil.downcase
Thank you! The tests are passing now :)

I didn't know where the problem came from.

On 5 jun, 14:02, SteveQ <steve.quin...@gmail.com> wrote:


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »