Class: FakeWeb::Fixture
- Inherits:
-
Object
- Object
- FakeWeb::Fixture
- Defined in:
- lib/fake_web/fixture.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #file_name ⇒ Object
-
#initialize(path, method, uri, response) ⇒ Fixture
constructor
A new instance of Fixture.
- #register ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(path, method, uri, response) ⇒ Fixture
Returns a new instance of Fixture.
12 13 14 15 16 17 |
# File 'lib/fake_web/fixture.rb', line 12 def initialize(path, method, uri, response) @path = path @method = method @uri = uri @response = response end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/fake_web/fixture.rb', line 3 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/fake_web/fixture.rb', line 3 def path @path end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/fake_web/fixture.rb', line 3 def response @response end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
3 4 5 |
# File 'lib/fake_web/fixture.rb', line 3 def uri @uri end |
Class Method Details
.register(path) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/fake_web/fixture.rb', line 5 def self.register(path) Dir.glob("#{path}/*.fixture") do |name| fixture = YAML.load_file name fixture.register end end |
Instance Method Details
#file_name ⇒ Object
19 20 21 |
# File 'lib/fake_web/fixture.rb', line 19 def file_name @file_name ||= generate_file_name end |
#register ⇒ Object
23 24 25 |
# File 'lib/fake_web/fixture.rb', line 23 def register FakeWeb.register_uri(method, uri, :response => response) end |
#save ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/fake_web/fixture.rb', line 27 def save Dir.chdir path do File.open(file_name, 'w') do |f| f.write self.to_yaml end end end |