rspec_starter 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/.travis.yml +5 -5
- data/CHANGELOG.md +29 -18
- data/README.md +145 -115
- data/exe/rspec_starter +14 -1
- data/lib/rspec_starter.rb +69 -24
- data/lib/rspec_starter/command.rb +59 -0
- data/lib/rspec_starter/command_context.rb +38 -0
- data/lib/rspec_starter/core_ext/string.rb +6 -3
- data/lib/rspec_starter/environment.rb +57 -0
- data/lib/rspec_starter/errors/step_error.rb +9 -0
- data/lib/rspec_starter/errors/step_stopper.rb +9 -0
- data/lib/rspec_starter/help.rb +79 -32
- data/lib/rspec_starter/helpers.rb +74 -0
- data/lib/rspec_starter/{which.rb → helpers/which.rb} +0 -0
- data/lib/rspec_starter/legacy.rb +16 -0
- data/lib/rspec_starter/legacy/help.rb +40 -0
- data/lib/rspec_starter/legacy/legacy_runner.rb +90 -0
- data/lib/rspec_starter/{steps → legacy/steps}/invoke_rspec_step.rb +2 -0
- data/lib/rspec_starter/{steps → legacy/steps}/prepare_database_step.rb +3 -1
- data/lib/rspec_starter/{steps → legacy/steps}/remove_tmp_folder_step.rb +3 -0
- data/lib/rspec_starter/{steps → legacy/steps}/step.rb +0 -0
- data/lib/rspec_starter/{steps → legacy/steps}/verify_xvfb_step.rb +2 -0
- data/lib/rspec_starter/option.rb +84 -0
- data/lib/rspec_starter/options.rb +96 -0
- data/lib/rspec_starter/rspec_starter_task.rb +35 -0
- data/lib/rspec_starter/runner.rb +15 -74
- data/lib/rspec_starter/step.rb +181 -0
- data/lib/rspec_starter/step_context.rb +28 -0
- data/lib/rspec_starter/step_options.rb +20 -0
- data/lib/rspec_starter/task_context.rb +63 -0
- data/lib/rspec_starter/tasks/rebuild_rails_app_database.rb +50 -0
- data/lib/rspec_starter/tasks/remove_tmp_folder.rb +28 -0
- data/lib/rspec_starter/tasks/start_rspec.rb +68 -0
- data/lib/rspec_starter/tasks/verify_display_server.rb +43 -0
- data/lib/rspec_starter/version.rb +1 -1
- data/lib/templates/rails_engine_start_rspec +38 -0
- data/lib/templates/rails_start_rspec +38 -0
- data/lib/templates/start_rspec +20 -5
- data/rspec_starter.gemspec +4 -2
- metadata +63 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07651d1f45ae7e33bb3d5de51c198c87f6be0749803084eeae6ed4e2e2a2dfdb
|
4
|
+
data.tar.gz: '00769c37402ced8b3ce2c3d362bd6277d348d77e9f50d20c639ec2921425a47d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a06b48f11b0e5240dcc51761de9304e342d67e7d1d194823b1d3f64af98ad65499bcfafcefef8d2b1903f80e51ee9ad4bc39cd8fa12d2e29a90cdbd5b3c9ddc7
|
7
|
+
data.tar.gz: 5dc317a2c50d27d56bae0a2e7d556d803fe2c913fae7ed9aad9b9645e2ba0363cc111e83d5ff900a65e2237db941c5562358e34edb2293774fe5c8802c19d14c
|
data/.rubocop.yml
CHANGED
@@ -9,3 +9,12 @@ inherit_gem:
|
|
9
9
|
|
10
10
|
# Place custom settings below this comment. All customizations will OVERRIDE rubocop_plus rules. rubocop_plus & rubocop
|
11
11
|
# do not attempt to merge these settings with their defaults. Long term changes should be ported to the rubocop_plus gem.
|
12
|
+
|
13
|
+
Rails:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/NumericPredicate:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/Alias:
|
20
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.3.
|
5
|
-
- 2.4.
|
6
|
-
- 2.5.
|
7
|
-
- 2.6.
|
8
|
-
before_install: gem install bundler -v 2.0.
|
4
|
+
- 2.3.8
|
5
|
+
- 2.4.9
|
6
|
+
- 2.5.7
|
7
|
+
- 2.6.5
|
8
|
+
before_install: gem install bundler -v 2.0.2
|
9
9
|
notifications:
|
10
10
|
email:
|
11
11
|
on_success: never # default: change
|
data/CHANGELOG.md
CHANGED
@@ -1,43 +1,54 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
Issues marked as **(Internal)** mark internal development work. Issues are tracked at https://github.com/roberts1000/rspec_starter/issues.
|
4
|
+
|
5
|
+
## 1.6.0 (Dec 09, 2019)
|
6
|
+
|
7
|
+
1. [#56](../../issues/56) Move old starter code to a `legacy` folder so it can still be used. **(Internal)**
|
8
|
+
1. [#58](../../issues/58) Add step based interface.
|
9
|
+
1. [#59](../../issues/59) Use `rake ~> 13.0` for development. **(Internal)**
|
10
|
+
1. [#61](../../issues/61) Use `pry-byebug ~> 3.7.0` for development. **(Internal)**
|
11
|
+
1. [#63](../../issues/63) Modernize the CHANGELOG. **(Internal)**
|
12
|
+
1. [#66](../../issues/66) Update ruby versions and use bundler 2.0.2 in `travis.yml`. **(Internal)**
|
13
|
+
|
3
14
|
## 1.5.0 (Feb 19, 2019)
|
4
15
|
|
5
|
-
1. Report an exit status of 1 if DB Preparation or RSpec fails.
|
16
|
+
1. [#51](../../issues/51) Report an exit status of 1 if DB Preparation or RSpec fails.
|
6
17
|
|
7
18
|
## 1.4.0 (Oct 12, 2018)
|
8
19
|
|
9
|
-
1. Isolate rebuild command string into a dedicated method
|
10
|
-
1. Add instructions for creating custom steps.
|
11
|
-
1. Fix database rebuild command hanging when there's too much output.
|
20
|
+
1. [#41](../../issues/41) Isolate rebuild command string into a dedicated method. **(Internal)**
|
21
|
+
1. [#43](../../issues/43) Add instructions for creating custom steps.
|
22
|
+
1. [#45](../../issues/45) Fix the database rebuild command hanging when there's too much output.
|
12
23
|
|
13
24
|
## 1.3.0 (Aug 30, 2018)
|
14
25
|
|
15
|
-
1. Change `cri` version to `~> 2.0`.
|
26
|
+
1. [#37](../../issues/37) Change `cri` version to `~> 2.0`.
|
16
27
|
|
17
28
|
## 1.2.0 (Aug 08, 2018)
|
18
29
|
|
19
|
-
1. Remove rubocop_plus from Gemfile.
|
20
|
-
1. Update ruby versions in
|
21
|
-
1. Use `bundler` `1.16.3` in
|
22
|
-
1. Use `cri` `~> 2.12.0`.
|
23
|
-
1. Remove support for Ruby 2.2.
|
24
|
-
1. Use `rake` `~> 12.0` in development.
|
30
|
+
1. [#23](../../issues/23) Remove `rubocop_plus` from Gemfile. **(Internal)**
|
31
|
+
1. [#24](../../issues/24) Update ruby versions in `.travis.yml`. **(Internal)**
|
32
|
+
1. [#26](../../issues/26) Use `bundler` `1.16.3` in `.travis.yml`. **(Internal)**
|
33
|
+
1. [#29](../../issues/29) Use `cri` `~> 2.12.0`.
|
34
|
+
1. [#31](../../issues/31) Remove support for Ruby 2.2.
|
35
|
+
1. [#33](../../issues/33) Use `rake` `~> 12.0` in development. **(Internal)**
|
25
36
|
|
26
37
|
## 1.1.1 (May 06, 2018)
|
27
38
|
|
28
|
-
1. Cleanup rubocop issues in the `start_rspec` template
|
39
|
+
1. [#6](../../issues/6) Cleanup rubocop issues in the `start_rspec` template.
|
29
40
|
|
30
41
|
## 1.1.0 (Feb 02, 2018)
|
31
42
|
|
32
|
-
1. Ensure
|
33
|
-
1. Prepare the database when the project is a Rails engine.
|
34
|
-
1. Add an `rspec_starter --init` command that installs an initial script.
|
35
|
-
1. Add rubocop_plus gem for internal code cleanup.
|
36
|
-
1. Change the highlight color of the output from yellow to blue.
|
43
|
+
1. [#5](../../issues/5) Ensure XVFB is detected correctly.
|
44
|
+
1. [#7](../../issues/7) Prepare the database when the project is a Rails engine.
|
45
|
+
1. [#9](../../issues/9) Add an `rspec_starter --init` command that installs an initial script.
|
46
|
+
1. [#11](../../issues/11) Add `rubocop_plus` gem for internal code cleanup. **(Internal)**
|
47
|
+
1. [#15](../../issues/15) Change the highlight color of the output from yellow to blue.
|
37
48
|
|
38
49
|
## 1.0.1 (May 10, 2017)
|
39
50
|
|
40
|
-
1. Improve the logic for deciding when the database preparation step
|
51
|
+
1. [#1](../../issues/1) Improve the logic for deciding when the database preparation step successfully completes.
|
41
52
|
|
42
53
|
## 1.0.0 (Apr 06, 2017)
|
43
54
|
|
data/README.md
CHANGED
@@ -1,23 +1,12 @@
|
|
1
1
|
# rspec_starter
|
2
2
|
|
3
|
-
rspec_starter is a Ruby gem that simplifies the process of running RSpec.
|
3
|
+
rspec_starter is a Ruby gem that simplifies the process of running RSpec. Instead of running `bundle exec rspec`, developers run a script that includes predefined steps to execute while starting RSpec. The steps can be anything from removing the projects `tmp` folder to doing a full rebuild of the database prior to starting RSpec.
|
4
4
|
|
5
|
-
|
5
|
+
rspec_starter also helps eliminate differences between operating systems. For example, MacOS provides it's own display server for running feature tests while Linux operating systems may need to start a display sever, like XVFB. rspec_starter can inspect the OS and start the display server if necessary.
|
6
6
|
|
7
|
-
rspec_starter
|
7
|
+
rspec_starter currently works natively for Rails applications, Rails Engines and raw ruby applications/gems that are not database dependent. However, rspec_starter is flexible and you can add your own tasks to support other types of projects.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
### Main Steps
|
12
|
-
|
13
|
-
rspec_starter can currently perform the following steps (these steps can be toggled on or off)
|
14
|
-
|
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
|
-
- Remove the `tmp` folder if it exists
|
17
|
-
- Verify XVFB is installed when running on a Linux box
|
18
|
-
- Start RSpec with `bundle exec rspec` or `xvfb-run bundle exec rspec` (depending on the needs of the OS)
|
19
|
-
|
20
|
-
## Version Policy
|
9
|
+
## Version Strategy
|
21
10
|
|
22
11
|
Releases are versioned using [semver 2.0.0](https://semver.org/spec/v2.0.0.html).
|
23
12
|
|
@@ -29,7 +18,7 @@ Releases are versioned using [semver 2.0.0](https://semver.org/spec/v2.0.0.html)
|
|
29
18
|
|
30
19
|
### Rails Applications & Rails Engines
|
31
20
|
|
32
|
-
Add this line to
|
21
|
+
Add this line to the `Gemfile` of your Rails application or Rails Engine:
|
33
22
|
|
34
23
|
```ruby
|
35
24
|
group :development do
|
@@ -37,167 +26,208 @@ group :development do
|
|
37
26
|
end
|
38
27
|
```
|
39
28
|
|
40
|
-
|
29
|
+
You do not need to add rspec_starter to the `:test` group since rspec_starter doesn't execute while RSpec runs. Its work is done once RSpec starts.
|
30
|
+
|
31
|
+
Next, execute:
|
41
32
|
|
42
33
|
$ bundle
|
43
34
|
|
44
|
-
|
35
|
+
Then run the installer
|
45
36
|
|
46
37
|
$ rspec_starter --init
|
47
38
|
|
48
|
-
The
|
39
|
+
The installer creates a `bin/start_rspec` that you will use to start RSpec. You can rename the file to anything you want.
|
49
40
|
|
50
|
-
## Usage
|
41
|
+
## Basic Usage
|
51
42
|
|
52
|
-
`cd` into the root of your
|
43
|
+
`cd` into the root of your project and invoke the script.
|
53
44
|
|
54
45
|
$ bin/start_rspec
|
55
46
|
|
56
|
-
The
|
47
|
+
The `bin/start_rspec` file executes a series of "steps" (more on this later) and eventually starts RSpec. Output from RSpec is displayed to the console as normal.
|
48
|
+
|
49
|
+
You can pass command line arguments to rspec_starter. To see the full list, type `bin/start_rspec --help`. When you pass arguments, rspec_starter first checks if any of them are specific to rspec_starter. It processes those arguments and takes action. Any remaining arguments are saved and passed to RSpec when RSpec is started. You can use all the normal RSpec command line options, except for `--help` and `-h` (rspec_starter assumes you want help for rspec_starter instead of rspec). rspec_starter will happily forward them on. For example, if you only want to execute the feature specs in your project, simply do what you would normally do for RSpec:
|
57
50
|
|
58
51
|
$ bin/start_rspec spec/features
|
59
52
|
|
60
|
-
|
53
|
+
## Customizing the bin/start_rspec file
|
61
54
|
|
62
|
-
|
55
|
+
The `bin/start_rspec` file was made to be edited. When you ran the `rspec_starter --init` command, it installed a basic command for your project that looked something like this:
|
63
56
|
|
64
|
-
|
57
|
+
```ruby
|
58
|
+
RspecStarter.start do
|
59
|
+
task :verify_display_server
|
60
|
+
task :remove_tmp_folder
|
61
|
+
task :rebuild_rails_app_database
|
62
|
+
task :start_rspec
|
63
|
+
command "echo 'Done Diggity Done!'"
|
64
|
+
end
|
65
|
+
```
|
65
66
|
|
66
|
-
|
67
|
+
#### Steps
|
67
68
|
|
68
|
-
|
69
|
-
1. `PrepareDatabaseStep` - Runs `rake db:drop db:create db:migrate RAILS_ENV=test`.
|
70
|
-
1. `RemoveTmpFolderStep` - Deletes the `tmp` folder.
|
71
|
-
1. `InvokeRspecStep` - Runs `bundle exec rspec`.
|
69
|
+
At it's heart, rspec_starter is just a block that lists a series of "steps" that are executed in **top down order**. rspec_starter provides two kinds of steps:
|
72
70
|
|
73
|
-
|
71
|
+
1. `command` - A "command" is the most basic kind of "step" in rspec_starter. It accepts a string and passes that string to the ruby `system` command. It can be used to run shell commands or scripts.
|
72
|
+
1. `task` - A "task" is just a ruby class that implements an `execute` method. What you do in that `execute` method is up to you. rspec_starter provides a couple built-in tasks that perform various actions that are useful when running RSpec. The list of available task are defined below. You can also easily create your own.
|
74
73
|
|
75
|
-
####
|
74
|
+
#### Step Options
|
76
75
|
|
77
|
-
|
76
|
+
Any options that you add to steps inside the block, become available to the task.
|
78
77
|
|
79
78
|
```ruby
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
module CustomStep
|
87
|
-
def execute
|
88
|
-
# Place code above the super call if you want it run before the targeted step
|
89
|
-
super # super needs to be called if you want the targeted step to execute
|
90
|
-
# Place code after the super call if you want it run after the targeted step
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
RspecStarter::PrepareDatabaseStep.prepend CustomStep
|
95
|
-
|
96
|
-
Dir.chdir APP_ROOT do
|
97
|
-
RspecStarter.start(prepare_db: true, remove_tmp: true, allow_xvfb: true)
|
79
|
+
RspecStarter.start do
|
80
|
+
task :verify_display_servr, foo: :bar
|
81
|
+
task :remove_tmp_folder
|
82
|
+
task :rebuild_rails_app_database, command: "rake db:drop db:create db:migrate", quiet: false
|
83
|
+
task :start_rspec, quiet: true
|
98
84
|
end
|
99
85
|
```
|
100
86
|
|
101
|
-
|
87
|
+
Tasks ignore options unless they are specifically coded to look for them. For example, the `foo: :bar` in the above example has no affect on the `verify_display_server` task while the `command` option on the `rebuild_rails_app_database` changes the command that is executed.
|
102
88
|
|
103
|
-
|
89
|
+
All steps allow you to specify these options when you call the `command` or `task` helpers:
|
104
90
|
|
105
|
-
|
91
|
+
1. `quiet` - Direct the step to generate as little output as possible when it executes. It's up to the step to determine what this means for the step and the step may choose to ignore it. If you do not specify a value, a `command` or `task` will pick a default that it prefers. If the `command` or `task` triggers an error while it is running, it will dump the error output to the screen if it was running quietly.
|
92
|
+
1. `stop_on_problem` - Direct rspec_stater to stop everything if a particular step fails. Some steps may only show information, and if they fail, you may not want to stop RSpec from running. If you want to ensure a step failure causes rspec_stater to stop, then set `stop_on_problem: true`. If you do not specify a value, steps will chose their preferred value.
|
106
93
|
|
107
|
-
|
94
|
+
## Commands
|
108
95
|
|
109
|
-
|
110
|
-
module CustomStep
|
111
|
-
def rebuild_command
|
112
|
-
"rake db:drop db:create db:migreate db:do_something_else RAILS_ENV=test"
|
113
|
-
end
|
114
|
-
end
|
96
|
+
Commands are steps that pass a string to the Ruby `system` method. Commands are defined in the following manner
|
115
97
|
|
116
|
-
|
98
|
+
```ruby
|
99
|
+
RspecStarter.start do
|
100
|
+
command "echo 'This will execute, but not display output of the command"
|
101
|
+
command "echo 'This will execute, and display the output of the command", quiet: false
|
102
|
+
end
|
117
103
|
```
|
118
104
|
|
119
|
-
|
105
|
+
rspec_starter tries to keep output concise so command output is hidden by default. If you want to see the output of a command, add the `quiet: false` option.
|
120
106
|
|
121
|
-
|
107
|
+
## Tasks
|
122
108
|
|
123
|
-
####
|
109
|
+
#### Built-in Tasks
|
124
110
|
|
125
|
-
|
111
|
+
rspec_starter provides the following built-in tasks:
|
126
112
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
system("bundle exec rake do_something_else_after_db_is_prepped")
|
132
|
-
end
|
133
|
-
end
|
113
|
+
1. `verify_display_server` - Verify that Linux users have XVFB installed and Mac OS users do not.
|
114
|
+
1. `remove_tmp_folder` - Delete the project's `tmp` folder.
|
115
|
+
1. `rebuild_rails_app_database` - Rebuild the test database for a Ruby on Rails application. By default, the seed files are not loaded. The goal is to have a completely empty database.
|
116
|
+
1. `start_rspec` - Run RSpec.
|
134
117
|
|
135
|
-
|
136
|
-
|
118
|
+
You can find the code for rspec_starter's built-in `tasks` at ../../lib/rspec_starter/tasks.
|
119
|
+
|
120
|
+
#### Custom Tasks
|
137
121
|
|
138
|
-
|
122
|
+
The default tasks provided by rspec_starter are just subclasses of the `RspecStarterTask` class. You can define your own subclasses anywhere and load them. A simply way to get started is to define the classes in the `bin/start_rspec` file, before `RspecStarter.start` is called.
|
139
123
|
|
140
124
|
```ruby
|
141
|
-
|
142
|
-
|
143
|
-
|
125
|
+
class MyTask < RspecStarterTask
|
126
|
+
# [OPTIONAL] This is an optional method. If you define it, you can add command line options to the
|
127
|
+
# root bin/start_rspec starter command and arguments to the task steps inside the
|
128
|
+
# 'RspecStarter.start' block. You can access the values at runtime by calling 'options'.
|
129
|
+
# Be careful not to add a switch that RSpec itself uses. rspec_starter will use it, but it will
|
130
|
+
# not forward it to RSpec.
|
131
|
+
def self.register_options
|
132
|
+
# The following registration lets users call
|
133
|
+
#
|
134
|
+
# bin/start_rspec --skip-my-task
|
135
|
+
#
|
136
|
+
# and inside the start block they can do
|
137
|
+
#
|
138
|
+
# RspecStarter.start do
|
139
|
+
# task :my_task, skip_my_task: true/false
|
140
|
+
# end
|
141
|
+
#
|
142
|
+
# register_option takes the following options
|
143
|
+
#
|
144
|
+
# name - The argument name for the task option'.
|
145
|
+
# default - The default value when the argument is not specified on the 'task' step.
|
146
|
+
# switch - The string the user specifies with the 'bin/start_rspec' command. Switches
|
147
|
+
# always return true or false.
|
148
|
+
# description - The information to show when 'bin/start_rspec --help' is run.
|
149
|
+
#
|
150
|
+
# There are some rules that must be followed when registering the option:
|
151
|
+
#
|
152
|
+
# 1. You must specify either "name:", "switch:" or both.
|
153
|
+
# 2. If you specify both, "switch:" must be similiar to 'name:'. For example, if the name is
|
154
|
+
# "skip_my_task", the switch must be --skip-my-task (-skip-my-task works too). Internally,
|
155
|
+
# the hypens in the switch name are converted to underscores so you can access it as a
|
156
|
+
# method on the options object inside the task.
|
157
|
+
# 3. Switch names must start with "--" or "-".
|
158
|
+
# 4. If "switch:" is specified, "default:" must be set to true or false. If the user does not
|
159
|
+
# use the switch in the commandline, the default value is returned. If the user
|
160
|
+
# specifies the switch, !default is returned.
|
161
|
+
#
|
162
|
+
register_option name: "skip_my_task", default: false, switch: '--skip-my-task',
|
163
|
+
description: "Skip the task"
|
164
|
+
end
|
144
165
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
166
|
+
# [OPTIONAL] This is an optional method. Let subsequent steps run if this task runs into a problem.
|
167
|
+
# This value can be overridden in the applications bin/start_rspec file if the user adds
|
168
|
+
# 'stop_on_problem: true' to the task line.
|
169
|
+
def self.default_stop_on_problem
|
170
|
+
false
|
149
171
|
end
|
150
|
-
end
|
151
172
|
|
152
|
-
|
153
|
-
|
173
|
+
# [OPTIONAL] This is an optional method. Specify if the task likes to run quietly or not. This will
|
174
|
+
# only set the 'quiet' flag on the task. It is up to you to check the quiet flag in the `execute`
|
175
|
+
# method and do something quietly or not.
|
176
|
+
def self.default_quiet
|
177
|
+
false
|
178
|
+
end
|
154
179
|
|
155
|
-
|
180
|
+
# [OPTIONAL] This is an optional method. If you want your task to be skipped under certain conditions,
|
181
|
+
# add the logic here. The task is fully initialized at this point and you have access to the
|
182
|
+
# 'options' object and any arguments that are added to the `task` helper inside the
|
183
|
+
# `RspecStarter.start` block.
|
184
|
+
def should_skip?
|
185
|
+
options.skip_my_task
|
186
|
+
end
|
156
187
|
|
157
|
-
|
188
|
+
# The string that is returned from this method is displayed just before your task starts to run. It
|
189
|
+
# should be brief and describe what the task is doing.
|
190
|
+
def starting_message
|
191
|
+
"Some string"
|
192
|
+
end
|
158
193
|
|
159
|
-
|
194
|
+
# This is the main run method. Do whatever you want your task to do here.
|
195
|
+
def execute
|
196
|
+
# Call the 'problem' method if the command ran into an error.
|
197
|
+
problem if something_went_wrong
|
160
198
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
# do something additional
|
199
|
+
# You can call the 'success' method if successful, but this is optional. rspec_starter will
|
200
|
+
# assume the task was successful if `problem` wasn't called.
|
201
|
+
success
|
165
202
|
end
|
166
|
-
end
|
167
|
-
```
|
168
203
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
Rake::Task["another_task_name"].invoke
|
204
|
+
# [OPTIONAL] This is an optional method. When your task runs in quiet mode, it may not write error
|
205
|
+
# output to the screen if there's a problem. This method is called only when you call the `problem`
|
206
|
+
# method during execution (or if there's a general error raised). You can write any error/debug
|
207
|
+
# information that you find helpful.
|
208
|
+
def write_error_info
|
175
209
|
end
|
176
210
|
end
|
177
211
|
```
|
178
212
|
|
179
|
-
|
180
|
-
|
213
|
+
Once your custom task class is created, add it to the `RspecStarter.start` block:
|
181
214
|
|
182
215
|
```ruby
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
216
|
+
RspecStarter.start do
|
217
|
+
#... tasks or commands above ...
|
218
|
+
task :my_task
|
219
|
+
# ... tasks or commands below ...
|
220
|
+
task :start_rspec
|
189
221
|
end
|
190
222
|
```
|
191
223
|
|
192
|
-
|
193
|
-
|
194
|
-
The entire idea behind start_rspec is to standardize the process of starting RSpec for an 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:
|
224
|
+
When you add the `task` line, convert your class to lowercase and user underscores for word separators. In this example, the `MyTask` class became `:my_task` when it was used inside the start block.
|
195
225
|
|
196
|
-
|
226
|
+
That's it. rspec_starter will find your class, and call the `execute` at the appropriate time.
|
197
227
|
|
198
|
-
|
228
|
+
## Command line options
|
199
229
|
|
200
|
-
|
230
|
+
Run `bin/start_rspec --help` to see a list of command line options. Command line options override settings that are present in the `bin/start_rspec` file, or hard-coded defaults inside the Task/Command code.
|
201
231
|
|
202
232
|
## Contributing
|
203
233
|
|