rspec-temp_dir-1.1.2/0000755000004100000410000000000015114141562014460 5ustar www-datawww-datarspec-temp_dir-1.1.2/rspec-temp_dir.gemspec0000644000004100000410000000306315114141562020744 0ustar www-datawww-data# 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.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md" spec.metadata["documentation_uri"] = "https://sue445.github.io/rspec-temp_dir/" spec.metadata["rubygems_mfa_required"] = "true" 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 "coveralls_reborn" spec.add_development_dependency "rake" spec.add_development_dependency "simplecov" spec.add_development_dependency "term-ansicolor", "!= 1.11.1" # ref. https://github.com/flori/term-ansicolor/issues/41 spec.add_development_dependency "yard" end rspec-temp_dir-1.1.2/.gitignore0000644000004100000410000000027115114141562016450 0ustar www-datawww-data*.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.2/.github/0000755000004100000410000000000015114141562016020 5ustar www-datawww-datarspec-temp_dir-1.1.2/.github/dependabot.yml0000644000004100000410000000047315114141562020654 0ustar www-datawww-data# c.f. https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: weekly cooldown: default-days: 7 assignees: - sue445 rspec-temp_dir-1.1.2/.github/workflows/0000755000004100000410000000000015114141562020055 5ustar www-datawww-datarspec-temp_dir-1.1.2/.github/workflows/pages.yml0000644000004100000410000000331315114141562021677 0ustar www-datawww-data# Simple workflow for deploying static content to GitHub Pages name: Deploy static content to Pages on: # Runs on pushes targeting the default branch push: branches: - master # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write # Allow one concurrent deployment concurrency: group: "pages" cancel-in-progress: true jobs: # Single deploy job since we're just deploying deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0 with: ruby-version: ruby bundler-cache: true - run: bundle exec yard - name: Setup Pages uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - name: Upload artifact uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 with: # Upload entire repository path: './doc' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 - name: Slack Notification (not success) uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2 if: "! success()" continue-on-error: true with: status: ${{ job.status }} webhook-url: ${{ secrets.SLACK_WEBHOOK }} rspec-temp_dir-1.1.2/.github/workflows/release_gem.yml0000644000004100000410000000214115114141562023046 0ustar www-datawww-dataname: Publish gem to rubygems.org on: workflow_dispatch: jobs: release: if: github.repository == 'sue445/rspec-temp_dir' runs-on: ubuntu-latest environment: name: rubygems.org url: https://rubygems.org/gems/rspec-temp_dir permissions: contents: write id-token: write steps: - name: Harden Runner uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 with: egress-policy: audit - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up Ruby uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0 with: bundler-cache: true ruby-version: ruby - name: Publish to RubyGems uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1 - name: Create GitHub release run: | tag_name="$(git describe --tags --abbrev=0)" gh release create "${tag_name}" --verify-tag --generate-notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} rspec-temp_dir-1.1.2/.github/workflows/test.yml0000644000004100000410000000417115114141562021562 0ustar www-datawww-dataname: test on: push: branches: - master pull_request: types: - opened - synchronize - reopened schedule: - cron: "0 10 * * 5" # JST 19:00 (Fri) jobs: test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: ruby: - "2.0" - "2.1" - "2.2" - "2.3" - "2.4" - "2.5" - "2.6" - "2.7" - "3.0" - "3.1" - "3.2" - "3.3" - "3.4" steps: - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - run: bundle update --jobs $(nproc) --retry 3 - name: Setup Code Climate Test Reporter uses: aktions/codeclimate-test-reporter@7634aa9ac7883182f583f15ff7b6ff519939dd0a # v1.2.0 with: codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }} command: before-build continue-on-error: true - run: bundle exec rspec - name: Teardown Code Climate Test Reporter uses: aktions/codeclimate-test-reporter@7634aa9ac7883182f583f15ff7b6ff519939dd0a # v1.2.0 with: codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }} command: after-build if: always() continue-on-error: true - name: Slack Notification (not success) uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2 if: "! success()" continue-on-error: true with: status: ${{ job.status }} webhook-url: ${{ secrets.SLACK_WEBHOOK }} matrix: ${{ toJson(matrix) }} notify: needs: - test runs-on: ubuntu-latest steps: - name: Slack Notification (success) uses: act10ns/slack@cfcc30955fe9377f4f55e1079e5419ee1014269f # v2 if: always() continue-on-error: true with: status: ${{ job.status }} webhook-url: ${{ secrets.SLACK_WEBHOOK }} rspec-temp_dir-1.1.2/lib/0000755000004100000410000000000015114141562015226 5ustar www-datawww-datarspec-temp_dir-1.1.2/lib/rspec/0000755000004100000410000000000015114141562016342 5ustar www-datawww-datarspec-temp_dir-1.1.2/lib/rspec/temp_dir/0000755000004100000410000000000015114141562020145 5ustar www-datawww-datarspec-temp_dir-1.1.2/lib/rspec/temp_dir/within_temp_dir.rb0000644000004100000410000000026315114141562023660 0ustar www-datawww-datarequire "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.2/lib/rspec/temp_dir/uses_temp_dir.rb0000644000004100000410000000043415114141562023335 0ustar www-datawww-datarequire "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.2/lib/rspec/temp_dir/version.rb0000644000004100000410000000007615114141562022162 0ustar www-datawww-datamodule Rspec module TempDir VERSION = "1.1.2" end end rspec-temp_dir-1.1.2/lib/rspec/temp_dir.rb0000644000004100000410000000026715114141562020477 0ustar www-datawww-datarequire "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.2/LICENSE.txt0000644000004100000410000000204715114141562016306 0ustar www-datawww-dataCopyright (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.2/spec/0000755000004100000410000000000015114141562015412 5ustar www-datawww-datarspec-temp_dir-1.1.2/spec/spec_helper.rb0000644000004100000410000000725415114141562020240 0ustar www-datawww-data# 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["CI"] 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.2/spec/rspec/0000755000004100000410000000000015114141562016526 5ustar www-datawww-datarspec-temp_dir-1.1.2/spec/rspec/within_temp_dir_spec.rb0000644000004100000410000000065515114141562023260 0ustar www-datawww-datarequire "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.2/spec/rspec/uses_temp_dir_spec.rb0000644000004100000410000000074615114141562022736 0ustar www-datawww-datadescribe "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.2/.yardopts0000644000004100000410000000003715114141562016326 0ustar www-datawww-data--markup markdown --no-private rspec-temp_dir-1.1.2/.rspec0000644000004100000410000000006515114141562015576 0ustar www-datawww-data--format documentation --color --require spec_helper rspec-temp_dir-1.1.2/Rakefile0000644000004100000410000000016615114141562016130 0ustar www-datawww-datarequire "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec rspec-temp_dir-1.1.2/Gemfile0000644000004100000410000000163415114141562015757 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in rspec-temp_dir.gemspec gemspec if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.0") # NOTE: rake v13.0.0+ requires Ruby 2.2.0+ gem "rake", "< 13.0.0" end if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.3.0") # NOTE: json 2.6.0+ requires Ruby 2.3.0+ gem "json", "< 2.6.0" # NOTE: webrick 1.4.0+ requires Ruby 2.3.0+ gem "webrick", "< 1.4.0" end if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.4.0") # NOTE: simplecov-html v0.11.0+ requires Ruby ~> 2.4 gem "simplecov-html", "< 0.11.0" end if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.5.0") # NOTE: docile v1.4.0+ requires Ruby 2.5.0+ gem "docile", "< 1.4.0" end if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.7.0") # term-ansicolor 1.9.0+ doesn't work on Ruby < 2.7 gem "term-ansicolor", "< 1.9.0" end rspec-temp_dir-1.1.2/README.md0000644000004100000410000000376315114141562015750 0ustar www-datawww-data# 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) [![test](https://github.com/sue445/rspec-temp_dir/actions/workflows/test.yml/badge.svg)](https://github.com/sue445/rspec-temp_dir/actions/workflows/test.yml) [![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.2/CHANGELOG.md0000644000004100000410000000300715114141562016271 0ustar www-datawww-data# Changelog ## master [full changelog](http://github.com/sue445/rspec-temp_dir/compare/v1.1.2...master) ## [v1.1.2](https://github.com/sue445/rspec-temp_dir/releases/tag/v1.1.2) [full changelog](http://github.com/sue445/rspec-temp_dir/compare/v1.1.1...v1.1.2) * Release gem from GitHub Actions * https://github.com/sue445/rspec-temp_dir/pull/63 ## v1.1.1 [full changelog](http://github.com/sue445/rspec-temp_dir/compare/v1.1.0...v1.1.1) * Enable MFA requirement for gem releasing * https://github.com/sue445/rspec-temp_dir/pull/35 ## 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.2/.coveralls.yml0000644000004100000410000000005615114141562017254 0ustar www-datawww-datarepo_token: neej8FqJspOAXAEtwqYge65Dllr8Jn9R5