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

Makes sure Grape::API behaves as a Rack::App #1893

Merged
merged 2 commits into from
Jul 5, 2019

Conversation

myxoh
Copy link
Member

@myxoh myxoh commented Jul 5, 2019

By calling: 'call' on the first mounted instance rather than the base instance (which is never mounted) which will have the environment information as to where it was mounted

This addresses the underlying issue raised by: #1892

myxoh added 2 commits July 5, 2019 16:46
…e first mounted instance rather than the base instance (which is never mounted) which will have the environment information as to where it was mounted
@@ -31,4 +31,26 @@
input.unlink
end
end

context 'when the app is mounted' do
def app
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pollutess the global namespace, put it into a namespace itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what way @dblock ? I am under the impression that methods defined in a context are contained to that context?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this is news to me. Since when does it work as one would expect?!

require 'rspec'

describe 'Context' do
  def m1
    'm1'
  end

  it 'is m1' do
    expect(m1).to eq 'm1'
  end

  context 'c1' do
  	def m2
	  'c1:m2'
  	end

    it 'is m1' do
      expect(m1).to eq 'm1'
    end

    it 'is m2' do
      expect(m2).to eq 'c1:m2'
    end
  end

  context 'c2' do
	it 'is m2' do
	  expect(m2).to eq 'c1:m2'
    end
  end
end
  1) Context c2 is m2
     Failure/Error: expect(m2).to eq 'c1:m2'
     
     NameError:
       undefined local variable or method `m2' for #<RSpec::ExampleGroups::Context::C2 "is m2" (./spec.rb:27)>
     # ./spec.rb:28:in `block (3 levels) in <top (required)>'

My bad. Ignore me.

@dblock dblock merged commit 164f64f into ruby-grape:master Jul 5, 2019
basjanssen pushed a commit to basjanssen/grape that referenced this pull request Feb 28, 2020
Makes sure Grape::API behaves as a Rack::App by calling: 'call' on the first mounted instance rather than the base instance (which is never mounted) which will have the environment information as to where it was mounted.
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 this pull request may close these issues.

2 participants