Giter VIP home page Giter VIP logo

Comments (2)

ufo2mstar avatar ufo2mstar commented on June 7, 2024 1

@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.

levinmr avatar levinmr commented on June 7, 2024

Documentation improved in version 2.0.0 release

from rspec-snapshot.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.