Skip to content

Commit

Permalink
Merge b89a064 into 941f594
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejsliwa committed Mar 5, 2018
2 parents 941f594 + b89a064 commit 68398e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions features/component_generator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ Feature: Component generator
import "components/awesome_button/awesome_button";
import "components/button/button";
"""

Scenario: `imports` in JavaScript files are sorted and without duplicates
When I cd to "frontend/components"
When I run `rails generate component some_example`
When I run `rails generate component some_example`
Then the file named "index.js" should contain:
"""
import "components/all/all";
import "components/some_example/some_example";
import "components/world/world";
"""

Scenario: Generate component with `erb` template engine
When I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/component/component_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def sort_lines_alphabetically!(path)

return if lines.empty?

lines = lines.sort
lines = lines.uniq.sort

File.open(path, "w") do |f|
lines.each do |line|
Expand Down

0 comments on commit 68398e9

Please sign in to comment.