Skip to content

Commit

Permalink
convert Markdown tests to cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Dec 13, 2014
1 parent 9afbcf1 commit c323f9e
Show file tree
Hide file tree
Showing 3 changed files with 430 additions and 11 deletions.
56 changes: 47 additions & 9 deletions features/builtins_cop.feature
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
35 changes: 35 additions & 0 deletions features/builtins_env.feature
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)]
"""
Loading

0 comments on commit c323f9e

Please sign in to comment.