Based on testrail_client and testrail-ruby gems.
Why? testrail_client requires more setup and testrail-ruby has a lot of missing endpoints which hard to maintain and time consuming to add.
This gem provides both the Testrail::Client to send get and posts requests and an idiomatic interface for testrail v2 API, which ever sits better on you.
Add this line to your application's Gemfile:
gem 'testrail-client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install testrail-client
require 'testrail/api'
client = TestRail::Client::Api.new('https://YourTestrailURL')
client.user = 'YourUserName'
client.password = 'YourPassword'
This is how you would normally use the gem testrail_client, it uses Net::HTTP to send requests to the API
# GET case with ID 1
client.send_get("get_case/1")
# GET cases from Project_id 22, limit to 1 case
client.send_get("get_cases/22&limit1")
# POST update to case with ID 1, update case title
client.send_post("update_case/1",{:title => "new Name"})
# POST delete to case with ID 1, delete the case
client.send_post("delete_case/1")
This is how you would normally use testrail-ruby, the change is on how it is coded, but the functionality stays, plus all endpoints from the testrail API are supported
# GET case with ID 1
client.get_case(1)
# GET cases from Project_id 22, limit to 1 case
client.get_cases(22,{:limit => 1})
# POST update to case with ID 1, update case title
client.update_case(1,{:title => "new Name"})
# POST delete to case with ID 1, delete the case
client.delete_case(1)
As you see, this is more standardized and easy. It follows the testrail documentation.
The add_attachment endpoints require the multipart/form-data
content type and you to send a File, this is how that is done.
# takes result ID and a hash with the file
file = File.open('path/to/file')
client.add_attachment_to_result(1,{:attachment => file})
# takes case ID and a hash with the file
client.add_attachment_to_result_for_case(22,{:attachment => file})
- Test if add_attachment routes actually work
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at mundo03/testrails-client-ruby.
The gem is available as open source under the terms of the MIT License.