Lean Testing Ruby SDK
Ruby client for Lean Testing API
You can sign up for a Lean Testing account at https://leantesting.com.
Requirements
- Ruby 2.0 or greater
Installation
Add this line to your application's Gemfile:
gem 'leantesting'
And then execute:
$ bundle
Or install it yourself as:
$ gem install leantesting
Usage
require 'leantesting'
leantesting = LeanTesting::Client.new
leantesting.attachToken('<token>')
# Listing projects
projects = leantesting.projects.all()
# Fetching project bugs
bugs = leantesting.projects.find(123).bugs.all()
Methods
Get Current Token
leantesting.getCurrentTokenAttach New Token
leantesting.attachToken('<token>')Generate Authorization URL
generatedURL = leantesting.auth.generateAuthLink( '<client id>', '<redirect URL>', '<scope>', '<random string>' ) p generatedURLExchange authorization code For access token
token = leantesting.auth.exchangeAuthCode( '<client id>', '<client secret>', 'authorization_code', '<auth code>', '<redirect URL>' ) p token
Get User Information
leantesting.user.getInformationGet User Organizations
leantesting.user.organizations.all.toArray
List All Projects
leantesting.projects.all.toArrayCreate A New Project
newProject = leantesting.projects.create({ 'name' => 'Project135', 'organization_id' => 5779 }) p newProject.dataRetrieve An Existing Project
leantesting.projects.find(3515).dataList Project Sections
leantesting.projects.find(3515).sections.all.toArrayAdding A Project Section
newSection = leantesting.projects.find(3515).sections.create({ 'name' => 'SectionName' }) p newSection.dataList Project Versions
leantesting.projects.find(3515).versions.all.toArrayAdding A Project Version
newVersion = leantesting.projects.find(3515).versions.create({ 'number' => 'v0.3.1104' }) p newVersion.dataList Project Users
leantesting.projects.find(3515).users.all.toArrayList Bug Type Scheme
leantesting.projects.find(3515).bugTypeScheme.all.toArrayList Bug Status Scheme
leantesting.projects.find(3515).bugStatusScheme.all.toArrayList Bug Severity Scheme
leantesting.projects.find(3515).bugSeverityScheme.all.toArrayList Bug Reproducibility Scheme
leantesting.projects.find(3515).bugReproducibilityScheme.all.toArray
List All Bugs In A Project
leantesting.projects.find(3515).bugs.all.toArrayCreate A New Bug
newBug = leantesting.projects.find(3515).bugs.create({ 'title' => 'Something bad happened...', 'status_id' => 1, 'severity_id' => 2, 'project_version_id' => 10242 }) p newBug.dataRetrieve Existing Bug
leantesting.bugs.find(38483).dataUpdate A Bug
updatedBug = leantesting.bugs.update(118622, { 'title' => 'Updated title', 'status_id' => 1, 'severity_id' => 2, 'project_version_id' => 10242 }) p updatedBug.dataDelete A Bug
leantesting.bugs.delete(118622)
- List Bug Comments
ruby leantesting.bugs.find(38483).comments.all.toArray
List Bug Attachments
leantesting.bugs.find(38483)..all.toArrayUpload An Attachment
filePath = '/place/Downloads/Images/1370240743_2294218.jpg' newAttachment = leantesting.bugs.find(38483)..upload(filePath) p newAttachment.dataRetrieve An Existing Attachment
leantesting..find(21515).dataDelete An Attachment
leantesting..delete(75258)
List Platform Types
leantesting.platform.types.all.toArrayRetrieve Platform Type
leantesting.platform.types.find(1).dataList Platform Devices
leantesting.platform.types.find(1).devices.all.toArrayRetrieve Existing Device
leantesting.platform.devices.find(11).dataList OS
leantesting.platform.os.all.toArrayRetrieve Existing OS
leantesting.platform.os.find(1).dataList OS Versions
leantesting.platform.os.find(1).versions.all.toArrayList Browsers
leantesting.platform.browsers.all.toArrayRetrieve Existing Browser
leantesting.platform.browsers.find(1).dataList Browser Versions
leantesting.platform.browsers.find(1).versions.all.toArray
Using Filters
leantesting.projects.find(3515).bugs.all({'limit' => 2, 'page' => 5}).toArrayEntity List Functions
browsers = leantesting.platform.browsers.all p browsers.total p browsers.totalPages p browsers.count p browsers.toArrayEntity List Iterator When used in for loops, entity lists will automatically cycle to first page, regardless of
pagefilter. After ending the loop, the entity list will NOT revert to first page or the initial instancingpagefilter setting in order not to cause useless API request calls.comments = leantesting.bugs.find(38483).comments.all({'limit' => 1}) comments.each{ |page| p page }Entity List Manual Iteration
comments = leantesting.bugs.find(38483).comments.all({'limit' => 1}) p comments.toArray
Will return false if unable to move forwards
comments.next; p comments.toArray
Will return false if already on last page
comments.last; p comments.toArray
Will return false if unable to move backwards
comments.previous; p comments.toArray
Will return false if already on first page
comments.first; p comments.toArray
## Security
Need to report a security vulnerability? Send us an email to [email protected] or go directly to our security bug bounty site [https://hackerone.com/leantesting](https://hackerone.com/leantesting).
## Development
Install dependencies:
```bash
bundle install
Tests
Install dependencies as mentioned above, then you can run the test suite:
rake test