Skip to content

Commit f68d659

Browse files
committed
Update RSpec setup and gitignores
1 parent 3dcc9e3 commit f68d659

13 files changed

+125
-35
lines changed

.gitignore

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
*.gem
2-
.bundle
3-
.ruby-version
4-
Gemfile.lock
5-
coverage
6-
bin/rspec
7-
bin/rake
8-
doc/
9-
lib/bundler/man
10-
/git-tracker
11-
pkg
12-
rdoc
13-
tmp
14-
tags
1+
# Ignore all log/temp/etc... files
2+
/log/
3+
/tmp/
4+
/tags
5+
6+
# Package and dependency caches
7+
/.ruby-version
8+
/.bundle
9+
/Gemfile.lock
10+
/pkg/
11+
12+
# Generated documentation
13+
/.yardoc
14+
/_yardoc/
15+
16+
# Spec reports and failure tracking
17+
/coverage/
18+
/spec/rspec-status.txt
19+
/spec/reports/

.rspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
--colour
2-
-I spec/support
3-
-r pry
2+
--require spec_helper

bin/rake

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rake' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "pathname"
12+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13+
Pathname.new(__FILE__).realpath)
14+
15+
bundle_binstub = File.expand_path("../bundle", __FILE__)
16+
17+
if File.file?(bundle_binstub)
18+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19+
load(bundle_binstub)
20+
else
21+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23+
end
24+
end
25+
26+
require "rubygems"
27+
require "bundler/setup"
28+
29+
load Gem.bin_path("rake", "rake")

bin/rspec

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rspec' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "pathname"
12+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13+
Pathname.new(__FILE__).realpath)
14+
15+
bundle_binstub = File.expand_path("../bundle", __FILE__)
16+
17+
if File.file?(bundle_binstub)
18+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19+
load(bundle_binstub)
20+
else
21+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23+
end
24+
end
25+
26+
require "rubygems"
27+
require "bundler/setup"
28+
29+
load Gem.bin_path("rspec-core", "rspec")

git_tracker.gemspec

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ Gem::Specification.new do |spec|
2525
# Specify which files should be added to the gem when it is released.
2626
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
2727
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
28-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.gitignore|\.rspec|\.travis\.yml|bin/|spec/|features/)}) }
2929
end
3030
spec.bindir = "exe"
3131
spec.executables = %w[git-tracker]
3232
spec.require_paths = ["lib"]
3333
spec.platform = Gem::Platform::RUBY
3434

3535
spec.add_development_dependency "activesupport", "~> 6.0"
36-
spec.add_development_dependency "pry", "~> 0.12"
37-
spec.add_development_dependency "rake", "~> 12.0"
38-
spec.add_development_dependency "rspec", "~> 3.8"
36+
spec.add_development_dependency "pry-byebug", "~> 3.9"
37+
spec.add_development_dependency "rake", "~> 13.0"
38+
spec.add_development_dependency "rspec", "~> 3.9"
3939
# Simplecov 0.18+ is currently broken for the cc-test-reporter.
4040
# Until it's fixed, we need to stick to something pre-0.18
4141
# see: https://github.com/codeclimate/test-reporter/issues/413

spec/git_tracker/branch_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
require "spec_helper"
21
require "git_tracker/branch"
32

4-
describe GitTracker::Branch do
3+
RSpec.describe GitTracker::Branch do
54
subject(:branch) { described_class }
65

76
def stub_branch(ref, exit_status = 0)

spec/git_tracker/commit_message_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
require "spec_helper"
21
require "git_tracker/commit_message"
32
require "active_support/core_ext/string/strip"
43

5-
describe GitTracker::CommitMessage do
4+
RSpec.describe GitTracker::CommitMessage do
65
include CommitMessageHelper
76

87
subject(:commit_message) { described_class.new(file) }

spec/git_tracker/hook_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
require "spec_helper"
21
require "git_tracker/hook"
32
require "active_support/core_ext/string/strip"
43

5-
describe GitTracker::Hook do
4+
RSpec.describe GitTracker::Hook do
65
subject(:hook) { described_class }
76
let(:root) { "/path/to/git/repo/toplevel" }
87
let(:hook_path) { File.join(root, ".git", "hooks", "prepare-commit-msg") }

spec/git_tracker/prepare_commit_message_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
require "spec_helper"
21
require "git_tracker/prepare_commit_message"
32

4-
describe GitTracker::PrepareCommitMessage do
3+
RSpec.describe GitTracker::PrepareCommitMessage do
54
subject(:prepare_commit_message) { GitTracker::PrepareCommitMessage }
65

76
describe ".run" do

spec/git_tracker/repository_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
require "spec_helper"
21
require "git_tracker/repository"
32

4-
describe GitTracker::Repository do
3+
RSpec.describe GitTracker::Repository do
54
subject(:repository) { described_class }
65
let(:git_command) { "git rev-parse --show-toplevel" }
76
before do

spec/git_tracker/runner_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
require "spec_helper"
21
require "git_tracker/runner"
32

4-
describe GitTracker::Runner do
3+
RSpec.describe GitTracker::Runner do
54
subject(:runner) { described_class }
65
let(:args) { ["a_file", "the_source", "sha1234"] }
76

spec/git_tracker/standalone_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "git_tracker/standalone"
22

3-
describe GitTracker::Standalone do
3+
RSpec.describe GitTracker::Standalone do
44
describe "#save" do
55
before do
66
File.delete "git-tracker" if File.exist? "git-tracker"

spec/spec_helper.rb

+36-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,46 @@
33
SimpleCov.start
44
end
55

6+
require "pry-byebug"
67
require_relative "support/commit_message_helper"
78
require_relative "support/fake_file"
89
require_relative "support/output_helper"
910
require_relative "support/matchers/exit_code_matchers"
1011

1112
RSpec.configure do |config|
12-
config.run_all_when_everything_filtered = true
13-
config.filter_run :focus
13+
config.expect_with :rspec do |expectations|
14+
# This option will default to `true` in RSpec 4. It makes the `description`
15+
# and `failure_message` of custom matchers include text for helper methods
16+
# defined using `chain`, e.g.:
17+
# be_bigger_than(2).and_smaller_than(4).description
18+
# # => "be bigger than 2 and smaller than 4"
19+
# ...rather than:
20+
# # => "be bigger than 2"
21+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
22+
end
23+
24+
config.mock_with :rspec do |mocks|
25+
# Prevents you from mocking or stubbing a method that does not exist on
26+
# a real object. This is generally recommended, and will default to
27+
# `true` in RSpec 4.
28+
mocks.verify_partial_doubles = true
29+
end
30+
31+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
32+
# have no way to turn it off -- the option exists only for backwards
33+
# compatibility in RSpec 3). It causes shared context metadata to be
34+
# inherited by the metadata hash of host groups and examples, rather than
35+
# triggering implicit auto-inclusion in groups with matching metadata.
36+
config.shared_context_metadata_behavior = :apply_to_host_groups
37+
config.filter_run_when_matching :focus
38+
config.example_status_persistence_file_path = "spec/rspec-status.txt"
39+
config.disable_monkey_patching!
40+
config.warnings = true
41+
42+
if config.files_to_run.one?
43+
config.default_formatter = "doc"
44+
end
45+
# config.profile_examples = 10
46+
config.order = :random
47+
Kernel.srand(config.seed)
1448
end

0 commit comments

Comments
 (0)