Sha256: c14ba2b3de3848f9cbdacc922f062060f52d6a668b0dd1c0ec85ed877be9c995

Contents?: true

Size: 1.34 KB

Versions: 32

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Quby::Answers::Services
  describe BuildAnswer do
    let(:questionnaire) { Quby.questionnaires.find('simple') }

    it 'sets questionnaire key' do
      answer = BuildAnswer.new(questionnaire, {}).build
      expect(answer.questionnaire_key).to eq('simple')
    end

    describe 'textvars' do
      it 'sets default textvar values' do
        questionnaire = inject_questionnaire 'test', <<-END
          textvar key: 'foo', description: '', default: 'some_default'
        END

        answer = BuildAnswer.new(questionnaire, {}).build
        expect(answer.textvars).to eq({test_foo: 'some_default'})
      end

      it 'sets given textvar values' do
        questionnaire = inject_questionnaire 'test', <<-END
          textvar key: 'foo', description: '', default: 'some_default'
        END

        answer = BuildAnswer.new(questionnaire, {textvars: {test_foo: 'something_given'}}).build
        expect(answer.textvars).to eq({test_foo: 'something_given'})
      end

      it 'without default are replaced with {{text_var_key}}' do
        questionnaire = inject_questionnaire 'test', <<-END
          textvar key: 'foo', description: ''
        END

        answer = BuildAnswer.new(questionnaire, {}).build
        expect(answer.textvars).to eq({test_foo: '{{test_foo}}'})
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
quby-5.6.3 spec/quby/answers/services/build_answer_spec.rb
quby-5.6.2 spec/quby/answers/services/build_answer_spec.rb
quby-5.6.1 spec/quby/answers/services/build_answer_spec.rb
quby-5.6.0 spec/quby/answers/services/build_answer_spec.rb
quby-5.5.0 spec/quby/answers/services/build_answer_spec.rb
quby-5.4.0 spec/quby/answers/services/build_answer_spec.rb
quby-5.3.1 spec/quby/answers/services/build_answer_spec.rb
quby-5.3.0 spec/quby/answers/services/build_answer_spec.rb
quby-5.2.0 spec/quby/answers/services/build_answer_spec.rb
quby-5.1.3 spec/quby/answers/services/build_answer_spec.rb
quby-5.1.2 spec/quby/answers/services/build_answer_spec.rb
quby-5.1.1 spec/quby/answers/services/build_answer_spec.rb
quby-5.1.0 spec/quby/answers/services/build_answer_spec.rb
quby-5.0.5 spec/quby/answers/services/build_answer_spec.rb
quby-5.0.4 spec/quby/answers/services/build_answer_spec.rb
quby-5.0.3 spec/quby/answers/services/build_answer_spec.rb
quby-5.0.2 spec/quby/answers/services/build_answer_spec.rb
quby-5.0.1 spec/quby/answers/services/build_answer_spec.rb
quby-5.0.0 spec/quby/answers/services/build_answer_spec.rb
quby-4.0.4 spec/quby/answers/services/build_answer_spec.rb