In this post, I explained how to test sql procedures created for Microsoft SQL server. As tSQLt is not true programming language, I found that fact as obstacle for my testing process. For example, integrating created test scripts into existing continuous integration system based on Jenkins was practically impossible.
Because of Ruby support for testing ecosystem, my goal was to access to Microsoft SQL procedures using Ruby. Using PlasticLizard gist example and IronRuby, I managed to do that.
Database and procedures that I tested were deployed on local Microsoft SQL server, Express version. Authentication mode to SQL server was windows authentication, which means that ruby test script automatically used my windows server 2012 credentials.
In that way, I managed to unlock Ruby testing ecosystem to the Microsoft SQL server world.
Thank You for the post its really helpful , i have couple of questions though :
1. How am i setting up the connection string ,so as per my understanding I will put the value here :
connection_string = source_connection_string(source_server, source_database)
connection = System::Data::SqlClient::SqlConnection.new(connection_string)
command = System::Data::SqlClient::SqlCommand.new(query, connection)
2. How do i trigger a package from Ruby .
I plan to trigger the ruby jobs from Cucumber and from there trigger the SSIS package , lets see how it works .
Thanks,
Swarnava
Hi Swarnava Datta!
Thanks for reading the post!
1. You just call (with example parameters for local sql express database)
`SqlServerDataReader.read_data(“your_microsoft_computer_name\SQLEXPRESS”, “database_name”, “select * from users;”)
2. For start, use Iron irb session:
>>c:\IronRuby1.1\bin\iirb.bat
>>require ‘sql_server_data_reader.rb’
>> => true
And just call method from 1.
For Cucumber, be sure that you install it in IronRuby. After that, write require statement in Cucumber env.rb initialization file.
Regards, Karlo.