Sha256: c76f3a2b50417488e33f15a81c0c6834b6b7050b4c38ab550425c67f70ef5f78

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 KB

Contents

class Test::Unit::TestCase

  def setup
   @dir = File.dirname(__FILE__)
  end

  def contact_html
   File.join(@dir, '..', 'fixtures', 'contact.html')
  end

  def contact_pdf
    File.join(@dir, '..', 'fixtures', 'contact.pdf')
  end


  def self.should_behave_as_pdf_engine

    context 'Rendering from file' do
      setup do
        @dir = File.dirname(__FILE__)
      end

      should 'create a pdf file if the destination is a file' do
        assert_exist contact_pdf do
          subject.render(:input => contact_html, :output => contact_pdf)
        end
      end

      should 'fill STDOUT if no destination is specified' do
        assert_match %r{^%Pdf}, subject.render(:input => contact_html)
      end
    end


    context 'Rendering from STDIN' do
      should 'create pdf file if destination is a file' do
        assert_exist contact_pdf do
          subject.render(:data => '<html>Hello World</html>', :output => contact_pdf)
        end
      end

      should 'fill STDOUT if no destination is specified' do
        assert_match %r{^%Pdf}, subject.render(:data => '<html>Hello World</html>')
      end
    end

    context 'Rendering with http auth' do
      setup do
        @login    = 'ABCDLOGINABCD'
        @password = '7787PASSWORD8'
      end

      should 'include http user in command' do
        assert_match %r{#{@login}}, subject.command(:http_user => @login, :http_password => @password)
      end

      should 'include http password in command' do
        assert_match %r{#{@password}}, subject.command(:http_user => @login, :http_password => @password)
      end
    end

    context 'Rendering with baseurl' do
      setup do
        @baseurl  = 'http://localhost:7999'
      end

      should 'include baseurl in command' do
        assert_match %r{#{@baseurl}}, subject.command(:baseurl => @baseurl)
      end
    end
  end # should_behave_as_pdf_engine
end # Test::Unit::TestCase

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
zena-1.2.8 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.7 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.6 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.5 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.4 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.3 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.2 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.1 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.2.0 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.1.3 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.1.2 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.1.1 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.1.0 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.0.0 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb
zena-1.0.0.rc3 bricks/pdf/test/shoulda_macros/shoulda_pdf.rb