Comments (2)
@mathieujobin Yes, documentation should definitely be improved, and so should the features, because snapshot testing is a powerful idea! but lacks support across languages other than JS.
What I found to work was adding this to the top of your ./spec/spec_helper.rb
or equivalent
require "rspec/snapshot"
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
and giving the filename of your snapshot in your expect
call
it 'should match shapshot' do
...
expect(result).to match_snapshot 'shapshot_file_name'
...
end
which should create a __snapshots__/shapshot_file_name.snap
file (or you can configure the output from a relative to your spec file path to a more fixed path, based on this config
RSpec.configure do |config|
# The default setting is `:relative`, which means snapshots will be generate to
# the relative path of the spec file.
config.snapshot_dir = "spec/fixtures/snapshots"
end
from rspec-snapshot.
Documentation improved in version 2.0.0 release
from rspec-snapshot.
Related Issues (18)
- Possible to cut a new release? HOT 1
- Showing line-by-line diff when snapshot is different HOT 3
- Command to Update Snapshot automatically. HOT 1
- please add license
- Try to stringify `@actual` during comparison HOT 6
- Updating snapshots HOT 17
- Break old test after add gem HOT 1
- Make failure message nicer when used as an argument matcher HOT 1
- Fix CI build intermittent failures HOT 2
- Tests pass in CI if no snapshot is found HOT 1
- don't write snapshot when negated
- Project status? HOT 4
- Provide configurable serialization HOT 3
- Fails if snapshot_name has forward slashes HOT 3
- How to deal with obsolete files? HOT 1
- Issues with Object Comparison HOT 2
- Making the snapshot name optional HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspec-snapshot.