-
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.
initial support for writing tests in cucumber
- Loading branch information
Showing
9 changed files
with
124 additions
and
32 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
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,21 @@ | ||
Feature: Builtins Cop Features | ||
|
||
Scenario: Builtins.y2milestone() is reported | ||
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([])" | ||
When I check it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code is found correct | ||
|
||
Scenario: Builtins in the ::Builtins name space are ignored | ||
Given the original code is "::Builtins.lsort([])" | ||
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()" | ||
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,5 @@ | ||
Feature: Builtins.time() | ||
Scenario: Replace Builtins.time() with ::Time.now.to_i | ||
Given the original code is "Builtins.time()" | ||
When I correct it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code should be converted to "::Time.now.to_i" |
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,15 @@ | ||
Feature: Logging Builtins | ||
|
||
Scenario: The include statement is added only once | ||
Given the original code is | ||
""" | ||
Builtins.y2milestone("foo") | ||
Builtins.y2milestone("foo") | ||
""" | ||
When I correct it using RuboCop::Cop::Yast::Builtins cop | ||
Then the code should be converted to | ||
""" | ||
include Yast::Logger | ||
log.info "foo" | ||
log.info "foo" | ||
""" |
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,42 @@ | ||
|
||
# inline code | ||
Given(/^the original code is "(.*)"$/) do |original_code| | ||
@original_code = original_code | ||
end | ||
|
||
# multiline code passed via docstring | ||
Given(/^the original code is$/) do |original_code| | ||
@original_code = original_code | ||
end | ||
|
||
When(/^I correct it using (.*) cop$/) do |cop| | ||
@cop = Object.const_get(cop).new | ||
@corrected = autocorrect_source(@cop, @original_code.split("\n")) | ||
end | ||
|
||
# inline code | ||
Then(/^the code should be converted to "(.*)"$/) do |expected_code| | ||
expect(@corrected).to eq(expected_code) | ||
end | ||
|
||
# multiline code passed via docstring | ||
Then(/^the code should be converted to$/) do |expected_code| | ||
expect(@corrected).to eq(expected_code) | ||
end | ||
|
||
Then(/^the code is unchanged$/) do | ||
expect(@corrected).to eq(@original_code) | ||
end | ||
|
||
When(/^I check it using (.*) cop$/) do |cop| | ||
@cop = Object.const_get(cop).new | ||
inspect_source(@cop, @original_code.split("\n")) | ||
end | ||
|
||
Then(/^the code is found correct$/) do | ||
expect(@cop.offenses).to be_empty | ||
end | ||
|
||
Then(/^offense "(.*)" is found$/) do |offense| | ||
expect(@cop.offenses.first.message).to include(offense) | ||
end |
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,36 @@ | ||
# encoding: utf-8 | ||
|
||
require "simplecov" | ||
require "rspec" | ||
|
||
# use coveralls for on-line code coverage reporting at Travis CI | ||
if ENV["TRAVIS"] | ||
require "coveralls" | ||
|
||
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ | ||
SimpleCov::Formatter::HTMLFormatter, | ||
Coveralls::SimpleCov::Formatter | ||
] | ||
end | ||
|
||
SimpleCov.start do | ||
# don't check code coverage in these subdirectories | ||
add_filter "/vendor/" | ||
add_filter "/features/" | ||
end | ||
|
||
# allow only the new "expect" RSpec syntax | ||
RSpec.configure do |config| | ||
config.expect_with :rspec do |c| | ||
c.syntax = :expect | ||
end | ||
end | ||
|
||
# reuse the Rubocop helper, provides some nice methods used in tests | ||
require File.join(Gem::Specification.find_by_name("rubocop").gem_dir, "spec", | ||
"support", "cop_helper.rb") | ||
include CopHelper | ||
|
||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) | ||
|
||
require "rubocop-yast" |
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
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
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