Class: SQLite3::TestDatabaseReadwrite
- Defined in:
- lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb,
lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_insert_readwrite_database ⇒ Object
- #test_open_readwrite_database ⇒ Object
- #test_open_readwrite_not_exists_database ⇒ Object
- #test_open_readwrite_readonly_database ⇒ Object
Methods inherited from TestCase
Instance Method Details
#setup ⇒ Object
5 6 7 8 9 10 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb', line 5 def setup File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db') @db = SQLite3::Database.new('test-readwrite.db') @db.execute("CREATE TABLE foos (id integer)") @db.close end |
#teardown ⇒ Object
12 13 14 15 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb', line 12 def teardown @db.close unless @db.closed? File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db') end |
#test_insert_readwrite_database ⇒ Object
35 36 37 38 39 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb', line 35 def test_insert_readwrite_database @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true) @db.execute("INSERT INTO foos (id) VALUES (12)") assert @db.changes == 1 end |
#test_open_readwrite_database ⇒ Object
17 18 19 20 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb', line 17 def test_open_readwrite_database @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true) assert !@db.readonly? end |
#test_open_readwrite_not_exists_database ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb', line 28 def test_open_readwrite_not_exists_database File.unlink 'test-readwrite.db' assert_raise(SQLite3::CantOpenException) do @db = SQLite3::Database.new('test-readwrite.db', :readonly => true) end end |
#test_open_readwrite_readonly_database ⇒ Object
22 23 24 25 26 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb', line 22 def test_open_readwrite_readonly_database assert_raise(RuntimeError) do @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true, :readonly => true) end end |