Sha256: 5be4a4016646ef3ebc787632e5e74bcc12938824dbbe20e1f84c42394f1488fa

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

module InlineCssHtmlConverter
  describe Worker do
    let(:apikey) { '1-us1' }
    let(:html) { '<html></html>' }

    context '#initialize' do
      it 'set apikey' do
        worker = described_class.new(apikey, html)
        expect(worker.instance_variable_get("@apikey")).to eq apikey
      end

      it 'set html' do
        worker = described_class.new(apikey, html)
        expect(worker.instance_variable_get("@html")).to eq html
      end

      it 'raise an error if no apikey is given' do
        expect { described_class.new(nil, html) }
          .to raise_error(NoApiKeyGivenError)
      end

      it 'raise an error if the api key is invalid' do
        expect { described_class.new('1', html) }
          .to raise_error(InvalidApiKeyError)
      end
    end

    context '#perform' do
      it 'post a request' do
        expect(HTTParty).to receive(:post).and_return({html: ''})

        worker = described_class.new(apikey, html)
        worker.perform
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inline-css-html-converter-0.1.8 spec/worker_spec.rb
inline-css-html-converter-0.1.7 spec/worker_spec.rb
inline-css-html-converter-0.1.3 spec/worker_spec.rb
inline-css-html-converter-0.1.2 spec/worker_spec.rb
inline-css-html-converter-0.1.0 spec/worker_spec.rb