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

Already on GitHub? Sign in to your account

Fix #to_rack to handle non-array response bodies. #150

Merged
merged 1 commit into from Jan 22, 2012

Conversation

Projects
None yet
2 participants
Contributor

tsaleh commented Jan 19, 2012

When using #to_rack with a Rails endpoint, such as:

stub_request(:any, %r{api.example.com/.*}).to_rack(Rails.application)

...you receive the following error:

NoMethodError: undefined method `join' for #<ActionDispatch::Response:0x007ffd06e6f540>

Turns out ActionDispatch::Response is in the right. A Rack response body
is only required to implement #each, not #join.

This patch fixes #to_rack to build the body using the #each method.

Fix #to_rack to handle non-array response bodies.
When using #to_rack with a Rails endpoint, such as:

  stub_request(:any, %r{api.example.com/.*}).to_rack(Rails.application)

...you receive the following error:

  NoMethodError: undefined method `join' for #<ActionDispatch::Response:0x007ffd06e6f540>

Turns out ActionDispatch::Response is in the right. A Rack response body
is only required to implement #each, not #join.

This patch fixes #to_rack to build the body using the #each method.
Owner

bblimke commented Jan 22, 2012

Thank you for the patch!

bblimke added a commit that referenced this pull request Jan 22, 2012

Merge pull request #150 from thunderboltlabs/master
Fix #to_rack to handle non-array response bodies.

@bblimke bblimke merged commit d0c58e9 into bblimke:master Jan 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment