Class: SnapshotTesting::RSpec::MatchSnapshot
- Inherits:
-
Object
- Object
- SnapshotTesting::RSpec::MatchSnapshot
- Defined in:
- lib/snapshot_testing/rspec.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
Instance Method Summary collapse
- #diffable? ⇒ Boolean
- #failure_message ⇒ Object
-
#initialize(recorder:) ⇒ MatchSnapshot
constructor
A new instance of MatchSnapshot.
- #matches?(actual) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(recorder:) ⇒ MatchSnapshot
Returns a new instance of MatchSnapshot.
26 27 28 |
# File 'lib/snapshot_testing/rspec.rb', line 26 def initialize(recorder:) @recorder = recorder end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
24 25 26 |
# File 'lib/snapshot_testing/rspec.rb', line 24 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
24 25 26 |
# File 'lib/snapshot_testing/rspec.rb', line 24 def expected @expected end |
Instance Method Details
#diffable? ⇒ Boolean
42 43 44 |
# File 'lib/snapshot_testing/rspec.rb', line 42 def diffable? true end |
#failure_message ⇒ Object
36 37 38 39 40 |
# File 'lib/snapshot_testing/rspec.rb', line 36 def expected = ::RSpec::Support::ObjectFormatter.format(@expected) actual = ::RSpec::Support::ObjectFormatter.format(@actual) "\nexpected: #{expected}\n got: #{actual}\n\n(compared using ==)\n" end |
#matches?(actual) ⇒ Boolean
30 31 32 33 34 |
# File 'lib/snapshot_testing/rspec.rb', line 30 def matches?(actual) @actual = actual @expected = @recorder.record(@actual) @actual == @expected end |
#supports_block_expectations? ⇒ Boolean
46 47 48 |
# File 'lib/snapshot_testing/rspec.rb', line 46 def supports_block_expectations? false end |