Sha256: fb3c361eb359add10007bdefdb34f4f05535ddea0e91bf625bca987251d2ce1a

Contents?: true

Size: 645 Bytes

Versions: 15

Compression:

Stored size: 645 Bytes

Contents

module ScopedSearch::RSpec::Mocks

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

  def mock_activerecord_class
    ar_mock = double('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' => double('column')})
    return ar_mock
  end

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

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
scoped_search-4.0.0 spec/lib/mocks.rb
scoped_search-3.3.0 spec/lib/mocks.rb
scoped_search-3.2.2 spec/lib/mocks.rb
scoped_search-3.2.1 spec/lib/mocks.rb
scoped_search-3.2.0 spec/lib/mocks.rb
scoped_search-3.1.0 spec/lib/mocks.rb
scoped_search-3.0.1 spec/lib/mocks.rb
scoped_search-3.0.0 spec/lib/mocks.rb
scoped_search-2.7.1 spec/lib/mocks.rb
scoped_search-2.7.0 spec/lib/mocks.rb
scoped_search-2.6.5 spec/lib/mocks.rb
scoped_search-2.6.4 spec/lib/mocks.rb
scoped_search-2.6.3 spec/lib/mocks.rb
scoped_search-2.6.2 spec/lib/mocks.rb
scoped_search-2.6.1 spec/lib/mocks.rb