Module: Quo::Rspec::Helpers

Defined in:
lib/quo/rspec/helpers.rb

Instance Method Summary collapse

Instance Method Details

#stub_query(query_class, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/quo/rspec/helpers.rb', line 6

def stub_query(query_class, options = {})
  results = options.fetch(:results, [])
  with = options[:with]
  unless with.nil?
    return(
      allow(query_class).to receive(:new)
                              .with(with) { ::Quo::LoadedQuery.new(results) }
    )
  end
  allow(query_class).to receive(:new) { ::Quo::LoadedQuery.new(results) }
end