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

Allow multiple before_each block #1196

Closed
wants to merge 1 commit into from
Closed

Allow multiple before_each block #1196

wants to merge 1 commit into from

Conversation

qcam
Copy link
Contributor

@qcam qcam commented Nov 4, 2015

Hi forks,

Currently if I stub first_method and second_method in different before_each blocks, only the second_method got stubbed.

describe "GET /users/me' do
  it 'returns user information" do
    Grape::Endpoint.before_each do |endpoint|
      allow(endpoint).to receive(:authenticate_user!).and_return(true)
    end

    Grape::Endpoint.before_each do |endpoint|
      allow(endpoint).to receive(:user).and_return(someone)
    end

    get '/users/me'
  end
end

Can Grape support this? I have added some code as well as tests.

@dblock
Copy link
Member

dblock commented Nov 4, 2015

The change looks good. Please update CHANGELOG and squash your commits.

- Turn @before_each class variables to array.
- Add specs.
- Change rubocop config
- Update CHANGELOG
@qcam
Copy link
Contributor Author

qcam commented Nov 4, 2015

@dblock thanks, CHANGELOG updated and commits squashed as per your request. 😄

@@ -5,6 +5,7 @@

* Your contribution here.

* [#1196](https://github.com/ruby-grape/grape/pull/1196): Allow multiple before each blocks- [@huynhquancam](https://github.com/huynhquancam).
Copy link
Member

Choose a reason for hiding this comment

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

Missing space before -. Nitpick :)

@dblock
Copy link
Member

dblock commented Nov 6, 2015

Merged via ab2f0dc. Thanks!

@dblock dblock closed this Nov 6, 2015
@qcam
Copy link
Contributor Author

qcam commented Nov 6, 2015

Great! Thanks!

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