Sha256: 88c83da1efed0c55fb970ea2b9336260ee24842a70be822a4ebfb1ed2b42fc4c

Contents?: true

Size: 544 Bytes

Versions: 11

Compression:

Stored size: 544 Bytes

Contents

require "spec_helper"

describe "Simple::SQL.ask into: :struct" do
  let!(:users) { 1.upto(USER_COUNT).map { create(:user) } }

  it "calls the database" do
    r = SQL.ask("SELECT COUNT(*) AS count FROM users", into: :struct)
    expect(r.count).to eq(2)
    expect(r.class.members).to eq([:count])
  end

  it "reuses the struct" do
    r1 = SQL.ask("SELECT COUNT(*) AS count FROM users", into: :struct)
    r2 = SQL.ask("SELECT COUNT(*) AS count FROM users", into: :struct)
    expect(r1.class.object_id).to eq(r2.class.object_id)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
simple-sql-0.4.9 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.8 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.7 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.5 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.4 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.3 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.2 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.1 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.4.0 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.3.7 spec/simple/sql_ask_into_struct_spec.rb
simple-sql-0.3.6 spec/simple/sql_ask_into_struct_spec.rb