Sha256: a455f012f23dc439f9782853ae253d3556c58382054a1feae9b69ff6bafc5585

Contents?: true

Size: 644 Bytes

Versions: 5

Compression:

Stored size: 644 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])
    ar_mock.stub!(:columns_hash).and_return({'existing' => mock('column')})
    return ar_mock
  end

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scoped_search-2.6.0 spec/lib/mocks.rb
scoped_search-2.5.1 spec/lib/mocks.rb
scoped_search-2.5.0 spec/lib/mocks.rb
scoped_search-2.4.1 spec/lib/mocks.rb
scoped_search-2.4.0 spec/lib/mocks.rb