Class: ApprovalTests::Namers::CucumberNamer
- Inherits:
-
Object
- Object
- ApprovalTests::Namers::CucumberNamer
- Defined in:
- lib/approval_tests/namers/cucumber_namer.rb
Instance Attribute Summary collapse
-
#approval_name ⇒ Object
readonly
Returns the value of attribute approval_name.
-
#source_file_path ⇒ Object
readonly
Returns the value of attribute source_file_path.
Class Method Summary collapse
Instance Method Summary collapse
- #format(string) ⇒ Object
-
#initialize(feature_file_and_path, scenario_name) ⇒ CucumberNamer
constructor
A new instance of CucumberNamer.
Constructor Details
#initialize(feature_file_and_path, scenario_name) ⇒ CucumberNamer
Returns a new instance of CucumberNamer.
14 15 16 17 18 19 20 21 |
# File 'lib/approval_tests/namers/cucumber_namer.rb', line 14 def initialize(feature_file_and_path, scenario_name) feature_file_and_path =~ /([^\/]*)\.feature$/ feature_name = $1 @source_file_path = File.dirname(File.(feature_file_and_path)) @approval_name = format("#{feature_name}_#{scenario_name}") end |
Instance Attribute Details
#approval_name ⇒ Object (readonly)
Returns the value of attribute approval_name.
4 5 6 |
# File 'lib/approval_tests/namers/cucumber_namer.rb', line 4 def approval_name @approval_name end |
#source_file_path ⇒ Object (readonly)
Returns the value of attribute source_file_path.
5 6 7 |
# File 'lib/approval_tests/namers/cucumber_namer.rb', line 5 def source_file_path @source_file_path end |
Class Method Details
.create_namer(scenario) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/approval_tests/namers/cucumber_namer.rb', line 7 def self.create_namer(scenario) feature_file_and_path = scenario.instance_variable_get(:@feature).file scenario_name = scenario.name Approvals.namer = CucumberNamer.new(feature_file_and_path, scenario_name) end |
Instance Method Details
#format(string) ⇒ Object
23 24 25 |
# File 'lib/approval_tests/namers/cucumber_namer.rb', line 23 def format(string) string.downcase.gsub(/ |\./, "_") end |