rspec_starter 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4c9da79a01f7f899551da8967be196b0ae0de2e4
4
- data.tar.gz: 5ac202d616c486bbcc3a41fea93f8527181eed8a
2
+ SHA256:
3
+ metadata.gz: 675c8382e7232709fcb696221de19a79f5d3eff9b717a4f664bbc54fe666587e
4
+ data.tar.gz: f5a16bc6e027a4cebfd0a8cce5abf6eac79f5359395137c5878538477de1068e
5
5
  SHA512:
6
- metadata.gz: f0f5da7b49b6b93d1e7089c494a991332728687829089891d02b4b4986a93b966e4767851889d4f3e4b6a65c531dd33970afdf6c3cb8e199c592b975b2257e1c
7
- data.tar.gz: 8a6d3e14c89e453c7b496a49b8a498c1b3bb206c820b2930c0af591738f4d9f69fd343fac3a4cc0c70e99743fa3271825fd58fff0d3bd0c3371ff3fcf9c9ccd2
6
+ metadata.gz: f6d0162efa5314de25c8c075951b9390d2f2ea03a38773e39032cbf3dc36a5a5712491272b5bc5b6594bab2451581d6a4191d1aa546440bc6e984bcb9aaf1463
7
+ data.tar.gz: 7cfcab5bd3a442d5380d290d6302bf0e93567c2634f3a55723c89e39b1736723a8d11892117e122dfeead82a64fb6d63975067a256e7e618890691cf0f26de59
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
+ /rubocop/
6
7
  /doc/
7
8
  /pkg/
