[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7727":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":16,"starSnapshotCount":16,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},7727,"rspec-rails","rspec\u002Frspec-rails","rspec","RSpec for Rails 7+","https:\u002F\u002Frspec.info",null,"Ruby",5270,1047,84,43,0,15,40.06,"MIT License",false,"main",[],"2026-06-12 02:01:43","# rspec-rails [![Code Climate][]][code-climate] [![Gem Version][]][gem-version]\n\n`rspec-rails` brings the [RSpec][] testing framework to [Ruby on Rails][]\nas a drop-in alternative to its default testing framework, Minitest.\n\nIn RSpec, tests are not just scripts that verify your application code.\nThey’re also specifications (or _specs,_ for short):\ndetailed explanations of how the application is supposed to behave,\nexpressed in plain English.\n\n## Supported Versions\n\nWe follow a versioning strategy as defined by [RSpec Rails versioning strategy][] the\nTL;DR of which is that we support currently supported versions of Rails, and will\nissue a major version change when removing older versions from support.\n\nAccordingly you should use:\n\n* **[`rspec-rails` 8.x][]** for Rails 8.0 or 7.2.\n* **[`rspec-rails` 7.x][]** for Rails 7.x.\n* **[`rspec-rails` 6.x][]** for Rails 6.1, 7.0 or 7.1.\n* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.\n* **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.\n* **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.\n* **[`rspec-rails` 1.x][]** for Rails 2.x.\n\n[Code Climate]: https:\u002F\u002Fcodeclimate.com\u002Fgithub\u002Frspec\u002Frspec-rails.svg\n[code-climate]: https:\u002F\u002Fcodeclimate.com\u002Fgithub\u002Frspec\u002Frspec-rails\n[Gem Version]: https:\u002F\u002Fbadge.fury.io\u002Frb\u002Frspec-rails.svg\n[gem-version]: https:\u002F\u002Fbadge.fury.io\u002Frb\u002Frspec-rails\n[RSpec]: https:\u002F\u002Frspec.info\u002F\n[Ruby on Rails]: https:\u002F\u002Frubyonrails.org\u002F\n[`rspec-rails` 1.x]: https:\u002F\u002Fgithub.com\u002Fdchelimsky\u002Frspec-rails\n[`rspec-rails` 3.x]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F3-9-maintenance\n[`rspec-rails` 4.x]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F4-1-maintenance\n[`rspec-rails` 5.x]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F5-1-maintenance\n[`rspec-rails` 6.x]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F6-1-maintenance\n[`rspec-rails` 7.x]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F7-1-maintenance\n[`rspec-rails` 8.x]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F8-0-maintenance\n[RSpec Rails versioning strategy]: https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Fblob\u002Fmain\u002Frfcs\u002Fversioning-strategy.md\n\n## Installation\n\n**IMPORTANT** This README \u002F branch refers to the current development build.\nSee the [`8-0-maintenance` branch on Github](https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails\u002Ftree\u002F8-0-maintenance) if you want or require the latest stable release.\n\n1. Add `rspec-rails` to **both** the `:development` and `:test` groups\n   of your app’s `Gemfile`:\n\n   ```ruby\n   # Run against this stable release\n   group :development, :test do\n     gem 'rspec-rails', '~> 8.0.0'\n   end\n\n   # Or, run against the main branch\n   group :development, :test do\n     gem 'rspec-rails', git: 'https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec-rails'\n   end\n   ```\n\n   (Adding it to the `:development` group is not strictly necessary,\n   but without it, generators and rake tasks must be preceded by `RAILS_ENV=test`.)\n\n2. Then, in your project directory:\n\n   ```sh\n   # Download and install\n   $ bundle install\n\n   # Generate boilerplate configuration files\n   # (check the comments in each generated file for more information)\n   $ rails generate rspec:install\n         create  .rspec\n         create  spec\n         create  spec\u002Fspec_helper.rb\n         create  spec\u002Frails_helper.rb\n   ```\n\n## Upgrading\n\nIf your project is already using an older version of `rspec-rails`,\nupgrade to the latest version with:\n\n```sh\n$ bundle update rspec-rails\n```\n\nRSpec follows [semantic versioning](https:\u002F\u002Fsemver.org\u002F),\nwhich means that “major version” upgrades (_e.g.,_ 2.x → 3.x)\ncome with **breaking changes**.\nIf you’re upgrading from version 2.x or below,\nread the [`rspec-rails` upgrade notes][] to find out what to watch out for.\n\nBe sure to check the general [RSpec upgrade notes][] as well.\n\n[`rspec-rails` upgrade notes]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fupgrade\n[RSpec upgrade notes]: https:\u002F\u002Frspec.info\u002Fupgrading-from-rspec-2\u002F\n\n## Usage\n\n### Creating boilerplate specs with `rails generate`\n\n```sh\n# RSpec hooks into built-in generators\n$ rails generate model user\n      invoke  active_record\n      create    db\u002Fmigrate\u002F20181017040312_create_users.rb\n      create    app\u002Fmodels\u002Fuser.rb\n      invoke    rspec\n      create      spec\u002Fmodels\u002Fuser_spec.rb\n\n# RSpec also provides its own spec file generators\n$ rails generate rspec:model user\n      create  spec\u002Fmodels\u002Fuser_spec.rb\n\n# List all RSpec generators\n$ rails generate --help | grep rspec\n```\n\n### Running specs\n\n```sh\n# Default: Run all spec files (i.e., those matching spec\u002F**\u002F*_spec.rb)\n$ bundle exec rspec\n\n# Run all spec files in a single directory (recursively)\n$ bundle exec rspec spec\u002Fmodels\n\n# Run a single spec file\n$ bundle exec rspec spec\u002Fcontrollers\u002Faccounts_controller_spec.rb\n\n# Run a single example from a spec file (by line number)\n$ bundle exec rspec spec\u002Fcontrollers\u002Faccounts_controller_spec.rb:8\n\n# See all options for running specs\n$ bundle exec rspec --help\n```\n\n**Optional:** If `bundle exec rspec` is too verbose for you,\nyou can generate a binstub at `bin\u002Frspec` and use that instead:\n\n ```sh\n $ bundle binstubs rspec-core\n ```\n\n## RSpec DSL Basics (or, how do I write a spec?)\n\nIn RSpec, application behavior is described\n**first in (almost) plain English, then again in test code**, like so:\n\n```ruby\nRSpec.describe 'Post' do           #\n  context 'before publication' do  # (almost) plain English\n    it 'cannot have comments' do   #\n      expect { Post.create.comments.create! }.to raise_error(ActiveRecord::RecordInvalid)  # test code\n    end\n  end\nend\n```\n\nRunning `rspec` will execute this test code,\nand then use the plain-English descriptions\nto generate a report of where the application\nconforms to (or fails to meet) the spec:\n\n```\n$ rspec --format documentation spec\u002Fmodels\u002Fpost_spec.rb\n\nPost\n  before publication\n    cannot have comments\n\nFailures:\n\n  1) Post before publication cannot have comments\n     Failure\u002FError: expect { Post.create.comments.create! }.to raise_error(ActiveRecord::RecordInvalid)\n       expected ActiveRecord::RecordInvalid but nothing was raised\n     # .\u002Fspec\u002Fmodels\u002Fpost.rb:4:in `block (3 levels) in \u003Ctop (required)>'\n\nFinished in 0.00527 seconds (files took 0.29657 seconds to load)\n1 example, 1 failure\n\nFailed examples:\n\nrspec .\u002Fspec\u002Fmodels\u002Fpost_spec.rb:3 # Post before publication cannot have comments\n```\n\nFor an in-depth look at the RSpec DSL, including lots of examples,\nread the official Cucumber documentation for [RSpec Core][].\n\n[RSpec Core]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F3-12\u002Frspec-core\n\n### Helpful Rails Matchers\n\nIn RSpec, assertions are called _expectations,_\nand every expectation is built around a _matcher._\nWhen you `expect(a).to eq(b)`, you’re using the `eq` matcher.\n\nIn addition to [the matchers that come standard in RSpec][],\nhere are some extras that make it easier\nto test the various parts of a Rails system:\n\n| RSpec matcher            | Delegates to        | Available in                    | Notes                                                    |\n| ------------------------ | ------------------- | ------------------------------- | -------------------------------------------------------- |\n| [`be_a_new`][]           |                     | all                             | primarily intended for controller specs                  |\n| [`render_template`][]    | `assert_template`   | request \u002F controller \u002F view     | use with `expect(response).to`                           |\n| [`redirect_to`][]        | `assert_redirect`   | request \u002F controller            | use with `expect(response).to`                           |\n| [`route_to`]             | `assert_recognizes` | routing \u002F controller            | use with `expect(...).to route_to`                       |\n| [`be_routable`]          |                     | routing \u002F controller            | use with `expect(...).not_to be_routable`                |\n| [`have_http_status`][]   |                     | request \u002F controller \u002F feature  |                                                          |\n| [`match_array`][]        |                     | all                             | for comparing arrays of ActiveRecord objects             |\n| [`have_been_enqueued`][] |                     | all                             | requires config: `ActiveJob::Base.queue_adapter = :test` |\n| [`have_enqueued_job`][]  |                     | all                             | requires config: `ActiveJob::Base.queue_adapter = :test` |\n\nFollow the links above for examples of how each matcher is used.\n\n[the matchers that come standard in RSpec]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F3-12\u002Frspec-expectations\u002Fbuilt-in-matchers\n[`be_a_new`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Fnew-record-matcher\n[`render_template`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Frender-template-matcher\n[`redirect_to`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Fredirect-to-matcher\n[`route_to`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Frouting-specs\u002Froute-to-matcher\n[`be_routable`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Frouting-specs\u002Fbe-routable-matcher\n[`have_http_status`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Fhave-http-status-matcher\n[`match_array`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Frelation-match-array\n[`have_been_enqueued`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Fhave-been-enqueued-matcher\n[`have_enqueued_job`]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmatchers\u002Fhave-enqueued-job-matcher\n\n### What else does RSpec Rails add?\n\nFor a comprehensive look at RSpec Rails’ features,\nread the [official Cucumber documentation][].\n\n[official Cucumber documentation]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\n\n## What tests should I write?\n\nRSpec Rails defines ten different _types_ of specs\nfor testing different parts of a typical Rails application.\nEach one inherits from one of Rails’ built-in `TestCase` classes,\nmeaning the helper methods provided by default in Rails tests\nare available in RSpec, as well.\n\n| Spec type      | Corresponding Rails test class        |\n| -------------- | --------------------------------      |\n| [model][]      |                                       |\n| [controller][] | [`ActionController::TestCase`][]      |\n| [mailer][]     | `ActionMailer::TestCase`              |\n| [job][]        |                                       |\n| [view][]       | `ActionView::TestCase`                |\n| [routing][]    |                                       |\n| [helper][]     | `ActionView::TestCase`                |\n| [request][]    | [`ActionDispatch::IntegrationTest`][] |\n| [feature][]    |                                       |\n| [system][]     | [`ActionDispatch::SystemTestCase`][]  |\n\nFollow the links above to see examples of each spec type,\nor for official Rails API documentation on the given `TestCase` class.\n\n> **Note: This is not a checklist.**\n>\n> Ask a hundred developers how to test an application,\n> and you’ll get a hundred different answers.\n>\n> RSpec Rails provides thoughtfully selected features\n> to encourage good testing practices, but there’s no “right” way to do it.\n> Ultimately, it’s up to you to decide how your test suite will be composed.\n\nWhen creating a spec file,\nassign it a type in the top-level `describe` block, like so:\n\n```ruby\n# spec\u002Fmodels\u002Fuser_spec.rb\n\nRSpec.describe User, type: :model do\n...\n```\n\n[request]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Frequest-specs\u002Frequest-spec\n[feature]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Ffeature-specs\u002Ffeature-spec\n[system]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fsystem-specs\u002Fsystem-specs\n[model]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmodel-specs\n[controller]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fcontroller-specs\n[mailer]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fmailer-specs\n[job]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fjob-specs\u002Fjob-spec\n[view]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fview-specs\u002Fview-spec\n[routing]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Frouting-specs\n[helper]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fhelper-specs\u002Fhelper-spec\n[`ActionDispatch::IntegrationTest`]: https:\u002F\u002Fapi.rubyonrails.org\u002Fclasses\u002FActionDispatch\u002FIntegrationTest.html\n[`ActionDispatch::SystemTestCase`]: https:\u002F\u002Fapi.rubyonrails.org\u002Fclasses\u002FActionDispatch\u002FSystemTestCase.html\n[`ActionController::TestCase`]: https:\u002F\u002Fapi.rubyonrails.org\u002Fclasses\u002FActionController\u002FTestCase.html\n[in the appropriate folder]: https:\u002F\u002Frspec.info\u002Ffeatures\u002F8-0\u002Frspec-rails\u002Fdirectory-structure\n\n### System specs, feature specs, request specs–what’s the difference?\n\nRSpec Rails provides some end-to-end (entire application) testing capability\nto specify the interaction with the client.\n\n#### System specs\n\nAlso called **acceptance tests**, **browser tests**, or **end-to-end tests**,\nsystem specs test the application from the perspective of a _human client._\nThe test code walks through a user’s browser interactions,\n\n* `visit '\u002Flogin'`\n* `fill_in 'Name', with: 'jdoe'`\n\nand the expectations revolve around page content.\n\n* `expect(page).to have_text('Welcome')`\n\nBecause system specs are a wrapper around Rails’ built-in `SystemTestCase`,\nthey’re only available on Rails 5.1+.\n(Feature specs serve the same purpose, but without this dependency.)\n\n#### Feature specs\n\nBefore Rails introduced system testing facilities,\nfeature specs were the only spec type for end-to-end testing.\nWhile the RSpec team now [officially recommends system specs][] instead,\nfeature specs are still fully supported, look basically identical,\nand work on older versions of Rails.\n\nOn the other hand, feature specs require non-trivial configuration\nto get some important features working,\nlike JavaScript testing or making sure each test runs with a fresh DB state.\nWith system specs, this configuration is provided out-of-the-box.\n\nLike system specs, feature specs require the [Capybara][] gem.\nRails 5.1+ includes it by default as part of system tests,\nbut if you don’t have the luxury of upgrading,\nbe sure to add it to the `:test` group of your `Gemfile` first:\n\n```ruby\ngroup :test do\n  gem \"capybara\"\nend\n```\n\n[officially recommends system specs]: https:\u002F\u002Frspec.info\u002Fblog\u002F2017\u002F10\u002Frspec-3-7-has-been-released\u002F#rails-actiondispatchsystemtest-integration-system-specs\n[Capybara]: https:\u002F\u002Fgithub.com\u002Fteamcapybara\u002Fcapybara\n\n#### Request specs\n\nRequest specs are for testing the application\nfrom the perspective of a _machine client._\nThey begin with an HTTP request and end with the HTTP response,\nso they’re faster than feature specs,\nbut do not examine your app’s UI or JavaScript.\n\nRequest specs provide a high-level alternative to controller specs.\nIn fact, as of RSpec 3.5, both the Rails and RSpec teams\n[discourage directly testing controllers][]\nin favor of functional tests like request specs.\n\nWhen writing them, try to answer the question,\n“For a given HTTP request (verb + path + parameters),\nwhat HTTP response should the application return?”\n\n[discourage directly testing controllers]: https:\u002F\u002Frspec.info\u002Fblog\u002F2016\u002F07\u002Frspec-3-5-has-been-released\u002F#rails-support-for-rails-5\n\n## Contributing\n\n- [Build details](BUILD_DETAIL.md)\n- [Code of Conduct](CODE_OF_CONDUCT.md)\n- [Detailed contributing guide](CONTRIBUTING.md)\n\nOnce you’ve cloned the repo and [set up the environment](DEVELOPMENT.md),\nyou can run the specs and Cucumber features, or submit a pull request.\n\n## See Also\n\n### RSpec base libraries\n\n* https:\u002F\u002Fgithub.com\u002Frspec\u002Frspec\n\n### Recommended third-party extensions\n\n* [FactoryBot](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Ffactory_bot)\n* [Capybara](https:\u002F\u002Fgithub.com\u002Fteamcapybara\u002Fcapybara)\n  (Included by default in Rails 5.1+.\n  Note that [additional configuration is required][] to use the Capybara DSL\n  anywhere other than system specs and feature specs.)\n\n  [additional configuration is required]: https:\u002F\u002Frubydoc.info\u002Fgems\u002Frspec-rails\u002Ffile\u002FCapybara.md\n","`rspec-rails` 是一个为 Ruby on Rails 7 及以上版本提供的 RSpec 测试框架集成方案，作为默认测试框架 Minitest 的替代品。它允许开发者使用 RSpec 编写详细的、以行为驱动的测试用例，这些用例不仅验证代码的正确性，还充当了应用预期行为的详细说明。项目支持多种 Rails 版本，并且遵循清晰的版本策略来保证与不同版本 Rails 的兼容性。适用于需要更加灵活和可读性强的测试环境的 Rails 项目中，特别是在追求高质量代码和持续集成的过程中。",2,"2026-06-11 03:14:01","top_language"]