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

Regression? Class variable access in a helper function. #836

Closed
dblock opened this issue Dec 1, 2014 · 1 comment
Closed

Regression? Class variable access in a helper function. #836

dblock opened this issue Dec 1, 2014 · 1 comment
Labels

Comments

@dblock
Copy link
Member

dblock commented Dec 1, 2014

  context 'with static variable access' do
    before do
      @@static_variable = 42

      subject.helpers do
        def get_static_variable
          @@static_variable
        end
      end

      subject.get do
        get_static_variable
      end
    end
    it 'preserves self' do
      get '/'
      expect(last_response.status).to eq 200
      expect(last_response.body).to eq '42'
    end
  end
  1) Grape::API with static variable access preserves self
     Failure/Error: @@static_variable
     NameError:
       uninitialized class variable @@static_variable in #<Module:0x007fb4646c72b0>
     # ./spec/grape/api_spec.rb:2720:in `get_static_variable'
     # ./spec/grape/api_spec.rb:2725:in `block (4 levels) in <top (required)>'
     # ./lib/grape/endpoint.rb:47:in `call'

At least needs to be documented in UPGRADING.

@dblock dblock added the bug? label Dec 1, 2014
dblock added a commit to dblock/grape that referenced this issue Dec 1, 2014
@dblock
Copy link
Member Author

dblock commented Dec 16, 2014

Documented this in UPGRADING in b8b0ef1. Will leave this by design.

@dblock dblock closed this as completed Dec 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant