Skip to content

Commit

Permalink
Always add comma between params hash and format key (#1)
Browse files Browse the repository at this point in the history
* Always add comma between params hash and format key

tjgrathwell#8
https://github.com/eugeneius
@intercom

* Add Gemfile.lock
  • Loading branch information
joel authored Sep 30, 2021
1 parent cc174b5 commit 2eaddba
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2

updates:
# Check for updates to Rubygems
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
versioning-strategy: increase
commit-message:
prefix: "gems"
include: "scope"
labels:
- "gems"
- "dependencies"

# Check for updates to GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "github-actions"
include: "scope"
labels:
- "github-actions"
- "dependencies"
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Tests

on: [ push ]

jobs:
ci:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
-
name: "Default"
ruby: 2.7.4
gemfile: Gemfile

env:
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
BUNDLE_WITHOUT: production
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3

steps:
-
name: Checkout Source Code
uses: actions/checkout@v2
with:
fetch-depth: '1'
-
name: Install ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
-
name: Set Env 1.17.3 (Default)
if: ${{ matrix.gemfile == 'Gemfile' }}
run: gem install bundler:1.17.3
-
name: Bundle Install ${{ matrix.gemfile }}
run: |
bundle config set --local deployment 'true'
bundle install
-
name: Run test suite
run: |
bundle exec rake
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
Expand Down
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

44 changes: 44 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PATH
remote: .
specs:
rails5-spec-converter (2.0.0)
astrolabe (~> 1.2)
parser (>= 2.3.0.7)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
astrolabe (1.3.1)
parser (~> 2.2)
byebug (11.1.3)
diff-lcs (1.4.4)
parser (2.7.2.0)
ast (~> 2.4.1)
rake (10.5.0)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.10)
byebug
rails5-spec-converter!
rake (~> 10.0)
rspec

BUNDLED WITH
1.17.3
3 changes: 1 addition & 2 deletions lib/rails5/spec_converter/hash_rewriter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ def rewritten_params_hash
joiner: ",\n"
)

optional_comma = has_trailing_comma?(hash_node) ? ',' : ''
new_wrapped_hash_content = wrap_and_indent(
"{",
"}",
[
wrap_and_indent(
"params: {",
"}#{optional_comma}",
"},",
params_hash,
@options.indent
),
Expand Down
24 changes: 24 additions & 0 deletions spec/rails5/text_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,30 @@ def quiet_transform(text)
end
RUBY
end

it 'adds a comma between the params hash and the format key' do
result = transform(<<-RUBY.strip_heredoc)
let(:perform_request) do
post :show, {
branch_name: 'new_design3',
ref: 'foo',
format: :json
}
end
RUBY

expect(result).to eq(<<-RUBY.strip_heredoc)
let(:perform_request) do
post :show, {
params: {
branch_name: 'new_design3',
ref: 'foo'
},
format: :json
}
end
RUBY
end
end

describe 'things that look like route definitions' do
Expand Down

0 comments on commit 2eaddba

Please sign in to comment.