Created
November 20, 2012 01:05
-
-
Save blackxored/4115275 to your computer and use it in GitHub Desktop.
RSpec::Rails, Capybara, Rack::Test errors on last_response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./spec/support/api/helper.rb | |
module ApiHelper | |
include Rack::Test::Methods | |
def app | |
Rails.application | |
end | |
end | |
RSpec.configure do |c| | |
c.include ApiHelper, :type => :api | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApiHelper | |
def self.included(base) | |
base.__send__(:include, Rack::Test::Methods) | |
end | |
def app | |
Rails.application | |
end | |
end | |
RSpec.configure do |c| | |
c.include ApiHelper, :type => :api | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) /api/v0/projects list of projects returns a JSON array of projects scoped by this user | |
Failure/Error: expect(last_response.status).to eq(200) | |
NameError: | |
undefined local variable or method `last_response' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xd219348> | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-expectations-2.12.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/actionpack-3.2.9/lib/action_dispatch/testing/assertions/routing.rb:176:in `method_missing' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/actionpack-3.2.9/lib/action_dispatch/testing/integration.rb:386:in `method_missing' | |
# ./spec/apis/v0/projects_spec.rb:19:in `block (3 levels) in <top (required)>' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:114:in `instance_eval' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:114:in `block in run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:254:in `with_around_each_hooks' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example.rb:111:in `run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:388:in `block in run_examples' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:384:in `map' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:384:in `run_examples' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:369:in `run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:370:in `block in run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:370:in `map' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/example_group.rb:370:in `run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:28:in `map' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:28:in `block in run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/reporter.rb:34:in `report' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/command_line.rb:25:in `run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:66:in `rescue in run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:62:in `run' | |
# /home/adrian/.rvm/gems/ruby-1.9.3-p286-perf@searchfuse/gems/rspec-core-2.12.0/lib/rspec/core/runner.rb:8:in `block in autorun' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./spec/apis/v0/projects_spec.rb | |
require 'spec_helper' | |
describe "/api/v0/projects", :type => :api do | |
let(:user) { create_user! } | |
let(:token) { user.authentication_token } | |
before do | |
@project = FactoryGirl.create(:project, :name => 'FirstProj') | |
user.account.projects << @project | |
user.account.save! | |
end | |
context "list of projects" do | |
let(:url) { "/api/v0/projects" } | |
it "returns a JSON array of projects scoped by this user" do | |
projects_json = user.projects.to_json | |
get "#{url}.json", :api_token => token | |
expect(last_response.status).to eq(200) | |
projects = JSON.parse(last_response.body)['projects'] | |
projects.any? { |p| p['name'] == 'FirstProj' }.should be | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2019 - still a problem - even if using 'response' in my case. Is there no generator which can set up all the boilerplate so it "just works"?? I'd like to spend time writing-tests, not hours trying to get the test-framework to function.