Class: Approvals::Namers::RSpecNamer
- Inherits:
-
Object
- Object
- Approvals::Namers::RSpecNamer
- Defined in:
- lib/approvals/namers/rspec_namer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(example) ⇒ RSpecNamer
constructor
A new instance of RSpecNamer.
- #normalize(string) ⇒ Object
- #output_dir ⇒ Object
Constructor Details
#initialize(example) ⇒ RSpecNamer
Returns a new instance of RSpecNamer.
6 7 8 |
# File 'lib/approvals/namers/rspec_namer.rb', line 6 def initialize(example) @name = normalize example.full_description end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/approvals/namers/rspec_namer.rb', line 5 def name @name end |
Instance Method Details
#normalize(string) ⇒ Object
10 11 12 |
# File 'lib/approvals/namers/rspec_namer.rb', line 10 def normalize(string) string.strip.squeeze(" ").gsub(/[\ :-]+/, '_').gsub(/[\W]/, '').downcase end |
#output_dir ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/approvals/namers/rspec_namer.rb', line 14 def output_dir unless @output_dir begin @output_dir = ::RSpec.configuration.approvals_path rescue NoMethodError => e end @output_dir ||= 'spec/fixtures/approvals/' end @output_dir end |