File: reader_spec.rb

package info (click to toggle)
ruby-dataobjects-mysql 0.10.17-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 372 kB
  • sloc: ansic: 1,420; ruby: 653; sh: 30; makefile: 13
file content (34 lines) | stat: -rw-r--r-- 958 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# encoding: utf-8

require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
require 'data_objects/spec/shared/reader_spec'

describe DataObjects::Mysql::Reader do
  it_should_behave_like 'a Reader'

  describe 'reading database metadata' do

    subject { reader }

    let(:connection) { DataObjects::Connection.new(CONFIG.uri) }
    let(:command)    { connection.create_command(sql) }
    let(:reader)     { command.execute_reader }

    after do
      reader.close
      connection.close
    end

    describe 'showing correct column field names for a table' do
      let(:sql)     { 'SHOW COLUMNS FROM `widgets`' }
      its(:fields)  { should == [ "Field", "Type", "Null", "Key", "Default", "Extra" ] }
    end

    describe 'showing correct column field names for variables' do
      let(:sql)     { "SHOW VARIABLES LIKE 'character_set_connection'" }
      its(:fields)  { should == [ 'Variable_name', 'Value' ] }
    end

  end

end