Class: SPV::Fixture
- Inherits:
-
Object
- Object
- SPV::Fixture
- Defined in:
- lib/site_prism_vcr/fixture.rb
Overview
Keeps a path to a fixture and options which should be passed to Vcr while inserting a cassette
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#clean_name ⇒ Object
Returns a name without a link to a home path.
-
#initialize(name, vcr_options = {}) ⇒ Fixture
constructor
A new instance of Fixture.
- #name ⇒ Object
- #prepend_path(val) ⇒ Object
- #set_home_path(path_to) ⇒ Object
- #shortcut_path ⇒ Object
Constructor Details
#initialize(name, vcr_options = {}) ⇒ Fixture
Returns a new instance of Fixture.
9 10 11 12 13 14 15 |
# File 'lib/site_prism_vcr/fixture.rb', line 9 def initialize(name, = {}) path = Pathname.new(name) @fixture_name = path.basename @path = path.dirname @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/site_prism_vcr/fixture.rb', line 7 def @options end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/site_prism_vcr/fixture.rb', line 7 def path @path end |
Instance Method Details
#clean_name ⇒ Object
Returns a name without a link to a home path
41 42 43 |
# File 'lib/site_prism_vcr/fixture.rb', line 41 def clean_name @fixture_name.to_path end |
#name ⇒ Object
17 18 19 |
# File 'lib/site_prism_vcr/fixture.rb', line 17 def name (self.path + @fixture_name).to_path end |
#prepend_path(val) ⇒ Object
25 26 27 |
# File 'lib/site_prism_vcr/fixture.rb', line 25 def prepend_path(val) self.path = Pathname.new(val) + self.path end |
#set_home_path(path_to) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/site_prism_vcr/fixture.rb', line 29 def set_home_path(path_to) self.path = self.path.to_path.gsub( /\A(\:#{self.shortcut_path}\/|:#{self.shortcut_path}|\~\/|\~)/, path_to ) end |
#shortcut_path ⇒ Object
36 37 38 |
# File 'lib/site_prism_vcr/fixture.rb', line 36 def shortcut_path res = (self.name.match(/:(\w+)\//) || self.name.match(/(~)\//)) and res[1] end |