https://github.com/rails/rails-controller-testing
Brings back `assigns` and `assert_template` to your Rails tests
https://github.com/rails/rails-controller-testing
Keywords from Contributors
activerecord activejob mvc rubygems feature-flag rack rspec feature feature-toggle sinatra
Last synced: about 22 hours ago
JSON representation
Repository metadata
Brings back `assigns` and `assert_template` to your Rails tests
- Host: GitHub
- URL: https://github.com/rails/rails-controller-testing
- Owner: rails
- License: mit
- Created: 2015-05-23T06:25:51.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-06-06T22:13:08.000Z (over 2 years ago)
- Last Synced: 2026-02-24T04:06:39.412Z (8 days ago)
- Language: Ruby
- Homepage: https://github.com/rails/rails-controller-testing
- Size: 330 KB
- Stars: 320
- Watchers: 11
- Forks: 54
- Open Issues: 12
- Releases: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
README.md
Rails::Controller::Testing
This gem brings back assigns to your controller tests as well as assert_template
to both controller and integration tests.
These methods were removed in Rails 5.
Installation
Add this line to your application's Gemfile:
gem 'rails-controller-testing'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails-controller-testing
RSpec
See https://github.com/rspec/rspec-rails/issues/1393.
rspec-rails automatically integrates with this gem since version 3.5.0.
Adding the gem to your Gemfile is sufficient.
If you use an older version of rspec-rails, you can manually include the
modules in your rails_helper.
RSpec.configure do |config|
[:controller, :view, :request].each do |type|
config.include ::Rails::Controller::Testing::TestProcess, :type => type
config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
config.include ::Rails::Controller::Testing::Integration, :type => type
end
end
Outside Rails
For projects and gems using controller tests outside of a Rails application,
invoke the Rails::Controller::Testing.install method inside your test suite
setup to include the required modules on controller test cases.
# test/test_helper.rb
require 'rails-controller-testing'
Rails::Controller::Testing.install
Usage
assigns
assigns allows you to access the instance variables that have been passed to
your views.
class PostsController < ActionController::Base
def index
@posts = Post.all
end
end
class PostControllerTest < ActionController::TestCase
def test_index
get :index
assert_equal Post.all, assigns(:posts)
end
end
assert_template
assert_template allows you to assert that certain templates have been rendered.
class PostControllerTest < ActionController::TestCase
def test_index
get :index
assert_template 'posts/index'
end
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Owner metadata
- Name: Ruby on Rails
- Login: rails
- Email:
- Kind: organization
- Description:
- Website: https://rubyonrails.org/
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/4223?v=4
- Repositories: 116
- Last ynced at: 2023-04-09T03:40:20.529Z
- Profile URL: https://github.com/rails
GitHub Events
Total
- Fork event: 3
- Issues event: 1
- Watch event: 13
Last Year
- Fork event: 2
- Watch event: 10
Committers metadata
Last synced: 5 days ago
Total Commits: 88
Total Committers: 27
Avg Commits per committer: 3.259
Development Distribution Score (DDS): 0.682
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Guo Xiang Tan | t****d@h****m | 28 |
| Rafael Mendonça França | r****a@g****m | 15 |
| eileencodes | e****s@g****m | 5 |
| Ryo Nakamura | r****a@g****m | 4 |
| David Rodríguez | d****z@r****t | 3 |
| John Hawthorn | j****n@h****l | 3 |
| Lucas Mazza | l****a@g****m | 3 |
| Olle Jonsson | o****n@g****m | 3 |
| Prem Sichanugrist | s@s****u | 3 |
| Sean Griffin | s****n@s****m | 3 |
| Thibault BENE | b****t@g****m | 2 |
| Jan David | j****d@a****e | 1 |
| Sam Phippen | s****n@g****m | 1 |
| Akira Matsuda | r****e@d****p | 1 |
| Alex Ghiculescu | a****x@t****o | 1 |
| Anton Rieder | a****r@g****m | 1 |
| Dana Scheider | d****r@g****m | 1 |
| Emil Sågfors | e****s@i****i | 1 |
| František Dvořák | v****i@c****z | 1 |
| Harry Grillo | h****y@r****m | 1 |
| Jeroen Visser | j****1 | 1 |
| Jon Rowe | m****l@j****k | 1 |
| Kasper Timm Hansen | k****h@g****m | 1 |
| Marcus Heng | m****z@g****m | 1 |
| Mike Moore | m****e@b****m | 1 |
| Mingan | ja@m****e | 1 |
| Orien Madgwick | 4****n | 1 |
Committer domains:
- mingan.name: 1
- blowmage.com: 1
- jonrowe.co.uk: 1
- redbassett.com: 1
- civ.zcu.cz: 1
- iki.fi: 1
- tanda.co: 1
- dio.jp: 1
- awesometechnology.de: 1
- seantheprogrammer.com: 1
- sikac.hu: 1
- hawthorn.email: 1
- riseup.net: 1
Issue and Pull Request metadata
Last synced: 11 days ago
Total issues: 38
Total pull requests: 41
Average time to close issues: 4 months
Average time to close pull requests: 4 months
Total issue authors: 34
Total pull request authors: 32
Average comments per issue: 4.63
Average comments per pull request: 2.24
Merged pull request: 29
Bot issues: 0
Bot pull requests: 0
Past year issues: 1
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 1
Past year pull request authors: 0
Past year average comments per issue: 0.0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- jasnow (4)
- jasonfb (2)
- mjhenkes (1)
- MunimIftikhar (1)
- fredngo (1)
- Edouard-chin (1)
- fwininger (1)
- djpate (1)
- connorshea (1)
- mahemoff (1)
- mhartl (1)
- jstoebel (1)
- corymcdonald (1)
- navidemad (1)
- spurnaye (1)
Top Pull Request Authors
- tgxworld (4)
- olleolleolle (4)
- orien (3)
- r7kamura (2)
- Shuiei (2)
- danascheider (1)
- deivid-rodriguez (1)
- lucasmazza (1)
- jeroenvisser101 (1)
- ionut998 (1)
- mingan (1)
- voxik (1)
- jdno (1)
- blowmage (1)
- yuri-zubov (1)
Top Issue Labels
- bug (4)
- more-information-needed (3)
Top Pull Request Labels
Package metadata
- Total packages: 11
-
Total downloads:
- rubygems: 362,042,760 total
- Total docker downloads: 1,221,269,234
- Total dependent packages: 164 (may contain duplicates)
- Total dependent repositories: 35,166 (may contain duplicates)
- Total versions: 29
- Total maintainers: 12
gem.coop: rails-controller-testing
Extracting `assigns` and `assert_template` from ActionDispatch.
- Homepage: https://github.com/rails/rails-controller-testing
- Documentation: http://www.rubydoc.info/gems/rails-controller-testing/
- Licenses: MIT
- Latest release: 1.0.5 (published over 5 years ago)
- Last Synced: 2026-03-02T20:30:41.423Z (about 22 hours ago)
- Versions: 10
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 181,021,380 Total
- Docker Downloads: 610,634,617
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.072%
- Downloads: 0.142%
- Docker downloads count: 0.147%
- Maintainers (12)
debian-13: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Documentation: https://packages.debian.org/trixie/ruby-rails-controller-testing
- Licenses: mit
- Latest release: 1.0.5-2 (published 19 days ago)
- Last Synced: 2026-02-13T13:18:55.467Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.491%
- Stargazers count: 0.958%
- Forks count: 1.008%
rubygems.org: rails-controller-testing
Extracting `assigns` and `assert_template` from ActionDispatch.
- Homepage: https://github.com/rails/rails-controller-testing
- Documentation: http://www.rubydoc.info/gems/rails-controller-testing/
- Licenses: MIT
- Latest release: 1.0.5 (published over 5 years ago)
- Last Synced: 2026-03-02T20:31:10.833Z (about 22 hours ago)
- Versions: 10
- Dependent Packages: 164
- Dependent Repositories: 35,166
- Downloads: 181,021,380 Total
- Docker Downloads: 610,634,617
-
Rankings:
- Downloads: 0.147%
- Dependent repos count: 0.176%
- Docker downloads count: 0.185%
- Dependent packages count: 0.216%
- Average: 1.257%
- Stargazers count: 3.281%
- Forks count: 3.538%
- Maintainers (12)
ubuntu-20.04: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Licenses:
- Latest release: 1.0.4-2 (published 18 days ago)
- Last Synced: 2026-02-13T07:21:14.787Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-11: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Documentation: https://packages.debian.org/bullseye/ruby-rails-controller-testing
- Licenses:
- Latest release: 1.0.5-1 (published 21 days ago)
- Last Synced: 2026-02-13T08:24:10.349Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Licenses:
- Latest release: 1.0.5-2 (published 20 days ago)
- Last Synced: 2026-02-11T06:47:48.723Z (20 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Documentation: https://packages.debian.org/bookworm/ruby-rails-controller-testing
- Licenses:
- Latest release: 1.0.5-2 (published 19 days ago)
- Last Synced: 2026-02-12T23:39:08.074Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
ubuntu-23.10: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Licenses:
- Latest release: 1.0.5-2 (published 18 days ago)
- Last Synced: 2026-02-13T18:31:02.748Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-22.04: ruby-rails-controller-testing
- Homepage: https://github.com/rails/rails-controller-testing
- Licenses:
- Latest release: 1.0.5-2 (published 18 days ago)
- Last Synced: 2026-02-13T13:24:03.986Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- activerecord-jdbc-adapter >= 0 development
- jdbc-sqlite3 >= 0 development
- railties >= 5.0.1.rc1 development
- sqlite3 >= 0 development
- actionpack >= 5.0.1.rc1
- actionview >= 5.0.1.rc1
- activesupport >= 5.0.1.rc1
Score: 30.283779284570997