Skip to content

Commit

Permalink
DEV: improve test_query_decorator (#16)
Browse files Browse the repository at this point in the history
* improve test_query_decorator

* mysql
  • Loading branch information
ermolaev committed Jul 20, 2020
1 parent 86071d6 commit 2d23167
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/mini_sql/builder_tests.rb
Expand Up @@ -95,9 +95,10 @@ def amount_price
end

def test_query_decorator
builder = @connection.build("select 20 price, 3 quantity")
builder = @connection.build("select :price AS price, :quantity AS quantity /*where*/")
builder.where('1 = :one', one: 1)

r = builder.query_decorator(ProductDecorator).first
r = builder.query_decorator(ProductDecorator, price: 20, quantity: 3).first
assert_equal(60, r.amount_price)
end
end
8 changes: 8 additions & 0 deletions test/mini_sql/mysql/builder_test.rb
Expand Up @@ -95,4 +95,12 @@ def test_set

assert_equal([7, 8], @connection.query_single("select * from ta"))
end

def test_query_decorator
builder = @connection.build("select :price AS price, :quantity AS quantity from for_testing /*where*/")
builder.where('1 = :one', one: 1)

r = builder.query_decorator(ProductDecorator, price: 20, quantity: 3).first
assert_equal(60, r.amount_price)
end
end

0 comments on commit 2d23167

Please sign in to comment.