Skip to content

Commit

Permalink
Do not wrap the :headers / :xhr attributes within :params (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
joel authored Sep 30, 2021
1 parent b908eda commit 0a27bdd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rails5/spec_converter/hash_rewriter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails5/spec_converter/node_textifier'

class HashRewriter
OUTSIDE_PARAMS_KEYS = %i(format xhr)
OUTSIDE_PARAMS_KEYS = %i(format headers xhr)

attr_reader :hash_node, :original_indent

Expand Down
26 changes: 26 additions & 0 deletions spec/rails5/text_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,32 @@ def quiet_transform(text)
get :show, headers: { 'X-BANANA' => 'pancake' }
RUBY
end

describe 'when the :headers key is present' do
it 'does not wrap it within :params' do
result = transform(<<-RUBY.strip_heredoc)
get :show, id: 10, headers: { 'X-BANANA' => 'pancake' }
RUBY

expect(result).to eq(<<-RUBY.strip_heredoc)
get :show, params: { id: 10 }, headers: { 'X-BANANA' => 'pancake' }
RUBY
end
end
end

describe 'xhr param' do
describe 'when :xhr key is present' do
it 'does not wrap it within :params' do
result = transform(<<-RUBY.strip_heredoc)
get :show, id: 10, xhr: true
RUBY

expect(result).to eq(<<-RUBY.strip_heredoc)
get :show, params: { id: 10 }, xhr: true
RUBY
end
end
end
end

Expand Down

0 comments on commit 0a27bdd

Please sign in to comment.