Call create method of controller without user interaction

How can I call the create method of a push controller for doing the rspec test that proper thing is getting returned in response?

You can test controllers in two ways:

  1. They can be tested indirectly via an integration test (this will test via the UI)
  2. You can test directly using an RSpec controller test For example:
# spec/controllers/teams_controller_spec.rb

describe TeamsController do
  describe "GET index" do
    it "renders the index template" do
      get :index
      expect(response).to render_template("index")
1 Like