8
9
  /spec/reports/
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
1
+ --format progress
2
2
  --color
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ # DO NOT MODIFY THIS FILE unless you want to deviate from the rubocop_plus ruleset.
2
+
3
+ # This file defines the settings used by rubocop when it runs. You would normally add your customizations directly to this
4
+ # file, but this file has been pre configured to read settings out of the rubocop_plus gem instead.
5
+
6
+ # Tell rubocop to load its settings from the rubocop_plus gem.
7
+ inherit_gem:
8
+ rubocop_plus: config/rubocop.yml
9
+
10
+ # Place custom settings below this comment. All customizations will OVERRIDE rubocop_plus rules. rubocop_plus & rubocop
11
+ # do not attempt to merge these settings with their defaults. Long term changes should be ported to the rubocop_plus gem.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.2.0
5
+ - 2.3.0
6
+ - 2.4.3
7
+ - 2.5.0
8
+ before_install: gem install bundler -v 1.16.1
data/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.0 (Feb 02, 2018)
4
+
5
+ 1. Ensure the XVFB is detected correctly. (Issue #5)
6
+ 1. Prepare the database when the project is a Rails engine. (Issue #7)
7
+ 1. Add an `rspec_starter --init` command that installs an initial script. (Issue #9)
8
+ 1. Add rubocop_plus gem for internal code cleanup. (Issue #11)
9
+ 1. Change the highlight color of the output from yellow to blue. (Issue #15)
10
+
3
11
  ## 1.0.1 (May 10, 2017)
4
12
 
5
- 1. (Fix) Improve the logic for deciding when the database preparation step has successfully completed, and format the error output better. (Issue #1)
13
+ 1. Improve the logic for deciding when the database preparation step has successfully completed, and format the error output better. (Issue #1)
6
14
 
7
15
  ## 1.0.0 (Apr 06, 2017)
8
16
 
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rspec_starter.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'rubocop_plus', "~> 1.0", require: false
8
+ end
data/README.md CHANGED
@@ -1,72 +1,55 @@
1
1
  # rspec_starter
2
2
 
3
- rspec_starter is a Ruby gem that simplifies the process of running RSpec. Large development teams often manage multiple projects. When developers move around projects, it can be unclear how to start RSpec in a way that runs the test suite properly for a given project. Hopefully someone took the time to explain how to do it in the README, but this frequently doesn't happen.
3
+ rspec_starter is a Ruby gem that simplifies the process of running RSpec. Large development teams often manage multiple projects. Those projects tend to have subtle differences in how rspec should be invoked. Hopefully someone took the time to explain how to do it in the README, but this frequently doesn't happen.
4
4
 
5
- With rspec_starter, a script is created which specifies how to run RSpec properly for the application. Anyone can invoke the script to run the rspec test suite. No confusion. Self documenting. Amazing.
5
+ With rspec_starter, a script is created which specifies how to run RSpec properly for the application. Anyone can invoke the `bin/start_rspec` script to run the rspec test suite. No confusion. Self documenting. Amazing.
6
6
 
7
7
  rspec_starter also helps smooth out differences between operating systems. For example, MacOS provides it's own display server for running feature tests whereas Linux operating systems may need to start a display sever, like XVFB, before feature tests will pass. Once rspec_starter is setup, developers simply execute the script and rspec_starter does the rest.
8
8
 
9
- At the moment, rspec_starter works for Rails applications and raw ruby applications/gems that are not database dependent. We can support other frameworks if needed desired.
9
+ At the moment, rspec_starter works for Rails applications, Rails Engines and raw ruby applications/gems that are not database dependent.
10
10
 
11
11
  ### Main Steps
12
12
 
13
- RSpec runner can curently perform the following steps (these steps can be toggled on or off)
13
+ rspec_starter can curently perform the following steps (these steps can be toggled on or off)
14
14
 
15
- - Prepare a Rails database by running `rake db:drop db:create db:migrate RAILS_ENV=test`
15
+ - Prepare a Rails database (or dummy database inside a Rails engine) by running `rake db:drop db:create db:migrate RAILS_ENV=test`
16
16
  - Remove the `tmp` folder if it exists
17
17
  - Verify XVFB is installed when running on a Linux box
18
- - Start RSpec with 'bundle exec rspec' or 'xvfb-run bundle exec rspec' as needed
18
+ - Start RSpec with `bundle exec rspec` or `xvfb-run bundle exec rspec` (depending on the needs of the OS)
19
19
 
20
20
  ## Versioning Strategy
21
21
 
22
- This gem uses [semver](semver.org).
22
+ This gem uses [Semver](semver.org) 2.0.0.
23
+
24
+ ## Supported Ruby Versions
25
+
26
+ 2.2.0+
23
27
 
24
28
  ## Installation
25
29
 
26
- ### Rails
30
+ ### Rails Applications & Rails Engines
27
31
 
28
- Add this line to your application's Gemfile:
32
+ Add this line to your Gemfile of your Rails application or Rails Engine:
29
33
 
30
34
  ```ruby
31
- gem 'rspec_starter', require: false
35
+ group :development do
36
+ gem 'rspec_starter', require: false
37
+ end
32
38
  ```
33
39
 
34
40
  And then execute:
35
41
 
36
42
  $ bundle
37
43
 
38
- Inside the `bin` folder, create file called `start_rspec` (it can be named anything you like).
39
-
40
- Run `chmod +x start_rspec` to make the file executable.
41
-
42
- Add the following contents to the file
43
-
44
- #!/usr/bin/env ruby
45
-
46
- # Execute this script to run RSpec for the app.
47
- # To run all specs, navigate to the application's root folder and execute
48
- # bin/start_rspec
49
- # rspec_starter takes command line options and forwards unknown options to rspec
50
- # bin/start_rspec --no-prep-db spec/features
51
- # See the help output for more advanced ways to run the script
52
- # bin/start_rspec --help
53
-
54
- require "bundler/setup"
55
- require "rspec_starter"
44
+ Run the installer
56
45
 
57
- # The path to the application's root folder.
58
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
46
+ $ rspec_starter --init
59
47
 
60
- # Run commands in the context of the application's root folder.
61
- Dir.chdir APP_ROOT do
62
- # Arguments passed to 'start' define the steps needed to cleanly run RSpec.
63
- # Command line options may change execution on a per-run basis.
64
- RspecStarter.start(prepare_db: true, remove_tmp: true, allow_xvfb: true)
65
- end
48
+ The above command installs the script you will use to run rspec. The file is named `start_rspec`, but you can rename it to anything you like.
66
49
 
67
50
  ## Usage
68
51
 
69
- `cd` into the root of your application/project and invoke the script. For these examples, it is assumed you placed the script in the `bin` folder of your app.
52
+ `cd` into the root of your application/project and invoke the script. For these examples, it is assumed you placed the script in the `bin` folder of your app (but you could put it anywhere you like).
70
53
 
71
54
  $ bin/start_rspec
72
55
 
@@ -80,13 +63,13 @@ which tells start_rspec, to tell rspec, to only run the feature tests. Run the
80
63
 
81
64
  ## Configuration
82
65
 
83
- The entire idea behind start_rspec is to standardize the process of starting application. You can modify the `bin/start_rspec` file (assuming you put `start_rspec` inside the `bin` folder of your project) to do whatever you want. If you open that file, you'll see that it basically does one thing - it calls the following command in the context of the root folder, of your project:
66
+ The entire idea behind start_rspec is to standardize the process of starting application. You can modify the `bin/start_rspec` file to do whatever you want. If you open that file, you'll see that it does one thing - it calls the following command in the context of the root folder, of your project:
84
67
 
85
68
  RspecStarter.start(prepare_db: true, remove_tmp: true, allow_xvfb: true)
86
69
 
87
70
  The arguments passed to `start_rspec`, represent the defaults you consider important for achieving a clean RSpec run. If your particular project doesn't have a DB, or you don't need it prepared before each Rspec run, you could turn that step off by passing `prepare_db: false`.
88
71
 
89
- Be careful about the steps you enable/disable inside the script file. **The goal is to define steps that help people, with limited knowledge of the app, successfully run the test suite.** Having said that, it's certainly a waste of time to prepare the test database if you just ran the test suite and you know it's empty (start_rspec doesn't advocate seeding the test database). If you want to turn steps off on a per run basis, you can use command line options. Run `bin/start_rspec --help` to see a list of available options.
72
+ Be careful about the steps you enable/disable inside the script file. **The goal is to define steps that help people, with limited knowledge of the project, successfully run RSpec.** It's best to have the bin/start_rspec define the best way to run rspec for newbies. You can disable specific steps by passing in command line options. Run `bin/start_rspec --help` to see a list of available options.
90
73
 
91
74
  ## Contributing
92
75
 
data/exe/rspec_starter ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # An executable installed by the rspec_starter gem. It's currently used to install a bin/start_rspec script.
4
+ #
5
+ # EXECUTION
6
+ #
7
+ # rspec_starter # Currently a no-op.
8
+ # rspec_starter -i # Install the bin/start_rspec script.
9
+ # rspec_starter -h # View the help file to see more options.
10
+
11
+ lib = File.expand_path('../../lib', __FILE__)
12
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
13
+
14
+ require "cri"
15
+ require 'fileutils'
16
+
17
+ module Cri
18
+ # A small monkey patch to force the cri gem to stop coloring output.
19
+ module Platform
20
+ def self.color?(_io)
21
+ false
22
+ end
23
+ end
24
+ end
25
+
26
+ command = Cri::Command.define do
27
+ usage 'rspec_starter [options]'
28
+ # aliases :ds, :stuff
29
+ # summary 'foo'
30
+ description "An executable installed by the rspec_starter gem. It's currently used to install a bin/start_rspec script."
31
+
32
+ flag :h, :help, 'show help for this command' do |_value, cmd|
33
+ puts cmd.help
34
+ exit 0
35
+ end
36
+
37
+ flag :i, :init, "(re)initialize your project bin/start_rspec file" do |_value, _cmd|
38
+ if File.file?("bin/start_rspec")
39
+ FileUtils.mv("bin/start_rspec", "bin/start_rspec.bak")
40
+ puts "bin/start_rspec renamed to bin/start_rspec.bak"
41
+ end
42
+
43
+ template_path = File.expand_path('../../lib/templates/start_rspec', __FILE__)
44
+ FileUtils.cp(template_path, "bin/start_rspec")
45
+ File.chmod(0o775, "bin/start_rspec")
46
+ puts "bin/start_rspec created"
47
+ exit 0
48
+ end
49
+
50
+ flag :v, :version, 'return the version of rspec_starter' do |_value, _cmd|
51
+ require 'rspec_starter/version'
52
+ puts RspecStarter::VERSION
53
+ exit 0
54
+ end
55
+
56
+ run do |options, args, cmd|
57
+ end
58
+ end
59
+
60
+ begin
61
+ command.run(ARGV)
62
+ exit 0
63
+ end
data/lib/rspec_starter.rb CHANGED
@@ -1,6 +1,9 @@
1
+ require 'English'
2
+ require 'colorize'
1
3
  require "rspec_starter/version"
2
4
  require_relative 'rspec_starter/runner'
3
5
 
6
+ # Entry point for the RspecStarter gem.
4
7
  module RspecStarter
5
8
  # The 'start' method takes arguments that can be used to control the steps that are executed when running Rspec. These
6
9
  # arguments are specified by the developer when configuring how the app prefers to run RSpec. In addition to the arguments,
@@ -4,16 +4,4 @@ class String
4
4
  def rs_colorize(color_code)
5
5
  "\e[#{color_code}m#{self}\e[0m"
6
6
  end
7
-
8
- def rs_red
9
- rs_colorize(31)
10
- end
11
-
12
- def rs_green
13
- rs_colorize(32)
14
- end
15
-
16
- def rs_yellow
17
- rs_colorize(33)
18
- end
19
7
  end
@@ -1,35 +1,40 @@
1
1
  module RspecStarter
2
+ # Method that support the help option on the bin/start_rspec script.
2
3
  module Help
3
4
  def should_show_help?
4
5
  ARGV.any? { |option| option.include? "--help" }
5
6
  end
6
7
 
7
8
  def show_help
8
- # Figure out the name of the file that invoked the rspec_starter helper. This is the name of the script; it be called anything.
9
+ # Figure out the file name that invoked the rspec_starter helper. This is the name of the script; it be called anything.
9
10
  script_name = calling_file_name
10
- puts "Usage: #{script_name.rs_yellow} #{'[options] [options for RSpec]'.rs_yellow}\n"
11
+ puts "Usage: #{script_name.colorize(:light_blue)} #{'[options] [options for RSpec]'.colorize(:light_blue)}\n"
11
12
  puts " #{script_name} will look for its own options first then pass any remaining options to rspec"
12
13
 
14
+ # rubocop:disable Metrics/LineLength
13
15
  puts "\nOptions: (run 'rspec --help' to see RSpec's options)"
14
- puts " #{'--no-xvfb'.rs_yellow} DO NOT run XVFB (this can speed up RSpec when running tests that don't need XVFB)"
15
- puts " #{'--no-prep'.rs_yellow} DO NOT prepare the test database (can speed up testing if you know the DB is clean)"
16
+ puts " #{'--no-xvfb'.colorize(:light_blue)} DO NOT run XVFB (this can speed up RSpec when running tests that don't need XVFB)"
17
+ puts " #{'--no-prep'.colorize(:light_blue)} DO NOT prepare the test database (can speed up testing if you know the DB is clean)"
16
18
 
17
19
  puts "\nExamples:"
18
- puts " #{script_name.rs_yellow} #{'spec/features'.rs_yellow} (only run specs in the specs/features folder)"
19
- puts " #{script_name.rs_yellow} #{'spec/features/some_spec:53'.rs_yellow} (run the spec on line 53 of the spec/features_some_spec.rb file)"
20
- puts " #{script_name.rs_yellow} #{'--no-xvfb'.rs_yellow} #{'spec/requests/some_spec'.rs_yellow} (don't start XVFB since it's not needed for request specs)"
21
- puts " SIMPLECOV_FORMATTER=rcov #{script_name.rs_yellow} (use with environment variables)\n"
20
+ puts " #{script_name.colorize(:light_blue)} #{'spec/features'.colorize(:light_blue)} (only run specs in the specs/features folder)"
21
+ puts " #{script_name.colorize(:light_blue)} #{'spec/features/some_spec:53'.colorize(:light_blue)} (run the spec on line 53 of the spec/features_some_spec.rb file)"
22
+ puts " #{script_name.colorize(:light_blue)} #{'--no-xvfb'.colorize(:light_blue)} #{'spec/requests/some_spec'.colorize(:light_blue)} (don't start XVFB since it's not needed for request specs)"
23
+ puts " #{'SIMPLECOV_FORMATTER=rcov'.colorize(:light_blue)} #{script_name.colorize(:light_blue)} (use with environment variables)\n"
24
+ # rubocop:enable Metrics/LineLength
22
25
  end
23
26
 
24
27
  # This is ugly, but it gives us some added flexibility. Users can invoke the rspec_starter method from any script or
25
28
  # executable. This method attempts to find out the name of the script/exectuable.
26
- # "caller" returns the method stack, and because of the location of this file in the gem, we happen to be the 4 item in the
29
+ # "caller" returns the method stack, and because of the location of this file in the gem, we happen to be the 4th item in the
27
30
  # the array (hence "caller[3]" below).
28
31
  #
29
32
  # This method may not return a pretty result in all cases, but it's decent if the user has defined a script in their project
30
33
  # (possibly in the bin folder, or root of the project).
31
34
  def calling_file_name
35
+ # rubocop:disable Performance/Caller
32
36
  caller[3].split(":")[0]
37
+ # rubocop:enable Performance/Caller
33
38
  end
34
39
  end
35
40
  end
@@ -33,18 +33,29 @@ module RspecStarter
33
33
  return show_help if should_show_help? # If we show help, exit and don't do anything else.
34
34
 
35
35
  @steps.each do |step|
36
- if step.should_execute?
37
- step.execute
38
- @step_num += 1
39
- break if step.failed?
40
- end
36
+ next unless step.should_execute?
37
+ step.execute
38
+ @step_num += 1
39
+ break if step.failed?
41
40
  end
42
41
  end
43
42
 
44
- def app_uses_rails?
43
+ def project_is_rails_app?
45
44
  File.file?(File.join(Dir.pwd, 'config', 'application.rb'))
46
45
  end
47
46
 
47
+ def project_is_rails_engine?
48
+ return false unless project_has_lib_dir?
49
+ Dir["#{Dir.pwd}/lib/**/*.rb"].each do |file|
50
+ return true if File.readlines(file).detect { |line| line.match(/\s*class\s+.*<\s+::Rails::Engine/) }
51
+ end
52
+ false
53
+ end
54
+
55
+ def project_has_lib_dir?
56
+ Dir.exist?("#{Dir.pwd}/lib")
57
+ end
58
+
48
59
  def operating_system_name
49
60
  result = `uname`
50
61
  return 'Linux' if result.include?('Linux')
@@ -1,6 +1,6 @@
1
1
  module RspecStarter
2
+ # The step that actually starts the RSpec.
2
3
  class InvokeRspecStep < RspecStarter::Step
3
-
4
4
  def initialize(defaults, runner)
5
5
  super(runner)
6
6
  @allow_xvfb = defaults.fetch(:allow_xvfb, true)
@@ -27,7 +27,7 @@ module RspecStarter
27
27
  def execute
28
28
  cmd = command
29
29
  cmd = "#{cmd} #{@rspec_options.join(' ')}" unless @rspec_options.empty?
30
- puts "[#{@runner.step_num}] Running specs with '#{cmd.rs_yellow}' ...\n\n"
30
+ puts "[#{@runner.step_num}] Running specs with '#{cmd.colorize(:light_blue)}' ...\n\n"
31
31
  system cmd
32
32
  @success_or_skipped = true
33
33
  end
@@ -1,4 +1,5 @@
1
1
  module RspecStarter
2
+ # The steps that destorys and rebuilds the DB before running RSpec.
2
3
  class PrepareDatabaseStep < RspecStarter::Step
3
4
  def initialize(defaults, runner)
4
5
  super(runner)
@@ -15,27 +16,27 @@ module RspecStarter
15
16
  def should_execute?
16
17
  return false if @user_wants_to_skip
17
18
  return false unless @prepare_database
18
- @runner.app_uses_rails?
19
+ @runner.project_is_rails_app? || @runner.project_is_rails_engine?
19
20
  end
20
21
 
21
22
  def execute
22
23
  return @success_or_skipped = true if should_skip?
23
24
 
24
25
  rebuild_cmd = "rake db:drop db:create db:migrate RAILS_ENV=test"
25
- print "[#{@runner.step_num}] Preparing the test database with '#{rebuild_cmd.rs_yellow}' ... "
26
+ print "[#{@runner.step_num}] Preparing the test database with '#{rebuild_cmd.colorize(:light_blue)}' ... "
26
27
  _stdin, _stdout, stderr = Open3.popen3(rebuild_cmd)
27
28
  output_array = prepare_output_array(stderr.readlines)
28
29
 
29
- if successful?(output_array)
30
- puts "Success".rs_green
30
+ @success_or_skipped = successful?(output_array)
31
+
32
+ if @success_or_skipped
33
+ puts "Success".colorize(:green)
31
34
  puts output_array
32
- @success_or_skipped = true
33
35
  else
34
- puts "Fail".rs_red + "\n\n"
36
+ puts "Fail".colorize(:red) + "\n\n"
35
37
  puts output_array
36
- puts "\n\nThere was an error rebuilding the test database. See the output above for details.".rs_red
37
- puts "or manually run '#{rebuild_cmd}' for more information.".rs_red
38
- @success_or_skipped = false
38
+ puts "\n\nThere was an error rebuilding the test database. See the output above for details.".colorize(:red)
39
+ puts "or manually run '#{rebuild_cmd}' for more information.".colorize(:red)
39
40
  end
40
41
  end
41
42
 
@@ -44,12 +45,12 @@ module RspecStarter
44
45
  # Simply checking the exitstatus isn't good enough. When rake aborts due to a bug, it will still
45
46
  # return a zero exit status. We need to see if 'rake aborted!' has been written to the output.
46
47
  def successful?(output_array)
47
- return false if $?.exitstatus.nonzero?
48
- not output_array.any? { |result| result.include? "rake aborted!"}
48
+ return false if $CHILD_STATUS.exitstatus.nonzero?
49
+ output_array.none? { |result| result.include? "rake aborted!" }
49
50
  end
50
51
 
51
52
  def prepare_output_array(array)
52
- (0..array.size-1).each { |i| array[i] = " #{array[i].strip}".rs_red }
53
+ (0..array.size - 1).each { |i| array[i] = " #{array[i].strip}".colorize(:red) }
53
54
  array
54
55
  end
55
56
  end
@@ -1,4 +1,5 @@
1
1
  module RspecStarter
2
+ # The step that removes the tmp folder.
2
3
  class RemoveTmpFolderStep < RspecStarter::Step
3
4
  def initialize(defaults, runner)
4
5
  super(runner)
@@ -22,7 +23,7 @@ module RspecStarter
22
23
  return @success_or_skipped = true unless should_execute?
23
24
  existed_before = tmp_folder_exists?
24
25
 
25
- print "[#{@runner.step_num}] Removing #{'tmp'.rs_yellow} folder ... "
26
+ print "[#{@runner.step_num}] Removing #{'tmp'.colorize(:light_blue)} folder ... "
26
27
  system "rm -rf tmp/"
27
28
 
28
29
  if tmp_folder_exists?
@@ -31,7 +32,7 @@ module RspecStarter
31
32
  else
32
33
  @success_or_skipped = true
33
34
  info = existed_before ? "" : " (the tmp folder didn't exist)"
34
- puts "Success!!#{info}".rs_green
35
+ puts "Success!!#{info}".colorize(:green)
35
36
  end
36
37
  end
37
38
 
@@ -1,4 +1,5 @@
1
1
  module RspecStarter
2
+ # Abstract super class for a step.
2
3
  class Step
3
4
  attr_reader :relevant_options
4
5
 
@@ -1,6 +1,8 @@
1
1
  module RspecStarter
2
+ # The step that makes sure XVFB is installed on the system. When feature tests run, they need a display server to power the
3
+ # browsr that will execute the feature tests. MacOS provides its own display server that always runs. Linux needs one
4
+ # installed and activated.
2
5
  class VerifyXvfbStep < RspecStarter::Step
3
-
4
6
  def initialize(defaults, runner)
5
7
  super(runner)
6
8
  @relevant_options << '--no-xvfb'
@@ -32,17 +34,14 @@ module RspecStarter
32
34
  print "[#{@runner.step_num}] Verifying display server ... "
33
35
 
34
36
  if @runner.is_linux? && !@runner.xvfb_installed?
35
- print "Warning".rs_yellow
36
- return puts " (XVFB has NOT been installed on this system. If you are running feature specs, they will fail.)".rs_yellow
37
+ return puts "Warning (XVFB is not installed. Feature specs will fail.)".colorize(:yellow)
37
38
  end
38
39
 
39
40
  if @runner.is_mac? && @runner.xvfb_installed?
40
- print "Warning".rs_yellow
41
- return puts " (XVFB has been installed. This is not needed on a Mac and may cause specs to fail.)".rs_yellow
41
+ return puts "Warning (XVFB has been installed. It's not needed on a Mac and may cause specs to fail.)".colorize(:yellow)
42
42
  end
43
43
 
44
- puts "Success!!".rs_green
44
+ puts "Success!!".colorize(:green)
45
45
  end
46
46
  end
47
47
  end
48
-
@@ -1,3 +1,3 @@
1
1
  module RspecStarter
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0".freeze
3
3
  end
@@ -1,12 +1,13 @@
1
+ # A helper method for figuring out if a command exists on the file system.
1
2
  module RspecStarter
2
3
  def self.which(cmd)
3
4
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
4
5
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
5
- exts.each { |ext|
6
+ exts.each do |ext|
6
7
  exe = File.join(path, "#{cmd}#{ext}")
7
8
  return exe if File.executable?(exe) && !File.directory?(exe)
8
- }
9
+ end
9
10
  end
10
- return "nil"
11
+ false
11
12
  end
12
13
  end
@@ -18,5 +18,5 @@ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
18
18
  Dir.chdir APP_ROOT do
19
19
  # Arguments passed to 'start' define the steps needed to cleanly run RSpec.
20
20
  # Command line options may change execution on a per-run basis.
21
- RspecStarter.start(prepare_db: false, remove_tmp: true, allow_xvfb: true)
21
+ RspecStarter.start(prepare_db: true, remove_tmp: true, allow_xvfb: true)
22
22
  end
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'rspec_starter/version'
@@ -21,7 +20,10 @@ Gem::Specification.new do |spec|
21
20
  spec.require_paths = ["lib"]
22
21
 
23
22
  spec.add_development_dependency "bundler", "~> 1.14"
23
+ spec.add_development_dependency "pry-byebug", "~> 3.6.0"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "pry"
26
+
27
+ spec.add_dependency "cri", "~> 2.10.1"
28
+ spec.add_dependency "colorize", "~> 0.8.1"
27
29
  end
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.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberts
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2018-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry-byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.6.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.6.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,28 +67,45 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: pry
70
+ name: cri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.10.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.10.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: colorize
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - ">="
87
+ - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
89
+ version: 0.8.1
90
+ type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - ">="
94
+ - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '0'
96
+ version: 0.8.1
69
97
  description: A Ruby gem that helps run RSpec in a standard manner.
70
98
  email:
71
99
  - roberts@corlewsolutions.com
72
- executables: []
100
+ executables:
101
+ - rspec_starter
73
102
  extensions: []
74
103
  extra_rdoc_files: []
75
104
  files:
76
105
  - ".gitignore"
77
106
  - ".rspec"
107
+ - ".rubocop.yml"
108
+ - ".travis.yml"
78
109
  - CHANGELOG.md
79
110
  - Gemfile
80
111
  - LICENSE.md
@@ -82,7 +113,7 @@ files:
82
113
  - Rakefile
83
114
  - bin/console
84
115
  - bin/setup
85
- - bin/start_rspec
116
+ - exe/rspec_starter
86
117
  - lib/rspec_starter.rb
87
118
  - lib/rspec_starter/core_ext/string.rb
88
119
  - lib/rspec_starter/help.rb
@@ -94,6 +125,7 @@ files:
94
125
  - lib/rspec_starter/steps/verify_xvfb_step.rb
95
126
  - lib/rspec_starter/version.rb
96
127
  - lib/rspec_starter/which.rb
128
+ - lib/templates/start_rspec
97
129
  - rspec_starter.gemspec
98
130
  homepage: https://github.com/roberts1000/rspec_starter
99
131
  licenses: []
@@ -114,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
146
  version: '0'
115
147
  requirements: []
116
148
  rubyforge_project:
117
- rubygems_version: 2.6.11
149
+ rubygems_version: 2.7.3
118
150
  signing_key:
119
151
  specification_version: 4
120
152
  summary: A Ruby gem that helps run RSpec in a standard manner.