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.
- #name_for_example(example) ⇒ Object
- #normalize(string) ⇒ Object
- #output_dir ⇒ Object
Constructor Details
#initialize(example) ⇒ RSpecNamer
Returns a new instance of RSpecNamer.
6 7 8 9 |
# File 'lib/approvals/namers/rspec_namer.rb', line 6 def initialize(example) @name = name_for_example(example) @output_dir = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/approvals/namers/rspec_namer.rb', line 4 def name @name end |
Instance Method Details
#name_for_example(example) ⇒ Object
11 12 13 |
# File 'lib/approvals/namers/rspec_namer.rb', line 11 def name_for_example(example) normalize example.full_description end |
#normalize(string) ⇒ Object
15 16 17 |
# File 'lib/approvals/namers/rspec_namer.rb', line 15 def normalize(string) string.strip.squeeze(" ").gsub(/[\ :-]+/, '_').gsub(/[\W]/, '').downcase end |
#output_dir ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/approvals/namers/rspec_namer.rb', line 19 def output_dir unless @output_dir begin @output_dir = ::RSpec.configuration.approvals_path rescue NoMethodError end @output_dir ||= 'spec/fixtures/approvals/' end @output_dir end |