Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Created December 2, 2018 06:47
Show Gist options
  • Select an option

  • Save dpaluy/8dbc256ec69967f37722ee93dbe1484f to your computer and use it in GitHub Desktop.

Select an option

Save dpaluy/8dbc256ec69967f37722ee93dbe1484f to your computer and use it in GitHub Desktop.
RSpec Helpers
# spec/support/fixture_helpers.rb
def fixture_file_path(filename)
Rails.root.join("spec/fixtures/#{filename}").to_s
end
def read_fixture_file(filename)
File.read fixture_file_path(filename)
end
def yaml_fixture_file(filename)
YAML.load_file(fixture_file_path(filename))
end
__END__
# Usage
RSpec.describe LoadItems do
let(:source) { read_fixture_file('items.xml') }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment