Class: Museo::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/museo/snapshot.rb,
lib/museo/snapshot/rspec.rb,
lib/museo/snapshot/minitest.rb

Direct Known Subclasses

Minitest, Rspec

Defined Under Namespace

Classes: GenerationDisabledError, Minitest, Rspec

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass:, test_name:, response:) ⇒ Snapshot

Returns a new instance of Snapshot.



15
16
17
18
19
20
21
# File 'lib/museo/snapshot.rb', line 15

def initialize(klass:, test_name:, response:)
  @class_name = klass.to_s
  @test_name = test_name
  @response = response

  generate unless exists?
end

Class Method Details

.sanitize_response(body) ⇒ Object



10
11
12
# File 'lib/museo/snapshot.rb', line 10

def sanitize_response(body)
  body.gsub(/:0x[a-fA-F0-9]{4,}/, ":0xXXXXXX")
end

Instance Method Details

#bodyObject



23
24
25
# File 'lib/museo/snapshot.rb', line 23

def body
  exists? ? File.read(path) : nil
end