Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/r7kamura/rails_kwargs_testing
Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5.
https://github.com/r7kamura/rails_kwargs_testing
rails
Last synced: 3 months ago
JSON representation
Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5.
- Host: GitHub
- URL: https://github.com/r7kamura/rails_kwargs_testing
- Owner: r7kamura
- License: mit
- Created: 2018-04-21T08:37:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-01T10:38:33.000Z (over 4 years ago)
- Last Synced: 2024-10-06T03:56:37.957Z (3 months ago)
- Topics: rails
- Language: Ruby
- Homepage:
- Size: 21.5 KB
- Stars: 18
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RailsKwargsTesting
[![Gem](https://img.shields.io/gem/v/rails_kwargs_testing.svg)](https://rubygems.org/gems/rails_kwargs_testing)
[![Build Status](https://travis-ci.org/r7kamura/rails_kwargs_testing.png)](https://travis-ci.org/r7kamura/rails_kwargs_testing)Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5.
## Installation
Add this line to your application's Gemfile:
```ruby
gem "rails_kwargs_testing"
```And then execute:
```bash
bundle
```Or install it yourself as:
```ruby
gem install rails_kwargs_testing
```## For controller tests
Prepend RailsKwargsTesting::ControllerMethods. Supported options are:
- :flash
- :format
- :params
- :session
- :xhr
- :as### Minitest
```ruby
class ArticlesControllerTest < ::ActionController::TestCase
prepend ::RailsKwargsTesting::ControllerMethodsdef test_create
# `post :create, name: "Hello, World!"` in Rails 4
post :create, params: { name: "Hello, World!" }
assert_equal 200, response.status
end
end
```### RSpec
```ruby
RSpec.describe ArticlesController do
prepend RailsKwargsTesting::ControllerMethodsdescribe "#create" do
subject do
# `post :create, name: "Hello, World!"` in Rails 4
post :create, params: { name: "Hello, World!" }
endit { is_expected.to eq 200 }
end
end
```## For request tests
Prepend RailsKwargsTesting::RequestMethods. Supported options are:
- :env
- :headers
- :params### Minitest
```ruby
class CreateArticleTest < ActionDispatch::IntegrationTest
prepend ::RailsKwargsTesting::RequestMethodsdef test_create_article
# `post "/articles", name: "Hello, World!"` in Rails 4
post "/articles", params: { name: "Hello, World!" }
assert_equal 200, response.status
end
end
```### RSpec
```ruby
RSpec.describe "POST /articles" do
prepend RailsKwargsTesting::RequestMethodssubject do
# `post "/articles", name: "Hello, World!"` in Rails 4
post "/articles", params: { name: "Hello, World!" }
endit { is_expected.to eq 200 }
end
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/r7kamura/rails_kwargs_testing.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).