Sha256: f4d9ff9efc7fd991b0183e76cb40127185cdc1c64ecf66cc2ccdf795c2c1f2af

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'
require 'rspec-search-and-destroy'

describe RSpecSearchAndDestroy::ReorderAndFilter do
  subject(:ordering_block) do
    RSpecSearchAndDestroy::ReorderAndFilter.new(location_source).block
  end

  let(:location_source) { double("location source") }

  context "when filtering examples" do
    let(:examples) do
      [double('example 1', location: 'location 1'),
       double('example 2', location: 'location 2')]
    end

    before do
      location_source.stub(:example_locations_to_run)
        .and_return ["location 1"]
    end

    it "leaves examples that are enabled" do
      sorted_examples = ordering_block.call(examples)

      expect(sorted_examples).to include examples.first
    end

    it "removes examples that are not enabled" do
      sorted_examples = ordering_block.call(examples)

      expect(sorted_examples).to_not include examples.last
    end
  end

  context "when reordering examples" do
    let(:examples) do
      [double('example 1', location: 'location 1'),
       double('example 2', location: 'location 2')]
    end

    before do
      location_source.stub(:example_locations_to_run)
        .and_return ["location 2", "location 1"]
    end

    it "reorders examples to match" do
      sorted_examples = ordering_block.call(examples)

      expect(sorted_examples).to eql [examples.last, examples.first]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-search-and-destroy-0.0.4 spec/rspec_example_ordering_spec.rb