Sha256: 2fabd7c6132f2ceac4b040aecabf83a65b00bf09ddcdf3ebcad968224abee1dc

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require "spec_helper"

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

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

  if ::Rails::VERSION::STRING >= '4'
    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

4 entries across 4 versions & 1 rubygems

Version Path
rspec-rails-2.14.1 spec/rspec/rails/matchers/relation_match_array_spec.rb
rspec-rails-3.0.0.beta1 spec/rspec/rails/matchers/relation_match_array_spec.rb
rspec-rails-2.99.0.beta1 spec/rspec/rails/matchers/relation_match_array_spec.rb
rspec-rails-2.14.0 spec/rspec/rails/matchers/relation_match_array_spec.rb