Skip to content
Snippets Groups Projects
Commit dd63f066 authored by Anthony Fok's avatar Anthony Fok
Browse files

Import Upstream version 1.1.0

parents
No related branches found
No related tags found
No related merge requests found
repo_token: neej8FqJspOAXAEtwqYge65Dllr8Jn9R5
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
.rspec 0 → 100644
--format documentation
--color
--require spec_helper
language: ruby
rvm:
- 2.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- ruby-head
cache: bundler
bundler_args: "--jobs=2"
before_install:
- gem update --system --no-document
- gem install bundler --no-document
before_script:
- export CODECLIMATE_REPO_TOKEN=329887587f83c7ce5a1ab75f426c00830ba5ffac290c90bc486713c88baea900
- export COVERAGE=true
script:
- bundle exec rspec
- bundle exec codeclimate-test-reporter
branches:
only:
- master
notifications:
email: false
slack:
secure: FWlvqeogBihUPkAQh/2t9ajZXFEe6CXMxcHeH9uY/7GPPBX0e4gUf4RU0xt7Ep3eloa1dtYIGj4UCcE5wZGG6oDdXVTGCp+NDdfKcBCjHyncbynS475m8N4oGTyNJ7LiS7ksL1vjdixO+pJb+EZYHR+RI86M2aaaLRhQ8feOVCU=
matrix:
allow_failures:
- rvm: ruby-head
sudo: false
# Changelog
## master
[full changelog](http://github.com/sue445/rspec-temp_dir/compare/v1.1.0...master)
## v1.1.0
[full changelog](http://github.com/sue445/rspec-temp_dir/compare/v1.0.0...v1.1.0)
* Impl within temp dir
* https://github.com/sue445/rspec-temp_dir/pull/13
## v1.0.0
[full changelog](http://github.com/sue445/rspec-temp_dir/compare/v0.0.4...v1.0.0)
* Drop support ruby 1.9
* https://github.com/sue445/rspec-temp_dir/pull/10
* Drop support rspec 2.x
* https://github.com/sue445/rspec-temp_dir/pull/9
## v0.0.4
[full changelog](http://github.com/sue445/rspec-temp_dir/compare/v0.0.3...v0.0.4)
* Fixed no method error for Pathname ruby 2.2.2
* https://github.com/sue445/rspec-temp_dir/pull/5
## v0.0.3
[full changelog](http://github.com/sue445/rspec-temp_dir/compare/v0.0.2...v0.0.3)
* support `temp_dir_path`
* https://github.com/sue445/rspec-temp_dir/pull/2
## v0.0.2
[full changelog](http://github.com/sue445/rspec-temp_dir/compare/v0.0.1...v0.0.2)
* bugfix: raise error when padrino and rspec3+
* https://github.com/sue445/rspec-temp_dir/pull/1
## v0.0.1
* first release
source 'https://rubygems.org'
# Specify your gem's dependencies in rspec-temp_dir.gemspec
gemspec
Copyright (c) 2014 sue445
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# 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://travis-ci.org/sue445/rspec-temp_dir.svg)](https://travis-ci.org/sue445/rspec-temp_dir)
[![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
end
it "can create file in temp_dir" do
temp_file = "#{temp_dir}/temp.txt"
File.open(temp_file, "w") do |f|
f.write("foo")
end
expect(File.read(temp_file)).to eq "foo"
end
describe "#temp_dir_path" do
subject{ temp_dir_path }
it { should be_an_instance_of Pathname }
it { should be_exist }
end
end
describe "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
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
require "rspec/temp_dir/version"
require "rspec/temp_dir/uses_temp_dir"
require "rspec/temp_dir/within_temp_dir"
module Rspec
module TempDir
# Your code goes here...
end
end
require "tmpdir"
require "rspec"
require "pathname"
RSpec.shared_context "uses temp dir" do
around do |example|
Dir.mktmpdir("rspec-") do |dir|
@temp_dir = dir
example.run
end
end
attr_reader :temp_dir
def temp_dir_path
Pathname(temp_dir)
end
end
module Rspec
module TempDir
VERSION = "1.1.0"
end
end
require "rspec"
RSpec.shared_context "within temp dir" do
include_context "uses temp dir"
around do |example|
Dir.chdir(temp_dir) do
example.run
end
end
end
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rspec/temp_dir/version'
Gem::Specification.new do |spec|
spec.name = "rspec-temp_dir"
spec.version = Rspec::TempDir::VERSION
spec.authors = ["sue445"]
spec.email = ["sue445@sue445.net"]
spec.summary = %q{create automatically temporary directory at each examples}
spec.description = %q{create automatically temporary directory at each examples}
spec.homepage = "https://github.com/sue445/rspec-temp_dir"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.required_ruby_version = ">= 2.0.0"
spec.add_dependency "rspec", ">= 3.0"
spec.add_development_dependency "bundler"
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
spec.add_development_dependency "coveralls"
spec.add_development_dependency "rake"
spec.add_development_dependency "simplecov"
end
describe "uses temp dir" do
include_context "uses temp dir"
it "should create temp_dir" do
expect(Pathname(temp_dir)).to be_exist
end
it "can create file in temp_dir" do
temp_file = "#{temp_dir}/temp.txt"
File.open(temp_file, "w") do |f|
f.write("foo")
end
expect(File.read(temp_file)).to eq "foo"
end
describe "#temp_dir_path" do
subject{ temp_dir_path }
it { should be_an_instance_of Pathname }
it { should be_exist }
end
end
require "rbconfig"
describe "within temp dir" do
include_context "within temp dir"
it "within temp dir" do
expect(current_dir).to eq temp_dir
end
def current_dir
dir = Dir.pwd
case RbConfig::CONFIG["host_os"]
when /darwin|mac os/
# FIXME: `Dir.mktmpdir` returns "/var/folders/xxx", but `pwd` returns "/private/var/folders/xxx" ...
dir.gsub!(%r{^/private/}, "/")
end
dir
end
end
# 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.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
# that actually need it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
if ENV["COVERAGE"]
require "simplecov"
require "coveralls"
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start
end
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'rspec/temp_dir'
RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
expectations.syntax = :expect
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
mocks.syntax = :expect
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended.
mocks.verify_partial_doubles = true
end
=end
config.order = :random
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment