~ubuntu-branches/ubuntu/vivid/ruby-sequel/vivid

« back to all changes in this revision

Viewing changes to spec/extensions/filter_having_spec.rb

  • Committer: Package Import Robot
  • Author(s): Dmitry Borodaenko, Dmitry Borodaenko, Cédric Boutillier
  • Date: 2013-08-10 18:38:17 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20130810183817-iqanz804j32i5myi
Tags: 4.1.1-1
[ Dmitry Borodaenko ]
* New upstream release.
* Standards-Version upgraded to 3.9.4 (no changes).
* Added Build-Depend on ruby-sqlite3.

[ Cédric Boutillier ]
* debian/control: remove obsolete DM-Upload-Allowed flag.
* use canonical URI in Vcs-* fields.
* debian/copyright: use DEP5 copyright-format/1.0 official URL for Format
  field.
* Update debian/watch. Thanks Bart Martens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
 
2
 
 
3
describe "filter_having extension" do
 
4
  before do
 
5
    @ds = Sequel.mock[:t].extension(:filter_having)
 
6
    @dsh = @ds.having(:a)
 
7
  end
 
8
 
 
9
  it "should make filter operate on HAVING clause if dataset has a HAVING clause" do
 
10
    @dsh.filter(:b).sql.should == 'SELECT * FROM t HAVING (a AND b)'
 
11
  end
 
12
 
 
13
  it "should make filter operate on WHERE clause if dataset does not have a HAVING clause" do
 
14
    @ds.filter(:b).sql.should == 'SELECT * FROM t WHERE b'
 
15
  end
 
16
 
 
17
  it "should make and operate on HAVING clause if dataset has a HAVING clause" do
 
18
    @dsh.and(:b).sql.should == 'SELECT * FROM t HAVING (a AND b)'
 
19
  end
 
20
 
 
21
  it "should make and operate on WHERE clause if dataset does not have a HAVING clause" do
 
22
    @ds.where(:a).and(:b).sql.should == 'SELECT * FROM t WHERE (a AND b)'
 
23
  end
 
24
 
 
25
  it "should make or operate on HAVING clause if dataset has a HAVING clause" do
 
26
    @dsh.or(:b).sql.should == 'SELECT * FROM t HAVING (a OR b)'
 
27
  end
 
28
 
 
29
  it "should make or operate on WHERE clause if dataset does not have a HAVING clause" do
 
30
    @ds.where(:a).or(:b).sql.should == 'SELECT * FROM t WHERE (a OR b)'
 
31
  end
 
32
 
 
33
  it "should make exclude operate on HAVING clause if dataset has a HAVING clause" do
 
34
    @dsh.exclude(:b).sql.should == 'SELECT * FROM t HAVING (a AND NOT b)'
 
35
  end
 
36
 
 
37
  it "should make exclude operate on WHERE clause if dataset does not have a HAVING clause" do
 
38
    @ds.exclude(:b).sql.should == 'SELECT * FROM t WHERE NOT b'
 
39
  end
 
40
end