mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
few components with rspec3 syntax
This commit is contained in:
@ -13,8 +13,8 @@ describe SqlBuilder do
|
||||
p = Fabricate(:post)
|
||||
@builder.where('id = :id and topic_id = :topic_id', id: p.id, topic_id: p.topic_id)
|
||||
p2 = @builder.exec.first
|
||||
p2.id.should == p.id
|
||||
p2.should == p
|
||||
expect(p2.id).to eq(p.id)
|
||||
expect(p2).to eq(p)
|
||||
end
|
||||
end
|
||||
|
||||
@ -32,13 +32,13 @@ describe SqlBuilder do
|
||||
true AS bool")
|
||||
.map_exec(SqlBuilder::TestClass)
|
||||
|
||||
rows.count.should == 1
|
||||
expect(rows.count).to eq(1)
|
||||
row = rows[0]
|
||||
row.int.should == 1
|
||||
row.string.should == "string"
|
||||
row.text.should == "text"
|
||||
row.bool.should == true
|
||||
row.date.should be_within(10.seconds).of(DateTime.now)
|
||||
expect(row.int).to eq(1)
|
||||
expect(row.string).to eq("string")
|
||||
expect(row.text).to eq("text")
|
||||
expect(row.bool).to eq(true)
|
||||
expect(row.date).to be_within(10.seconds).of(DateTime.now)
|
||||
end
|
||||
end
|
||||
|
||||
@ -48,27 +48,27 @@ describe SqlBuilder do
|
||||
end
|
||||
|
||||
it "should allow for 1 param exec" do
|
||||
@builder.exec(a: 1, b: 2).values[0][0].should == '1'
|
||||
expect(@builder.exec(a: 1, b: 2).values[0][0]).to eq('1')
|
||||
end
|
||||
|
||||
it "should allow for a single where" do
|
||||
@builder.where(":a = 1")
|
||||
@builder.exec(a: 1, b: 2).values[0][0].should == '1'
|
||||
expect(@builder.exec(a: 1, b: 2).values[0][0]).to eq('1')
|
||||
end
|
||||
|
||||
it "should allow where chaining" do
|
||||
@builder.where(":a = 1")
|
||||
@builder.where("2 = 1")
|
||||
@builder.exec(a: 1, b: 2).to_a.length.should == 0
|
||||
expect(@builder.exec(a: 1, b: 2).to_a.length).to eq(0)
|
||||
end
|
||||
|
||||
it "should allow order by" do
|
||||
@builder.order_by("A desc").limit(1)
|
||||
.exec(a:1, b:2).values[0][0].should == "2"
|
||||
expect(@builder.order_by("A desc").limit(1)
|
||||
.exec(a:1, b:2).values[0][0]).to eq("2")
|
||||
end
|
||||
it "should allow offset" do
|
||||
@builder.order_by("A desc").offset(1)
|
||||
.exec(a:1, b:2).values[0][0].should == "1"
|
||||
expect(@builder.order_by("A desc").offset(1)
|
||||
.exec(a:1, b:2).values[0][0]).to eq("1")
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user