Sha256: 34d024e633f7fb2c99bc98cdb5cc72e637509afd1b16a7d2ea309a50af6eb691

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

module MultiEncoder

  describe QRcodeImage do

    let(:qrcode) { QRcodeImage.new 'thesisist' }

    context "Filesystem storage" do
      after do
        root_dir = qrcode.root.join 'public'
        FileUtils.rm_rf root_dir if root_dir.exist?
      end

      specify 'exsits? is false' do
        qrcode.exists?.should be_false
      end

      it 'should write the file if href is requested' do
        qrcode.should_receive(:write)
        qrcode.href
      end

      it 'writes the png to the filesystem' do
        qrcode.write
        qrcode.exists?.should be_true
      end

      it 'does not write the png twice' do
        qrcode.write
        qrcode.should_not_receive(:write)
        qrcode.href
      end
    end

    context "AWS storage" do
      before do
        MultiEncoder::Storage.configure do |c|
          c.destination = :aws
          c.aws_bucket_prefix = ENV['AWS_BUCKET_PREFIX']
          c.aws_access_key = ENV['AWS_ACCESS_KEY']
          c.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
        end
      end

      after do
        qrcode.delete if qrcode.exists?
      end

      specify 'exsits? is false' do
        qrcode.exists?.should be_false
      end

      it 'saves to as3' do
        qrcode.write
        qrcode.exists?.should be_true
        qrcode.should_not_receive(:write)
        qrcode.href.should match(/^http/)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
barcode_encoder-0.0.9 spec/multi_encoder/qrcode_image_spec.rb
multi_encoder-0.0.9 spec/multi_encoder/qrcode_image_spec.rb
multi_encoder-0.0.8 spec/multi_encoder/qrcode_image_spec.rb
multi_encoder-0.0.7 spec/multi_encoder/qrcode_image_spec.rb
multi_encoder-0.0.6 spec/multi_encoder/qrcode_image_spec.rb