Sha256: 67ec964d637aed3cd2476c8867c56acd5a790617eea49dc73c0f5d82a65d0be4

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

module TurnipFormatter
  class Step
    describe Failure do
      include_context 'turnip_formatter standard step parameters'
      include_context 'turnip_formatter failure scenario setup'
      include_context 'turnip_formatter standard scenario metadata'

      let(:step) do
        step = ::TurnipFormatter::Step.new(example, description)
        step.extend TurnipFormatter::Step::Failure
        step
      end

      let(:klasses) do
        builtin_klass1 = ::TurnipFormatter::StepTemplate::Source
        builtin_klass2 = ::TurnipFormatter::StepTemplate::Exception
        [builtin_klass1, builtin_klass2]
      end

      it 'exists built-in step template' do
        templates = TurnipFormatter::Step::Failure.templates
        expect(templates.keys).to include(*klasses)
      end

      context 'add custom step template' do
        let :custom_template do
          Module.new do
            def self.build(message)
              '[error] ' + message
            end
          end
        end

        before do
          TurnipFormatter::Step::Failure.add_template(custom_template) do
            example.example_group.description
          end
        end

        after do
          TurnipFormatter::Step::Failure.remove_template(custom_template)
        end

        it 'should get custom step template' do
          templates = TurnipFormatter::Step::Failure.templates
          klasses << custom_template
          expect(templates.keys).to include(*klasses)
        end
      end

      describe '#attention?' do
        subject { step.attention? }
        it { should be true }
      end

      describe '#status' do
        subject { step.status }
        it { should eq :failure }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
turnip_formatter-0.2.11 spec/turnip_formatter/step/failure_spec.rb
turnip_formatter-0.2.10 spec/turnip_formatter/step/failure_spec.rb