Sha256: 89033511cf5d9c2dd7851e02e9d756dc994084c80ff7b60e10f756956634639f

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

module RSpec::Core
  RSpec.describe 'Opal Metadata' do
    describe "backwards compatibility" do
      before { allow_deprecation }

      describe ":example_group" do
        it 'allows integration libraries like VCR to infer a fixture name from the example description by walking up nesting structure' do
          fixture_name_for = lambda do |metadata|
            description = metadata[:description]

            if example_group = metadata[:example_group]
              [fixture_name_for[example_group], description].join('/')
            else
              description
            end
          end

          ex = inferred_fixture_name = nil

          RSpec.configure do |config|
            config.before(:example, :infer_fixture) { |e| inferred_fixture_name = fixture_name_for[e.metadata] }
          end

          # run returns a promise
          # RSpec.describe "Group", :infer_fixture do
          #   ex = example("ex") {}
          # end.run
          #
          # raise ex.execution_result.exception if ex.execution_result.exception
          #
          # expect(inferred_fixture_name).to eq("Group/ex")

          group = RSpec.describe "Group", :infer_fixture do
            ex = example("ex") {}
          end

          group.run.then do
            raise ex.execution_result.exception if ex.execution_result.exception

            expect(inferred_fixture_name).to eq("Group/ex")
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
opal-rspec-0.6.2 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb
opal-rspec-0.7.0.rc.1 spec-opal-rspec/core/metadata_spec.rb
opal-rspec-0.6.1 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb
opal-rspec-0.6.0 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb
opal-rspec-0.6.0.beta1 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb
opal-connect-rspec-0.5.0 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb
opal-rspec-0.5.0 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb
opal-rspec-0.5.0.beta3 spec/rspec/core/opal_alternates/rspec/core/metadata_spec.rb