To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!More about adding a collaborator
Rails 5 adds simple access to sample files called file fixtures.
File fixtures are normal files stored in spec/fixtures/files by default.
File fixtures are represented as +Pathname+ objects.
This makes it easy to extract specific information:
file_fixture("example.txt").read # get the file's content file_fixture("example.mp3").size # get the file size
You can customize files location by setting
RSpec.configure do |config| config.file_fixture_path = "spec/custom_directory" end
- Reading file content from fixtures directory
- file fixtures are available
a file named "spec/fixtures/files/sample.txt" with:
a file named "spec/lib/file_spec.rb" with:
require "rails_helper" RSpec.describe "file" do it "reads sample file" do expect(file_fixture("sample.txt").read).to eq("Hello") end end
- the examples should all pass
Last published 21 days ago by myronmarston.
RSpec Rails settings