Sha256: de0aaae254c4e00205796d01d62ca279c5e88bfa38bb77ff2a9482392c90700b

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

RSpec.describe RuboCop::RSpec::ExampleGroup do
  include RuboCop::AST::Sexp

  subject(:group) { described_class.new(parse_source(source).ast) }

  let(:source) do
    <<-RUBY
    RSpec.describe Foo do
      it 'does x' do
        x
      end

      it 'does y' do
        y
      end

      context 'nested' do
        it 'does z' do
          z
        end
      end
    end
    RUBY
  end

  let(:example_nodes) do
    [
      s(:block,
        s(:send, nil, :it,
          s(:str, 'does x')),
        s(:args), s(:send, nil, :x)),
      s(:block,
        s(:send, nil, :it,
          s(:str, 'does y')),
        s(:args), s(:send, nil, :y))
    ].map { |node| RuboCop::RSpec::Example.new(node) }
  end

  it 'exposes examples in scope' do
    expect(group.examples).to eql(example_nodes)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-rspec-1.12.0 spec/rubocop/rspec/example_group_spec.rb
rubocop-rspec-1.11.0 spec/rubocop/rspec/example_group_spec.rb
rubocop-rspec-1.10.0 spec/rubocop/rspec/example_group_spec.rb