Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions allure-cucumber/lib/allure_cucumber/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module AllureCucumber
# @return [String]
class CucumberConfig
include Singleton
extend Forwardable

# @return [String] default tms tag prefix
DEFAULT_TMS_PREFIX = "TMS:"
Expand All @@ -36,26 +35,6 @@ class CucumberConfig
# @return [String] default story tag prefix
DEFAULT_STORY_PREFIX = "STORY:"

def_delegators :@allure_config,
:clean_results_directory,
:clean_results_directory=,
:link_issue_pattern,
:link_issue_pattern=,
:link_tms_pattern,
:link_tms_pattern=,
:logging_level,
:logging_level=,
:logger,
:logger=,
:results_directory,
:results_directory=,
:environment,
:environment=,
:environment_properties,
:environment_properties=,
:categories,
:categories=

attr_writer :tms_prefix,
:issue_prefix,
:severity_prefix,
Expand Down Expand Up @@ -96,5 +75,13 @@ def feature_prefix
def story_prefix
@story_prefix || DEFAULT_STORY_PREFIX
end

def method_missing(method, ...)
@allure_config.respond_to?(method) ? @allure_config.send(method, ...) : super
end

def respond_to_missing?(method, include_private = false)
@allure_config.respond_to?(method, include_private) || super
end
end
end
21 changes: 20 additions & 1 deletion allure-cucumber/spec/unit/allure_cucumber_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# frozen_string_literal: true

describe AllureCucumber do
let(:cucumber_config) { AllureCucumber::CucumberConfig.send(:new) }

before do
allow(Allure::Config).to receive(:instance).and_return(Allure::Config.send(:new))
allow(AllureCucumber::CucumberConfig).to receive(:instance).and_return(cucumber_config)
end

it "returns cucumber configuration" do
expect(AllureCucumber.configuration).to be_a(AllureCucumber::CucumberConfig)
end

it "yields cucumber configuration" do
expect { |b| AllureCucumber.configure(&b) }.to yield_with_args(AllureCucumber::CucumberConfig.instance)
expect { |b| AllureCucumber.configure(&b) }.to yield_with_args(cucumber_config)
end

it "supports common configuration options" do
AllureCucumber.configure { |config| config.failure_exception = StandardError }

expect(AllureCucumber.configuration.failure_exception).to eq(StandardError)
end

it "supports cucumber specific configuration options" do
AllureCucumber.configure { |config| config.tms_prefix = "TMS" }

expect(AllureCucumber.configuration.tms_prefix).to eq("TMS")
end
end
29 changes: 8 additions & 21 deletions allure-rspec/lib/allure_rspec/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module AllureRspec
# @return [String]
class RspecConfig
include Singleton
extend Forwardable

# @return [Symbol] default tms tag
DEFAULT_TMS_TAG = :tms
Expand All @@ -36,26 +35,6 @@ class RspecConfig
# @return [Symbol] default story tag
DEFAULT_STORY_TAG = :story

def_delegators :@allure_config,
:clean_results_directory,
:clean_results_directory=,
:link_issue_pattern,
:link_issue_pattern=,
:link_tms_pattern,
:link_tms_pattern=,
:logging_level,
:logging_level=,
:logger,
:logger=,
:results_directory,
:results_directory=,
:environment,
:environment=,
:environment_properties,
:environment_properties=,
:categories,
:categories=

def initialize
@allure_config = Allure.configuration
end
Expand Down Expand Up @@ -102,5 +81,13 @@ def story_tag
def ignored_tags
@ignored_tags || []
end

def method_missing(method, ...)
@allure_config.respond_to?(method) ? @allure_config.send(method, ...) : super
end

def respond_to_missing?(method, include_private = false)
@allure_config.respond_to?(method, include_private) || super
end
end
end
21 changes: 20 additions & 1 deletion allure-rspec/spec/unit/allure_rspec_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# frozen_string_literal: true

describe AllureRspec do
let(:rspec_config) { AllureRspec::RspecConfig.send(:new) }

before do
allow(Allure::Config).to receive(:instance).and_return(Allure::Config.send(:new))
allow(AllureRspec::RspecConfig).to receive(:instance).and_return(rspec_config)
end

it "returns rspec configuration" do
expect(AllureRspec.configuration).to be_a(AllureRspec::RspecConfig)
end

it "yields rspec configuration" do
expect { |b| AllureRspec.configure(&b) }.to yield_with_args(AllureRspec::RspecConfig.instance)
expect { |b| AllureRspec.configure(&b) }.to yield_with_args(rspec_config)
end

it "supports common configuration options" do
AllureRspec.configure { |config| config.failure_exception = StandardError }

expect(AllureRspec.configuration.failure_exception).to eq(StandardError)
end

it "supports rspec specific configuration options" do
AllureRspec.configure { |config| config.tms_tag = "TMS" }

expect(AllureRspec.configuration.tms_tag).to eq("TMS")
end
end