Sha256: 53d343decba23b6eea4a0644585ce4431429f309a7f1c6bfb7d20331dbf56d6c

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

describe "ActiveSupport::Relation =~ matcher" do
  before { MockableModel.delete_all }

  let!(:models) { Array.new(3) { MockableModel.create } }

  if RSpec::Rails.rails_version_satisfied_by?('>= 4.0.0.beta1')
    it "verifies that the scope returns the records on the right hand side, regardless of order" do
      MockableModel.all.should =~ models.reverse
    end

    it "fails if the scope encompasses more records than on the right hand side" do
      MockableModel.create
      MockableModel.all.should_not =~ models.reverse
    end
  else
    it "verifies that the scope returns the records on the right hand side, regardless of order" do
      MockableModel.scoped.should =~ models.reverse
    end

    it "fails if the scope encompasses more records than on the right hand side" do
      MockableModel.create
      MockableModel.scoped.should_not =~ models.reverse
    end
  end

  it "fails if the scope encompasses fewer records than on the right hand side" do
    MockableModel.limit(models.length - 1).should_not =~ models.reverse
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-rails-2.13.1 spec/rspec/rails/matchers/relation_match_array_spec.rb