Sha256: 00da7328af49efd0e74e1796007d50b78340d20e54076422a493a45c49837908

Contents?: true

Size: 1.35 KB

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
termit-2.13.0 spec/termit/text_response_handler_spec.rb
termit-2.12.1 spec/termit/text_response_handler_spec.rb
termit-2.12.0 spec/termit/text_response_handler_spec.rb
termit-2.11.2 spec/termit/text_response_handler_spec.rb
termit-2.11.1 spec/termit/text_response_handler_spec.rb
termit-2.11.0 spec/termit/text_response_handler_spec.rb
termit-2.10.2 spec/termit/text_response_handler_spec.rb