Sha256: 42023cb9af8344abe29e244ea44f846fc0bad60c4d28fdf21331bd8a4f8ce954

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '/spec_helper'))
require 'zpng/cli'

CLI_PATHNAME = File.expand_path(File.join(File.dirname(__FILE__), '/../bin/zpng'))

describe "CLI" do
  PNGSuite.each_good do |fname|
    describe fname.sub(%r|\A#{Regexp::escape(Dir.getwd)}/?|, '') do

      it "works" do
        orig_stdout, out = $stdout, ""
        begin
          $stdout = StringIO.new(out)
          lambda { ZPNG::CLI.new([fname]).run }.should_not raise_error
        ensure
          $stdout = orig_stdout
        end
      end

      it "works verbosely" do
        orig_stdout, out = $stdout, ""
        begin
          $stdout = StringIO.new(out)
          lambda { ZPNG::CLI.new([fname, "-vvv"]).run }.should_not raise_error
        ensure
          $stdout = orig_stdout
        end
      end

      it "to ASCII" do
        orig_stdout, out = $stdout, ""
        begin
          $stdout = StringIO.new(out)
          lambda { ZPNG::CLI.new([fname, "-A"]).run }.should_not raise_error
        ensure
          $stdout = orig_stdout
        end
      end

      it "to ANSI" do
        orig_stdout, out = $stdout, ""
        begin
          $stdout = StringIO.new(out)
          lambda { ZPNG::CLI.new([fname, "-N"]).run }.should_not raise_error
        ensure
          $stdout = orig_stdout
        end
      end

      it "to ANSI256" do
        orig_stdout, out = $stdout, ""
        begin
          $stdout = StringIO.new(out)
          lambda { ZPNG::CLI.new([fname, "-2"]).run }.should_not raise_error
        ensure
          $stdout = orig_stdout
        end
      end

    end
  end

  it "cuts long metadata" do
    fname = File.join(SAMPLES_DIR, "cats.png")
    orig_stdout, out = $stdout, ""
    begin
      $stdout = StringIO.new(out)
      lambda { ZPNG::CLI.new([fname]).run }.should_not raise_error
    ensure
      $stdout = orig_stdout
    end
    out.size.should < 100_000
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
zpng-0.4.5 spec/cli_spec.rb
zpng-0.4.4 spec/cli_spec.rb
zpng-0.4.3 spec/cli_spec.rb
zpng-0.4.2 spec/cli_spec.rb
zpng-0.4.1 spec/cli_spec.rb
zpng-0.4.0 spec/cli_spec.rb
zpng-0.3.4 spec/cli_spec.rb
zpng-0.3.3 spec/cli_spec.rb
zpng-0.3.2 spec/cli_spec.rb
zpng-0.3.1 spec/cli_spec.rb
zpng-0.3.0 spec/cli_spec.rb
zpng-0.2.5 spec/cli_spec.rb
zpng-0.2.4 spec/cli_spec.rb
zpng-0.2.3 spec/cli_spec.rb
zpng-0.2.2 spec/cli_spec.rb