Class: RSpec::SpecificationCoverage::SpecFromFile
- Inherits:
-
Object
- Object
- RSpec::SpecificationCoverage::SpecFromFile
- Defined in:
- lib/rspec/specification_coverage/spec_from_file.rb
Overview
Allows getting getting spec name from file name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(actual, type) ⇒ SpecFromFile
constructor
A new instance of SpecFromFile.
-
#is ⇒ String
Like ‘spec/models/user_spec.rb`.
Constructor Details
#initialize(actual, type) ⇒ SpecFromFile
Returns a new instance of SpecFromFile.
20 21 22 23 24 25 |
# File 'lib/rspec/specification_coverage/spec_from_file.rb', line 20 def initialize(actual, type) @actual = actual @type = type raise(::ArgumentError) unless valid? end |
Class Method Details
.is(actual, type) ⇒ Object
14 15 16 |
# File 'lib/rspec/specification_coverage/spec_from_file.rb', line 14 def self.is(actual, type) new(actual, type).is end |
Instance Method Details
#is ⇒ String
Returns like ‘spec/models/user_spec.rb`.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rspec/specification_coverage/spec_from_file.rb', line 28 def is case @type when :routing controller_replaced.gsub(/\.rb$/, "_#{@type}_spec.rb") when :requests controller_replaced.gsub(/\.rb$/, '_spec.rb') when :lib suffix_replaced.gsub(/^lib/, 'spec/lib') else suffix_replaced.gsub(/^lib/, 'spec') end end |