Sha256: 57fa985e89ebcde2be137521fd1d519d201f6871e122e6f5eff287c241f344ad

Contents?: true

Size: 568 Bytes

Versions: 8

Compression:

Stored size: 568 Bytes

Contents

module ScopedSearch::RSpec::Mocks

  def tree(array)
    ScopedSearch::QueryLanguage::AST.from_array(array)
  end

  def mock_activerecord_class
    ar_mock = mock('ActiveRecord::Base')
    ar_mock.stub!(:named_scope).with(:search_for, anything)
    ar_mock.stub!(:scope).with(:search_for, anything)
    ar_mock.stub!(:connection).and_return(mock_database_connection)
    ar_mock.stub!(:ancestors).and_return([ActiveRecord::Base])
    return ar_mock
  end

  def mock_database_connection
    c_mock = mock('ActiveRecord::Base.connection')
    return c_mock
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
scoped_search-2.3.7 spec/lib/mocks.rb
scoped_search-2.3.6 spec/lib/mocks.rb
scoped_search-2.3.5 spec/lib/mocks.rb
scoped_search-2.3.4 spec/lib/mocks.rb
scoped_search-2.3.3 spec/lib/mocks.rb
scoped_search-2.3.1 spec/lib/mocks.rb
scoped_search-2.3.0 spec/lib/mocks.rb
scoped_search-2.2.1 spec/lib/mocks.rb