-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
430 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,59 @@ | ||
Feature: Builtins Cop Features | ||
Feature: Generic Builtins detection and replacement | ||
|
||
Scenario: Builtins.y2milestone() is reported | ||
Given the original code is "Builtins.y2milestone('foo')" | ||
Scenario: It reports y2milestone builtin as offense | ||
Given the original code is | ||
""" | ||
Builtins.y2milestone("foo") | ||
""" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then offense "Builtin call `y2milestone` is obsolete" is found | ||
|
||
Scenario: Allowed Builtins.lsort() call is accepted | ||
Given the original code is "Builtins.lsort([])" | ||
Scenario: It finds builtin in explicit Yast namespace | ||
Given the original code is | ||
""" | ||
Yast::Builtins.y2milestone("foo") | ||
""" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code is found correct | ||
Then offense "Builtin call `y2milestone` is obsolete" is found | ||
|
||
Scenario: It finds builtin in explicit ::Yast namespace | ||
Given the original code is | ||
""" | ||
::Yast::Builtins.y2milestone("foo") | ||
""" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then offense "Builtin call `y2milestone` is obsolete" is found | ||
|
||
Scenario: Builtins in the ::Builtins name space are ignored | ||
Given the original code is "::Builtins.lsort([])" | ||
Given the original code is | ||
""" | ||
::Builtins.y2milestone("foo") | ||
""" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code is found correct | ||
|
||
Scenario: Builtins in non Yast name space are ignored | ||
Given the original code is | ||
""" | ||
Foo::Builtins.y2milestone("foo") | ||
""" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code is found correct | ||
|
||
Scenario: lsort(), crypt and gettext builtins are allowed | ||
Given the original code is | ||
""" | ||
Builtins.lsort(["foo"]) | ||
Builtins.crypt("foo") | ||
Builtins.dgettext("domain", "foo") | ||
""" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code is found correct | ||
|
||
Scenario: Unknown Builtins call is not changed | ||
Given the original code is "Builtins.foo()" | ||
Scenario: It does not change unknown builtins | ||
Given the original code is | ||
""" | ||
Builtins.foo() | ||
""" | ||
When I correct it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code is unchanged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Builtins.getenv() | ||
Scenario: With string literal parameter is translated to ENV equivalent | ||
Given the original code is | ||
""" | ||
Builtins.getenv("foo") | ||
""" | ||
When I correct it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code should be converted to | ||
""" | ||
ENV["foo"] | ||
""" | ||
|
||
Scenario: Variable as parameter is preserved | ||
Given the original code is | ||
""" | ||
foo = bar | ||
Builtins.getenv(foo) | ||
""" | ||
When I correct it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code should be converted to | ||
""" | ||
foo = bar | ||
ENV[foo] | ||
""" | ||
|
||
Scenario: Any other statement is preserved | ||
Given the original code is | ||
""" | ||
Builtins.getenv(Ops.add(foo, bar)) | ||
""" | ||
When I correct it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code should be converted to | ||
""" | ||
ENV[Ops.add(foo, bar)] | ||
""" |
Oops, something went wrong.