Skip to content

Post/Get methods not available in a before(:all) context #1311

Closed
@whithajess

Description

@whithajess

Trying to perform a get or a post Inside a before(:all) context:

context 'valid request' do
  before(:all) do
    get 'test'
  end
  it { expect(response).to be_ok }
  it { expect(response.body).to include("success='true'")
end

I get this error:

Failure/Error: get 'test'
     RuntimeError:
       @routes is nil: make sure you set it in your tests setup method.

Were as this will work in a before(:each) context (without the intended result)

context 'valid request' do
  before(:each) do
    get 'test'
  end
  it { expect(response).to be_ok }
  it { expect(response.body).to include("success='true'")
end

This was raised after a discussion over on the rspec mailing list if you want some context as to why you would use this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions