rspec-temp-dir-1.1.0/0000755000175000017500000000000013641034301012761 5ustar fokafokarspec-temp-dir-1.1.0/LICENSE.txt0000644000175000017500000000204713641034301014607 0ustar fokafokaCopyright (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-temp-dir-1.1.0/.travis.yml0000644000175000017500000000130513641034301015071 0ustar fokafokalanguage: 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 rspec-temp-dir-1.1.0/lib/0000755000175000017500000000000013641034301013527 5ustar fokafokarspec-temp-dir-1.1.0/lib/rspec/0000755000175000017500000000000013641034301014643 5ustar fokafokarspec-temp-dir-1.1.0/lib/rspec/temp_dir/0000755000175000017500000000000013641034301016446 5ustar fokafokarspec-temp-dir-1.1.0/lib/rspec/temp_dir/version.rb0000644000175000017500000000007613641034301020463 0ustar fokafokamodule Rspec module TempDir VERSION = "1.1.0" end end rspec-temp-dir-1.1.0/lib/rspec/temp_dir/uses_temp_dir.rb0000644000175000017500000000043413641034301021636 0ustar fokafokarequire "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 rspec-temp-dir-1.1.0/lib/rspec/temp_dir/within_temp_dir.rb0000644000175000017500000000026313641034301022161 0ustar fokafokarequire "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 rspec-temp-dir-1.1.0/lib/rspec/temp_dir.rb0000644000175000017500000000026713641034301017000 0ustar fokafokarequire "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 rspec-temp-dir-1.1.0/rspec-temp_dir.gemspec0000644000175000017500000000223513641034301017245 0ustar fokafoka# 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 rspec-temp-dir-1.1.0/CHANGELOG.md0000644000175000017500000000212413641034301014571 0ustar fokafoka# 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 rspec-temp-dir-1.1.0/.gitignore0000644000175000017500000000027113641034301014751 0ustar fokafoka*.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-temp-dir-1.1.0/.coveralls.yml0000644000175000017500000000005613641034301015555 0ustar fokafokarepo_token: neej8FqJspOAXAEtwqYge65Dllr8Jn9R5 rspec-temp-dir-1.1.0/Rakefile0000644000175000017500000000016613641034301014431 0ustar fokafokarequire "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec rspec-temp-dir-1.1.0/spec/0000755000175000017500000000000013641034301013713 5ustar fokafokarspec-temp-dir-1.1.0/spec/rspec/0000755000175000017500000000000013641034301015027 5ustar fokafokarspec-temp-dir-1.1.0/spec/rspec/uses_temp_dir_spec.rb0000644000175000017500000000074613641034301021237 0ustar fokafokadescribe "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 rspec-temp-dir-1.1.0/spec/rspec/within_temp_dir_spec.rb0000644000175000017500000000065513641034301021561 0ustar fokafokarequire "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 rspec-temp-dir-1.1.0/spec/spec_helper.rb0000644000175000017500000000726213641034301016540 0ustar fokafoka# 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 rspec-temp-dir-1.1.0/README.md0000644000175000017500000000370513641034301014245 0ustar fokafoka# 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 rspec-temp-dir-1.1.0/.rspec0000644000175000017500000000006513641034301014077 0ustar fokafoka--format documentation --color --require spec_helper rspec-temp-dir-1.1.0/Gemfile0000644000175000017500000000014313641034301014252 0ustar fokafokasource 'https://rubygems.org' # Specify your gem's dependencies in rspec-temp_dir.gemspec gemspec