Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined local variable or method `last_response' #12

Open
rpontes opened this issue Jul 23, 2014 · 14 comments
Open

undefined local variable or method `last_response' #12

rpontes opened this issue Jul 23, 2014 · 14 comments

Comments

@rpontes
Copy link

rpontes commented Jul 23, 2014

Hi, I'm trying use this gem to generate a blueprint.

When I execute bundle exec rspec, show this error:

undefined local variable or method `last_response' for #RSpec::ExampleGroups::UsersRequests::GETApiUsers:0x007fafa6bde540

I'm using Rails 4.1.4, Rspec 3.0.0

jsmestad added a commit to jsmestad/rspec_api_blueprint that referenced this issue Sep 10, 2014
Variable `example` is now passed into hooks in RSpec 3.x; Also include `Rack::Test::Methods` which fixes calderalabs#12
@ndbabb
Copy link

ndbabb commented Dec 2, 2014

+1

@kurtisnelson
Copy link

Is this abandoned?

@kurko
Copy link

kurko commented Feb 19, 2015

@kurtisnelson I got colab access, but I'm short on time right now. I'll be glad to merge PRs, though. Would you have some available time to fix this?

@kurtisnelson
Copy link

I've switched to using the tools to verify my blueprint instead.

@gonzalo-bulnes
Copy link

Hi! The error may occur because some of the spec helpers you use do follow different convention to store the response (e.g. setting response or @response instead of last_response).

Try inserting last_response = @response or last_response = response before the line that's causing the error.

I ran into the exactly opposite scenario: Airborne was expecting @response to be set while RSpec was setting last_response. The following allowed me to work around the issue:

before(:all) do
  get '/example' # does set last_response

  # make Airborne happy :)
  @response = last_response
end

it "says hello" do
  expect_json({ hello: "world" }) # was triggering the error
end

Hence the suggestion.

Regards!

@alexfu
Copy link

alexfu commented Jul 30, 2015

I also have ran into this issue. @gonzalo-bulnes your suggestion doesn't work for me.

@shideneyu
Copy link

I also have ran into this issue. @gonzalo-bulnes your suggestion doesn't work for me.

I have exactly the same issue as everyone, and same as @alexfu , that suggestion does not work for me.

Any update?

@shideneyu
Copy link

According to some sources, adding this line to the spec_helper's Rspec's configuration block is a solution. But I only get a new error then.

config.include Rack::Test::Methods

My new issue:

 Failure/Error: Unable to find matching line from backtrace
 Rack::Test::Error:
  No response yet. Request a page first.

@nilz3ro
Copy link

nilz3ro commented Feb 13, 2016

I have tried the same thing as @shideneyu and I'm running into the same error:

 Rack::Test::Error:
  No response yet. Request a page first.

@kurko
Copy link

kurko commented Feb 17, 2016

If you have some time, try debugging and opening a PR and I'll gladly merge it. I'm not working on a project with this gem at the moment.

@vincilbishop
Copy link

+1

2 similar comments
@jcabas
Copy link

jcabas commented May 6, 2016

+1

@grillermo
Copy link

+1

@qnm
Copy link

qnm commented Nov 22, 2017

I've found that this fork works well: https://github.com/drewcimino/rspec_api_blueprint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.