Sha256: 8e2d86c932d73334f20ff55e4fda802b552e5195441b7384952cc1769dbe1fe3

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

#encoding: UTF-8
require 'spec_helper'

describe Termit::TextResponseHandler do
  describe "call method" do
    context "no synonyms wanted" do
      let(:handler) do
        response_body = File.open('spec/fixtures/text_response_with_synonyms').read
        Termit::TextResponseHandler.new(response_body, false)
      end

      it "extracts data from HTTP response body" do
        expect($stdout).to receive(:puts).with("tyłek")
        handler.call
      end
    end

    context "synonyms wanted and available" do
      let(:handler) do
        response_body = File.open('spec/fixtures/text_response_with_synonyms').read
        Termit::TextResponseHandler.new(response_body, true)
      end

      it "extracts data from HTTP response body" do
        expect($stdout).to receive(:puts).with("tyłek")
        expect($stdout).to receive(:puts).with("osioł, tyłek, dupa, zadek")
        handler.call
      end
    end

    context "synonyms wanted and unavailable" do
      let(:handler) do
        response_body = File.open('spec/fixtures/text_response_without_synonyms').read
        Termit::TextResponseHandler.new(response_body, true)
      end

      it "extracts data from HTTP response body" do
        expect($stdout).to receive(:puts).with("będzie tam iść")
        expect($stdout).to receive(:puts).with(" ---")
        handler.call
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
termit-2.10.1 spec/termit/text_response_handler_spec.rb
termit-2.10.0 spec/termit/text_response_handler_spec.rb
termit-2.0.9 spec/termit/text_response_handler_spec.rb