Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sue445/rspec-temp_dir
create automatically temporary directory at each examples
https://github.com/sue445/rspec-temp_dir
gem rspec
Last synced: about 1 month ago
JSON representation
create automatically temporary directory at each examples
- Host: GitHub
- URL: https://github.com/sue445/rspec-temp_dir
- Owner: sue445
- License: mit
- Created: 2014-06-14T15:11:41.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-02T13:59:08.000Z (4 months ago)
- Last Synced: 2024-09-30T11:05:02.865Z (about 2 months ago)
- Topics: gem, rspec
- Language: Ruby
- Homepage: https://sue445.github.io/rspec-temp_dir/
- Size: 93.8 KB
- Stars: 12
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Rspec::TempDir
create automatically temporary directory at each examples
This is inspired by Junit [TemporaryFolder](http://junit.org/junit4/javadoc/4.12/org/junit/rules/TemporaryFolder.html)
[![Gem Version](https://badge.fury.io/rb/rspec-temp_dir.svg)](http://badge.fury.io/rb/rspec-temp_dir)
[![Build Status](https://github.com/sue445/rspec-temp_dir/workflows/test/badge.svg?branch=master)](https://github.com/sue445/rspec-temp_dir/actions?query=workflow%3Atest)
[![Code Climate](https://codeclimate.com/github/sue445/rspec-temp_dir.png)](https://codeclimate.com/github/sue445/rspec-temp_dir)
[![Coverage Status](https://img.shields.io/coveralls/sue445/rspec-temp_dir.svg)](https://coveralls.io/r/sue445/rspec-temp_dir)## Requirements
* ruby 2.0+
* rspec 3.0.0+## Installation
Add this line to your application's Gemfile:
gem 'rspec-temp_dir'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-temp_dir
## Usage
When use `include_context "uses temp dir"` , create automatically and can use `temp_dir````ruby
require 'rspec/temp_dir'describe "uses temp dir" do
include_context "uses temp dir"it "should create temp_dir" do
expect(Pathname(temp_dir)).to be_exist
endit "can create file in temp_dir" do
temp_file = "#{temp_dir}/temp.txt"File.open(temp_file, "w") do |f|
f.write("foo")
endexpect(File.read(temp_file)).to eq "foo"
enddescribe "#temp_dir_path" do
subject{ temp_dir_path }it { should be_an_instance_of Pathname }
it { should be_exist }
end
enddescribe "within temp dir" do
# create temp dir and cd to temp dir
include_context "within temp dir"it "within temp dir" do
expect(Dir.pwd).to eq temp_dir
end
end
```## Contributing
1. Fork it ( https://github.com/sue445/rspec-temp_dir/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request