No commit activity in last 3 years
No release in over 3 years
Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 5.0
~> 10.0

Runtime

 Project Readme

RailsKwargsTesting

Gem Build Status

Provides Rails 5 compatible testing methods for gradual migration from Rails 4 to 5.

Installation

Add this line to your application's Gemfile:

gem "rails_kwargs_testing"

And then execute:

bundle

Or install it yourself as:

gem install rails_kwargs_testing

For controller tests

Prepend RailsKwargsTesting::ControllerMethods. Supported options are:

  • :flash
  • :format
  • :params
  • :session
  • :xhr
  • :as

Minitest

class ArticlesControllerTest < ::ActionController::TestCase
  prepend ::RailsKwargsTesting::ControllerMethods

  def test_create
    # `post :create, name: "Hello, World!"` in Rails 4
    post :create, params: { name: "Hello, World!" }
    assert_equal 200, response.status
  end
end

RSpec

RSpec.describe ArticlesController do
  prepend RailsKwargsTesting::ControllerMethods

  describe "#create" do
    subject do
      # `post :create, name: "Hello, World!"` in Rails 4
      post :create, params: { name: "Hello, World!" }
    end

    it { is_expected.to eq 200 }
  end
end

For request tests

Prepend RailsKwargsTesting::RequestMethods. Supported options are:

  • :env
  • :headers
  • :params

Minitest

class CreateArticleTest < ActionDispatch::IntegrationTest
  prepend ::RailsKwargsTesting::RequestMethods

  def 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

RSpec.describe "POST /articles" do
  prepend RailsKwargsTesting::RequestMethods

  subject do
    # `post "/articles", name: "Hello, World!"` in Rails 4
    post "/articles", params: { name: "Hello, World!" }
  end

  it { 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.