Sha256: c221f9dc9bd518c3f153dfd9e12966470ea92b85d58ef9ab87ebe5260b07e664

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

require "spec_helper"

describe IMGKit::Configuration do
  describe "#wkhtmltoimage" do
    context "system version exists" do
      let(:system_path) { "/path/to/wkhtmltoimage\n" }

      before(:each) do
        subject.stub :` => system_path
      end

      context "with Bundler" do
        before(:each) do
          subject.stub :using_bundler? => true
        end

        it "should return the result of `bundle exec which wkhtmltoimage` with whitespace stripped" do
          subject.should_receive(:`).with("bundle exec which wkhtmltoimage")
          subject.wkhtmltoimage.should == system_path.chomp
        end
      end

      context "without Bundler" do
        before(:each) do
          subject.stub :using_bundler? => false
        end

        it "should return the result of `which wkhtmltoimage` with whitespace stripped" do
          subject.should_receive(:`).with("which wkhtmltoimage")
          subject.wkhtmltoimage.should == system_path.chomp
        end
      end
    end

    context "system version does not exist" do
      before(:each) do
        subject.stub :` => "\n"
        subject.stub :using_bundler? => false
      end

      it "should return the fallback path" do
        subject.wkhtmltoimage.should == "/usr/local/bin/wkhtmltoimage"
      end
    end

    context "set explicitly" do
      let(:explicit_path) { "/explicit/path/to/wkhtmltoimage" }

      before(:each) do
        subject.wkhtmltoimage = explicit_path
      end

      it "should not check the system version and return the explicit path" do
        subject.should_not_receive(:`)
        subject.wkhtmltoimage.should == explicit_path
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
imgkit-1.6.1 spec/configuration_spec.rb
imgkit-1.6.0 spec/configuration_spec.rb
imgkit-1.5.0 spec/configuration_spec.rb
imgkit-1.4.2 spec/configuration_spec.rb
imgkit-1.4.1 spec/configuration_spec.rb
imgkit-1.4.0 spec/configuration_spec.rb