Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/greena13/test_assistant
A toolbox for increased testing efficiency with RSpec
https://github.com/greena13/test_assistant
assertions debugger rails rspec testing-tools
Last synced: 12 days ago
JSON representation
A toolbox for increased testing efficiency with RSpec
- Host: GitHub
- URL: https://github.com/greena13/test_assistant
- Owner: greena13
- License: mit
- Created: 2016-05-30T13:26:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-14T13:04:14.000Z (almost 6 years ago)
- Last Synced: 2024-04-24T23:20:29.922Z (9 months ago)
- Topics: assertions, debugger, rails, rspec, testing-tools
- Language: Ruby
- Size: 44.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
TestAssistant
RSpec toolbox for writing and diagnosing Ruby on Rails tests, faster.
## Features
* Light-weight, scoped, lazily executed and composable tool-box, so you only include the features you want to use, when you want to use them with no unnecessary overhead
* Automatic reporting of the context around failing tests, so you don't have to re-run them with additional logging or a debugger## Installation
Add this line to your application's Gemfile:
group :test do
gem 'test_assistant'
endAnd then execute:
$ bundle
## Usage
Test assistant requires access to the RSpec configuration object, so add the following to either `rails_helper.rb` or `spec_helper.rb`:
```ruby
RSpec.configure do |config|
# other rspec configurationTestAssistant.configure(config) do |ta_config|
# test assistant configuration here
end
end
```## Failure Reporting
### Rendering a response context when a test fails
Test Assistant can automatically render the server response in your browser when a test fails and you have applied a nominated tag.
```ruby
TestAssistant.configure(config) do |ta_config|
ta_config.render_failed_responses tag: :focus, type: :request
end
``````ruby
RSpec.describe 'making some valid request', type: :request do
context 'some important context' do
it 'should return a correct result', focus: true do
# failing assertions
end
end
end
```### Invoking a debugger when a test fails
It's possible to invoke a debugger (`pry` is default, but fallback is to `byebug` and then `debugger`) if a test fails. This gives you access to some of the scope that the failing test ran in, allowing you to inspect objects and test variations of the failing assertion.
The `debug_failed_responses` accepts a the following options:
* `tag: :` (default is `:debugger`)
* `type: :` (default: nil - matches all test types) options.```ruby
TestAssistant.configure(config) do |ta_config|
ta_config.debug_failed_responses tag: :debugger
end
``````ruby
RSpec.describe 'making some valid request', type: :request do
context 'some important context' do
it 'should return a correct result', debugger: true do
# failing assertions
end
end
end
```## Contributing
1. Fork it ( https://github.com/greena13/test_assistant/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request