rspec_starter 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -5
- data/lib/rspec_starter.rb +10 -0
- data/lib/rspec_starter/runner.rb +12 -2
- data/lib/rspec_starter/steps/invoke_rspec_step.rb +4 -0
- data/lib/rspec_starter/steps/prepare_database_step.rb +6 -2
- data/lib/rspec_starter/version.rb +1 -1
- data/rspec_starter.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb6c3b840f892e7eb22465923f63708c2dd3942a21fb86754caf1ed9a25984f3
|
4
|
+
data.tar.gz: a37965d96323b5bf2f40611000e8c74c7f9b269c36dd461a0b3317fcccbdda3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b83cc5cd091593252a806854b35913e420ea38a90bdee5bfd26a2af270e13820ef40d3c7f2364e07d8e8e3e31d6b5b4fdbe45d55c0f44690300b3018b920136
|
7
|
+
data.tar.gz: e342445d01317ca1f239abca6dd566285863fb0d1411ef46df87b7cff91a8f1eb8b31528931a98262bb281a94fad205bd2d33e6141131bfa9c08fd1603656c81
|
data/.travis.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.3.
|
5
|
-
- 2.4.
|
6
|
-
- 2.5.
|
7
|
-
|
4
|
+
- 2.3.7
|
5
|
+
- 2.4.5
|
6
|
+
- 2.5.3
|
7
|
+
- 2.6.1
|
8
|
+
before_install: gem install bundler -v 2.0.1
|
8
9
|
notifications:
|
9
10
|
email:
|
10
11
|
on_success: never # default: change
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -17,9 +17,9 @@ rspec_starter can currently perform the following steps (these steps can be togg
|
|
17
17
|
- Verify XVFB is installed when running on a Linux box
|
18
18
|
- Start RSpec with `bundle exec rspec` or `xvfb-run bundle exec rspec` (depending on the needs of the OS)
|
19
19
|
|
20
|
-
##
|
20
|
+
## Version Policy
|
21
21
|
|
22
|
-
|
22
|
+
Releases are versioned using [semver 2.0.0](https://semver.org/spec/v2.0.0.html).
|
23
23
|
|
24
24
|
## Supported Ruby Versions
|
25
25
|
|
@@ -63,12 +63,12 @@ which tells start_rspec, to tell rspec, to only run the feature tests. Run the
|
|
63
63
|
|
64
64
|
## Custom Steps
|
65
65
|
|
66
|
-
rspec_starter does not currently have support for creating custom steps. However, there are some techniques that can achieve the same results. rspec_starter currently implements 4 "steps" which can be turned on or off. The steps are implemented by classes and are evaluated in this order:
|
66
|
+
rspec_starter does not currently have support for creating custom steps. However, there are some techniques that can achieve the same results. rspec_starter currently implements 4 "steps" which can be turned on or off. The steps are implemented by classes and are evaluated in this order:
|
67
67
|
|
68
68
|
1. `VerifyXvfbStep` - Ensures xvfb is installed on systems where it should be used (.i.e. Linux).
|
69
69
|
1. `PrepareDatabaseStep` - Runs `rake db:drop db:create db:migrate RAILS_ENV=test`.
|
70
70
|
1. `RemoveTmpFolderStep` - Deletes the `tmp` folder.
|
71
|
-
1. `InvokeRspecStep` - Runs `bundle exec rspec`.
|
71
|
+
1. `InvokeRspecStep` - Runs `bundle exec rspec`.
|
72
72
|
|
73
73
|
All steps implement an `execute` method that actually runs the step. You can inject custom code before or after any one of those steps.
|
74
74
|
|
@@ -92,7 +92,7 @@ module CustomStep
|
|
92
92
|
end
|
93
93
|
|
94
94
|
RspecStarter::PrepareDatabaseStep.prepend CustomStep
|
95
|
-
|
95
|
+
|
96
96
|
Dir.chdir APP_ROOT do
|
97
97
|
RspecStarter.start(prepare_db: true, remove_tmp: true, allow_xvfb: true)
|
98
98
|
end
|
data/lib/rspec_starter.rb
CHANGED
@@ -3,6 +3,16 @@ require 'colorize'
|
|
3
3
|
require "rspec_starter/version"
|
4
4
|
require_relative 'rspec_starter/runner'
|
5
5
|
|
6
|
+
# Setup pry for development when running "rake console". Guard against load
|
7
|
+
# errors in production (since pry is only loaded as a DEVELOPMENT dependency
|
8
|
+
# in the .gemspec)
|
9
|
+
# rubocop:disable Lint/HandleExceptions
|
10
|
+
begin
|
11
|
+
require "pry"
|
12
|
+
rescue LoadError
|
13
|
+
end
|
14
|
+
# rubocop:enable Lint/HandleExceptions
|
15
|
+
|
6
16
|
# Entry point for the RspecStarter gem.
|
7
17
|
module RspecStarter
|
8
18
|
# The 'start' method takes arguments that can be used to control the steps that are executed when running Rspec. These
|
data/lib/rspec_starter/runner.rb
CHANGED
@@ -23,10 +23,12 @@ module RspecStarter
|
|
23
23
|
@steps = []
|
24
24
|
@step_num = 1
|
25
25
|
@xvfb_installed = RspecStarter.which("xvfb-run")
|
26
|
+
@prep_db_step = PrepareDatabaseStep.new(defaults, self)
|
27
|
+
@run_rspec_step = InvokeRspecStep.new(defaults, self)
|
26
28
|
@steps << VerifyXvfbStep.new(defaults, self)
|
27
|
-
@steps <<
|
29
|
+
@steps << @prep_db_step
|
28
30
|
@steps << RemoveTmpFolderStep.new(defaults, self)
|
29
|
-
@steps <<
|
31
|
+
@steps << @run_rspec_step
|
30
32
|
end
|
31
33
|
|
32
34
|
def run
|
@@ -38,6 +40,8 @@ module RspecStarter
|
|
38
40
|
@step_num += 1
|
39
41
|
break if step.failed?
|
40
42
|
end
|
43
|
+
|
44
|
+
finalize_exit
|
41
45
|
end
|
42
46
|
|
43
47
|
def project_is_rails_app?
|
@@ -74,5 +78,11 @@ module RspecStarter
|
|
74
78
|
def xvfb_installed?
|
75
79
|
@xvfb_installed
|
76
80
|
end
|
81
|
+
|
82
|
+
def finalize_exit
|
83
|
+
exit(1) if @run_rspec_step.rspec_exit_status.nonzero?
|
84
|
+
exit(1) if @prep_db_step.exit_status.nonzero?
|
85
|
+
exit(0)
|
86
|
+
end
|
77
87
|
end
|
78
88
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module RspecStarter
|
2
2
|
# The step that actually starts the RSpec.
|
3
3
|
class InvokeRspecStep < RspecStarter::Step
|
4
|
+
attr_reader :rspec_exit_status
|
5
|
+
|
4
6
|
def initialize(defaults, runner)
|
5
7
|
super(runner)
|
6
8
|
@allow_xvfb = defaults.fetch(:allow_xvfb, true)
|
7
9
|
@relevant_options = ["--no-xvfb"]
|
8
10
|
@success_or_skipped = nil # Will be updated once step executes
|
11
|
+
@rspec_exit_status = nil # Will be updated once step executes
|
9
12
|
@user_wants_to_skip_xvfb = ARGV.any? { |option| option.include?("--no-xvfb") }
|
10
13
|
init_rspec_options
|
11
14
|
end
|
@@ -29,6 +32,7 @@ module RspecStarter
|
|
29
32
|
cmd = "#{cmd} #{@rspec_options.join(' ')}" unless @rspec_options.empty?
|
30
33
|
puts "[#{@runner.step_num}] Running specs with '#{cmd.colorize(:light_blue)}' ...\n\n"
|
31
34
|
system cmd
|
35
|
+
@rspec_exit_status = $CHILD_STATUS.exitstatus
|
32
36
|
@success_or_skipped = true
|
33
37
|
end
|
34
38
|
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module RspecStarter
|
2
2
|
# The steps that destorys and rebuilds the DB before running RSpec.
|
3
3
|
class PrepareDatabaseStep < RspecStarter::Step
|
4
|
+
attr_reader :exit_status
|
5
|
+
|
4
6
|
def initialize(defaults, runner)
|
5
7
|
super(runner)
|
6
8
|
@prepare_database = defaults.fetch(:prepare_db, true)
|
7
9
|
@relevant_options << '--no-prep-db'
|
8
10
|
@user_wants_to_skip = ARGV.any? { |option| option.include?("--no-prep-db") }
|
9
11
|
@success_or_skipped = nil # Will be updated once step executes
|
12
|
+
@exit_status = 0 # Will be updated once step executes
|
10
13
|
end
|
11
14
|
|
12
15
|
def failed?
|
@@ -24,7 +27,8 @@ module RspecStarter
|
|
24
27
|
|
25
28
|
rebuild_cmd = rebuild_command
|
26
29
|
print "[#{@runner.step_num}] Preparing the test database with '#{rebuild_cmd.colorize(:light_blue)}' ... "
|
27
|
-
_stdout, stderr,
|
30
|
+
_stdout, stderr, exit_status = Open3.capture3(rebuild_cmd)
|
31
|
+
@exit_status = exit_status.exitstatus
|
28
32
|
@success_or_skipped = successful?(stderr)
|
29
33
|
|
30
34
|
if @success_or_skipped
|
@@ -47,7 +51,7 @@ module RspecStarter
|
|
47
51
|
# Simply checking the exitstatus isn't good enough. When rake aborts due to a bug, it will still
|
48
52
|
# return a zero exit status. We need to see if 'rake aborted!' has been written to the output.
|
49
53
|
def successful?(stderr)
|
50
|
-
return false if
|
54
|
+
return false if @exit_status.nonzero?
|
51
55
|
!stderr.include?("rake aborted!")
|
52
56
|
end
|
53
57
|
end
|
data/rspec_starter.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler", "~>
|
22
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
23
23
|
spec.add_development_dependency "pry-byebug", "~> 3.6.0"
|
24
24
|
spec.add_development_dependency "rake", "~> 12.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry-byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.7.
|
149
|
+
rubygems_version: 2.7.8
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: A Ruby gem that helps run RSpec in a standard manner.
|