bdd-legacy 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2011-05-13
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,29 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/bdd-legacy.rb
7
+ lib/bdd-legacy.thor
8
+ script/console
9
+ script/console.cmd
10
+ script/destroy
11
+ script/destroy.cmd
12
+ script/generate
13
+ script/generate.cmd
14
+ test/test_bdd-legacy.rb
15
+ test/test_helper.rb
16
+ bin/templates/additions_feature.tt
17
+ bin/templates/addition_steps.tt
18
+ bin/templates/calculator.tt
19
+ bin/templates/env.tt
20
+ bin/templates/generic_browser_steps.tt
21
+ bin/templates/landing_page_feature.tt
22
+ bin/templates/landing_page_steps.tt
23
+ bin/templates/login_feature.tt
24
+ bin/templates/login_steps.tt
25
+ bin/templates/newgem.tt
26
+ bin/templates/rakefile.tt
27
+ bin/templates/sqlhelper.tt
28
+ bin/templates/sqlserver.tt
29
+ bin/bdd-legacy
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on bdd-legacy, see http://bdd-legacy.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = bdd-legacy
2
+
3
+ * http://github.com/#{github_username}/#{project_name}
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIX (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * FIX (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2011 FIXME full name
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'psych'
2
+ require 'rubygems'
3
+ gem 'hoe', '>= 2.1.0'
4
+ require 'hoe'
5
+ require 'fileutils'
6
+ require './lib/bdd-legacy'
7
+
8
+ Hoe.plugin :newgem
9
+ # Hoe.plugin :website
10
+ # Hoe.plugin :cucumberfeatures
11
+
12
+ # Generate all the Rake tasks
13
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
14
+ $hoe = Hoe.spec 'bdd-legacy' do
15
+ self.developer 'Wavell Watson', 'wavell.watson@gmail.com'
16
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
17
+ self.rubyforge_name = self.name # TODO this is default value
18
+ #self.extra_deps = [['activesupport','>= 2.0.2']]
19
+ self.extra_deps = [['activesupport','>= 2.0.2']]
20
+ self.extra_deps = [['bundler', '~> 1.0']]
21
+ self.extra_deps = [['fakeweb', '~> 1.3']]
22
+ self.extra_deps = [['rake', '>= 0.8']]
23
+ self.extra_deps = [['rdoc', '~> 2.5']]
24
+ self.extra_deps = [['rspec', '~> 2.1']]
25
+ self.extra_deps = [['simplecov', '~> 0.3']]
26
+ self.extra_deps = [['thor', '= 0.10.2']]
27
+ self.extra_deps = [['aruba', '>= 0.3.4']]
28
+ self.extra_deps = [['builder', '>= 2.1.2']]
29
+ self.extra_deps = [['capybara', '>= 0.4.1']]
30
+ self.extra_deps = [['diff-lcs', '>= 1.1.2']]
31
+ self.extra_deps = [['gherkin', '>= 2.3.5']]
32
+ self.extra_deps = [['json', '>= 1.4.6']]
33
+ self.extra_deps = [['nokogiri', '>= 1.4.4']]
34
+ self.extra_deps = [['prawn', '= 0.8.4']]
35
+ self.extra_deps = [['prawn-layout', '= 0.8.4']]
36
+ self.extra_deps = [['rack-test', '>= 0.5.7']]
37
+ self.extra_deps = [['rake', '>= 0.8.7']]
38
+ self.extra_deps = [['ramaze', '>= 0']]
39
+ self.extra_deps = [['rspec', '>= 2.5.0']]
40
+ self.extra_deps = [['simplecov', '>= 0.4.1']]
41
+ self.extra_deps = [['sinatra', '>= 1.2.0']]
42
+ self.extra_deps = [['spork', '>= 0.8.4']]
43
+ self.extra_deps = [['syntax', '>= 1.0.0']]
44
+ self.extra_deps = [['term-ansicolor', '>= 1.0.5']]
45
+ self.extra_deps = [['webrat', '>= 0.7.3']]
46
+ self.extra_deps = [['cucumber', '= 0.10.2']]
47
+
48
+
49
+
50
+ end
51
+
52
+ require 'newgem/tasks'
53
+ Dir['tasks/**/*.rake'].each { |t| load t }
54
+
55
+ # TODO - want other tests/tasks run by default? Add them to the list
56
+ # remove_task :default
57
+ # task :default => [:spec, :features]
@@ -0,0 +1,15 @@
1
+ Before do
2
+ @calculator = Calculator.new
3
+ end
4
+
5
+ Given /^I have entered ([0-9]*) into the calculator$/ do |value|
6
+ @calculator.enter( value.to_i )
7
+ end
8
+
9
+ When /^I press add$/ do
10
+ @calculator.add
11
+ end
12
+
13
+ Then /^the result should be ([0-9]*) on the screen$/ do |value|
14
+ @calculator.screen.should equal( value.to_i )
15
+ end
@@ -0,0 +1,10 @@
1
+ Feature: Addition
2
+ In order to avoid silly mistakes
3
+ As a math idiot
4
+ I want to be told the sum of two numbers
5
+
6
+ Scenario: Add two numbers
7
+ Given I have entered 50 into the calculator
8
+ And I have entered 70 into the calculator
9
+ When I press add
10
+ Then the result should be 120 on the screen
data/bin/bdd-legacy ADDED
@@ -0,0 +1,84 @@
1
+ #!/user/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'thor/group'
5
+
6
+ class BddLegacy < Thor::Group
7
+ include Thor::Actions
8
+
9
+ # Define arguments and options
10
+ argument :name
11
+ # class_option :test_framework, :default => :test_unit
12
+
13
+ def self.source_root
14
+ File.dirname(__FILE__)
15
+ end
16
+
17
+ def create_rake_file
18
+ template('templates/rakefile.tt', "#{name}/rakefile.rb")
19
+ end
20
+
21
+ def create_example_feature_file
22
+ template('templates/additions_feature.tt', "#{name}/features/additions.feature")
23
+ end
24
+
25
+ def create_login_feature_file
26
+ template('templates/login_feature.tt', "#{name}/features/login.feature")
27
+ end
28
+
29
+ def create_landing_page_feature_file
30
+ template('templates/landing_page_feature.tt', "#{name}/features/landing_page.feature")
31
+ end
32
+
33
+ def create_generic_steps_file
34
+ template('templates/generic_browser_steps.tt', "#{name}/features/step_definitions/generic_browser_steps.rb")
35
+ end
36
+
37
+ def create_login_steps_file
38
+ template('templates/login_steps.tt', "#{name}/features/step_definitions/login_steps.rb")
39
+ end
40
+
41
+ def create_landing_page_steps_file
42
+ template('templates/landing_page_steps.tt', "#{name}/features/step_definitions/landing_page_steps.rb")
43
+ end
44
+
45
+ def create_example_steps_file
46
+ template('templates/addition_steps.tt', "#{name}/features/step_definitions/addition_steps.rb")
47
+ end
48
+
49
+ def create_env_file
50
+ template('templates/env.tt', "#{name}/features/support/env.rb")
51
+ end
52
+
53
+ def create_sqlserver_file
54
+ template('templates/sqlserver.tt', "#{name}/lib/sqlserver.rb")
55
+ end
56
+
57
+ def create_sqlserver_wrapper_file
58
+ template('templates/sqlhelper.tt', "#{name}/lib/sqlhelper.rb")
59
+ end
60
+
61
+ def create_example_code_file
62
+ template('templates/calculator.tt', "#{name}/lib/calculator.rb")
63
+ end
64
+
65
+ # def create_feature_file
66
+ # template('templates/features.tt', "#{name}/lib/#{name}.rb")
67
+ # end
68
+
69
+ # def create_test_file
70
+ # test = options[:test_framework] == "rspec" ? :spec : :test
71
+ # create_file "#{name}/#{test}/#{name}_#{test}.rb"
72
+ # end
73
+
74
+ # def copy_licence
75
+ # if yes?("Use MIT license?")
76
+ # Make a copy of the MITLICENSE file at the source root
77
+ # copy_file "MITLICENSE", "#{name}/MITLICENSE"
78
+ # else
79
+ # say "Shame on you�", :red
80
+ # end
81
+ # end
82
+ end
83
+
84
+ BddLegacy.start
data/bin/calculator.tt ADDED
@@ -0,0 +1,17 @@
1
+ class Calculator
2
+ def initialize
3
+ @stack = []
4
+ end
5
+
6
+ def enter( value )
7
+ @stack.push value
8
+ end
9
+
10
+ def screen
11
+ @stack[0]
12
+ end
13
+
14
+ def add
15
+ @stack.push( @stack.pop + @stack.pop )
16
+ end
17
+ end
data/bin/env.tt ADDED
@@ -0,0 +1,53 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'calculator'
3
+ require 'sqlserver'
4
+ require 'sqlserver_wrapper'
5
+ require 'capybara/cucumber'
6
+
7
+ Capybara.run_server = false
8
+
9
+ Capybara.register_driver :selenium_firefox do |app|
10
+ Capybara::Driver::Selenium.new(app,:browser=>:firefox)
11
+ end
12
+
13
+ Capybara.register_driver :selenium_ie do |app|
14
+ Capybara::Driver::Selenium.new(app,:browser=>:ie)
15
+ end
16
+
17
+ Capybara.default_driver = :selenium_firefox
18
+
19
+ workingDBServerOpt||=
20
+ workingDBOpt||={}
21
+ workingEnvLinkOpt||={}
22
+
23
+ # change to :test or :dev or :local
24
+ $currentOpt=:local
25
+
26
+ #TODO change strings to import from yaml file
27
+ #TODO exclude yaml file from check-in
28
+ # the below server name will either be in the format of 'MYSERVERNAME' or 'MYSERVERNAME\DATABASEINSTANCE'
29
+ # depending on how your sql servr is set up
30
+ workingDBServerOpt={:dev => 'MYDEVDATABASESERVER',
31
+ :test => 'MYTESTDATABASESERVER',
32
+ :local => 'MYLOCALDATABASE'}
33
+ workingDBOpt={:dev => 'devdb',
34
+ :test => 'tstdb',
35
+ :local => 'devdb'}
36
+ # if you have a list of links after logging in with a single sign on account,
37
+ # you may also have a page of separate links for local/dev/test/prod etc
38
+ workingEnvLinkOpt = {:local => 'Welcome',
39
+ :dev => 'Welcome',
40
+ :test => 'Welcome'}
41
+
42
+ $workingDBServer = workingDBServerOpt[$currentOpt]
43
+ $workingDB = workingDBOpt[$currentOpt]
44
+ $workingAppUser='myapplicationusername'
45
+ $workingAppPW='myapplicationpw'
46
+ $workingDBUser='mydatabaseusername'
47
+ $workingDBPW='mydatabasepw'
48
+ # Change this to the domain of your web server. Don't add the full url
49
+ $workingAppHostLink='http://localhost'
50
+ # add the url of your login page
51
+ $workingAppLoginRoute='/welcome/logon.asp'
52
+ $workingEnvLink = workingEnvLinkOpt[$currentOpt]
53
+
@@ -0,0 +1,66 @@
1
+ Before('@firefox') do
2
+
3
+ Capybara.app_host = $workingAppHostLink
4
+
5
+ Capybara.current_driver = :selenium_firefox
6
+ visit $workingAppLoginRoute
7
+
8
+ end
9
+
10
+ After('@firefox') do
11
+ Capybara.use_default_driver
12
+ end
13
+
14
+ Before('@ie') do
15
+ Capybara.app_host = $workingAppHostLink
16
+ Capybara.current_driver = :selenium_ie
17
+ visit $workingAppLoginRoute
18
+ end
19
+
20
+ After('@ie') do
21
+ Capybara.use_default_driver
22
+ end
23
+
24
+ When /^I press "([^"]*)"$/ do |arg1|
25
+ continue = find_by_id arg1
26
+ continue.click
27
+ end
28
+
29
+ #example of making something ie specific
30
+ Given /^I press "([^"]*)" in internet explorer$/ do |arg1|
31
+ mybutton = find_button arg1
32
+ mybutton.click
33
+ end
34
+
35
+ Then /^I select the link "([^"]*)"$/ do |arg1|
36
+ click_link arg1
37
+ end
38
+
39
+
40
+ Then /^I should see "([^"]*)"$/ do |arg1|
41
+ page.should have_content(arg1)
42
+ end
43
+
44
+ Then /^I should not see "([^"]*)"$/ do |arg1|
45
+ page.should_not have_content(arg1)
46
+ end
47
+
48
+ Given /^I evaluate the script for "([^"]*)"$/ do |arg1|
49
+ page.evaluate_script arg1
50
+ end
51
+
52
+ # popup example
53
+ Then /^within the "([^"]*)" window, I should see "([^"]*)"$/ do |arg1, arg2|
54
+ page.within_window(arg1){page.should have_content(arg2)}
55
+ end
56
+
57
+ Then /^within the "([^"]*)" window, I select "([^"]*)"$/ do |arg1, arg2|
58
+ page.within_window(arg1) do
59
+ myelem = page.find(:xpath, "//*[@value='#{arg2}']")
60
+ myelem.click
61
+ end
62
+ end
63
+
64
+ Then /^I should see "([^"]*)" in a field$/ do |arg1|
65
+ page.should have_xpath("//*[@value='#{arg1}']")
66
+ end
@@ -0,0 +1,23 @@
1
+ Feature: Landing Page
2
+ In order to work in my app
3
+ As my app's personnel
4
+ I need to land on the home page
5
+
6
+ @firefox
7
+ Scenario: Land on the landing page page
8
+ Given I am logged in
9
+ Then I should see "My App's greeting"
10
+ And I should see "Something Else that I want to check"
11
+
12
+ @firefox @sql_insert_example
13
+ Scenario: Landing page messages
14
+ Given I am logged in
15
+ And I have a message that says "Heyas" waiting for me
16
+ Then I should see "Heyas"
17
+
18
+ @ie @sql_insert_example
19
+ Scenario: Delete Home page messages
20
+ Given I have a message that says "Heyas" waiting for me
21
+ And I am logged in
22
+ And I press "Remove" in internet explorer
23
+ Then I should not see "Heyas"
@@ -0,0 +1,30 @@
1
+ After('@sql_insert_example') do |s|
2
+ delete_message
3
+ end
4
+
5
+ # This is an example. If you need to do setup and teardown data in your database
6
+ # obviously you'll have your own table replace 'messages' below
7
+ def insert_message()
8
+ insertsql||=[]
9
+ insertsql[0]= <<-eos
10
+ INSERT INTO [Messages]
11
+ ([Message])
12
+ VALUES
13
+ ('Heyas')
14
+ eos
15
+
16
+ insertsql[1]= 'select @@IDENTITY'
17
+
18
+ results, field_lists = SqlServer.helperqueries(insertsql)
19
+
20
+ @insertID = results[1][0][0] #get *first* result from *second* query
21
+ end
22
+
23
+ def delete_message
24
+ result = SqlServer.helperquery("delete from Messages where Messageid = #{@insertID}")
25
+ end
26
+
27
+ Given /^I have a message that says "([^"]*)" waiting for me$/ do |arg1|
28
+ insert_message
29
+ end
30
+
@@ -0,0 +1,13 @@
1
+ Feature: Login
2
+ In order to log into my app
3
+ As my app's personnel
4
+ I want to put in my user name and password
5
+
6
+ @firefox
7
+ Scenario: Log in
8
+ Given I enter my username
9
+ And I enter my password
10
+ When I press Continue
11
+ Then I should see the environment link
12
+ And I select the environment link
13
+
@@ -0,0 +1,33 @@
1
+ # if you have trouble finding a button using the text of the button
2
+ # in either firefox or ie, try using the id
3
+ When /^I press login$/ do
4
+ login = find_by_id 'loginid'
5
+ login.click
6
+ end
7
+
8
+
9
+ Given /^I enter my username$/ do
10
+ fill_in 'Username', :with => $workingAppUser
11
+ end
12
+
13
+ Given /^I enter my password$/ do
14
+ fill_in 'Password', :with => $workingAppPW
15
+ end
16
+
17
+ Then /^I should see the environment link$/ do
18
+ page.should have_content($workingEnvLink)
19
+ end
20
+
21
+ Then /^I select the environment link$/ do
22
+ click_link $workingEnvLink
23
+ end
24
+
25
+ Given /^I am logged in$/ do
26
+ steps %Q{
27
+ Given I enter my username
28
+ And I enter my password
29
+ When I press Continue
30
+ Then I should see the environment link
31
+ And I select the environment link
32
+ }
33
+ end
data/bin/newgem.tt ADDED
@@ -0,0 +1,2 @@
1
+ class <%= name.capitalize %>
2
+ end
data/bin/rakefile.tt ADDED
@@ -0,0 +1,5 @@
1
+ require 'cucumber/rake/task'
2
+
3
+ Cucumber::Rake::Task.new do |t|
4
+ t.cucumber_opts = "--format pretty"
5
+ end
data/bin/sqlhelper.tt ADDED
@@ -0,0 +1,40 @@
1
+ require 'sqlserver'
2
+
3
+ # example use
4
+ # insertsql||=[]
5
+ # insertsql[0]= <<-eos
6
+ # INSERT INTO [Messages]
7
+ # ([Message])
8
+ # VALUES
9
+ # ('Do your hours')
10
+ # eos
11
+ # insertsql[1]= 'select @@IDENTITY'
12
+ # results, field_lists = SqlServer.helperqueries(insertsql)
13
+ # @insertID = results[1][0][0] #get *first* result from *second* query
14
+
15
+ class SqlServer
16
+
17
+ #multiple statements need an array
18
+ #don't error out on statements that don't return anything
19
+ def self.helperqueries(sql=[])
20
+ return [],[] if sql.empty?
21
+
22
+ db = SqlServer.new($workingDBServer, $workingDBUser, $workingDBPW)
23
+ db.open($workingDB)
24
+ data, field_lists = db.queries(sql)
25
+ db.close
26
+ return data, field_lists
27
+ end
28
+
29
+
30
+ def self.helperquery(sql)
31
+ db = SqlServer.new($workingDBServer, $workingDBUser, $workingDBPW)
32
+ db.open($workingDB)
33
+ db.query(sql)
34
+ field_names = db.fields
35
+ data = db.data
36
+ db.close
37
+ return data, field_names
38
+ end
39
+ end
40
+
data/bin/sqlserver.tt ADDED
@@ -0,0 +1,118 @@
1
+ require 'win32ole'
2
+
3
+ # example use
4
+ # db = SqlServer.new
5
+ # db.open
6
+ # db.query("SELECT PLAYER FROM PLAYERS WHERE TEAM = 'REDS';")
7
+ # field_names = db.fields
8
+ # players = db.data
9
+ # db.close
10
+
11
+ class SqlServer
12
+
13
+ # This class manages database connection and queries
14
+ attr_accessor :connection, :data, :fields
15
+ attr_writer :username, :password
16
+
17
+ def initialize(host, username = 'sa', password='')
18
+ @connection = nil
19
+ @data = nil
20
+ @host = host
21
+ @username = username
22
+ @password = password
23
+ end
24
+
25
+ def open(database)
26
+ # Open ADO connection to the SQL Server database
27
+ connection_string = "Provider=SQLOLEDB.1;"
28
+ connection_string << "Persist Security Info=False;"
29
+ connection_string << "User ID=#{@username};"
30
+ connection_string << "password=#{@password};"
31
+ connection_string << "Initial Catalog=#{database};"
32
+ connection_string << "Data Source=#{@host};"
33
+ connection_string << "Network Library=dbmssocn"
34
+ @connection = WIN32OLE.new('ADODB.Connection')
35
+ @connection.Open(connection_string)
36
+ end
37
+
38
+ def queries(sql=[])
39
+ # debugger
40
+ return [],[] if sql.empty?
41
+
42
+ results ||=[]
43
+ field_lists ||=[]
44
+ # debugger
45
+ sql.each do |s|
46
+ result, fields = query_field_data(s)
47
+ results << result
48
+ field_lists << fields
49
+ end
50
+ return results, field_lists
51
+ end
52
+
53
+
54
+ def query_field_data(sql)
55
+ # Create an instance of an ADO Recordset
56
+ recordset = WIN32OLE.new('ADODB.Recordset')
57
+ # Open the recordset, using an SQL statement and the
58
+ # existing ADO connection
59
+ recordset.Open(sql, @connection)
60
+ # Create and populate an array of field names
61
+ # debugger
62
+ fields = []
63
+ recordset.Fields.each do |field|
64
+ fields << field.Name
65
+ end
66
+ begin
67
+ # Move to the first record/row, if any exist
68
+ recordset.MoveFirst
69
+ # Grab all records
70
+ data = recordset.GetRows
71
+ # record only needs to be closed if movefirst doesn't cause an error
72
+ recordset.Close
73
+ rescue
74
+ data = []
75
+ end
76
+
77
+ # An ADO Recordset's GetRows method returns an array
78
+ # of columns, so we'll use the transpose method to
79
+ # convert it to an array of rows
80
+ data = data.transpose
81
+ return data, fields
82
+ end
83
+
84
+
85
+ def query(sql)
86
+ # Create an instance of an ADO Recordset
87
+ recordset = WIN32OLE.new('ADODB.Recordset')
88
+ # Open the recordset, using an SQL statement and the
89
+ # existing ADO connection
90
+ recordset.Open(sql, @connection)
91
+ # Create and populate an array of field names
92
+ # debugger
93
+ @fields ||=[]
94
+ recordset.Fields.each do |field|
95
+ @fields << field.Name
96
+ end
97
+ begin
98
+ # Move to the first record/row, if any exist
99
+ recordset.MoveFirst
100
+ # Grab all records
101
+ @data = recordset.GetRows
102
+ # record only needs to be closed if movefirst doesn't cause an error
103
+ recordset.Close
104
+ rescue
105
+ @data = []
106
+ end
107
+ # An ADO Recordset's GetRows method returns an array
108
+ # of columns, so we'll use the transpose method to
109
+ # convert it to an array of rows
110
+ @data = @data.transpose
111
+ return @data, @fields
112
+ end
113
+
114
+ def close
115
+ @connection.Close
116
+ end
117
+ end
118
+