Class: RspecStarter::Environment
- Inherits:
-
Object
- Object
- RspecStarter::Environment
- Defined in:
- lib/rspec_starter/environment.rb
Overview
Load the environment for RspecStarter.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #command(string, **args) ⇒ Object
-
#initialize(args, &start_block) ⇒ Environment
constructor
&start_block is the start block from the host application’s bin/start_rspec file.
- #step_contexts ⇒ Object
- #task(task_name, **args) ⇒ Object
- #unique_task_classes ⇒ Object
Constructor Details
#initialize(args, &start_block) ⇒ Environment
&start_block is the start block from the host application’s bin/start_rspec file. It looks like this:
RspecStarter.start do
command "something"
task :task_one
command "something"
task :task two
... more commands and tasks...
end
15 16 17 18 19 20 21 22 23 |
# File 'lib/rspec_starter/environment.rb', line 15 def initialize(args, &start_block) @next_id = 0 @step_info = {} load_step_info(&start_block) @options = Options.new(self, args, &start_block) # This will lazily load once execution starts. end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/rspec_starter/environment.rb', line 4 def @options end |
Instance Method Details
#command(string, **args) ⇒ Object
33 34 35 36 |
# File 'lib/rspec_starter/environment.rb', line 33 def command(string, **args) step_id = next_id @step_info[step_id] = CommandContext.new(environment: self, id: step_id, command_string: string, requested_args: args) end |
#step_contexts ⇒ Object
25 26 27 |
# File 'lib/rspec_starter/environment.rb', line 25 def step_contexts @step_info.values end |
#task(task_name, **args) ⇒ Object
38 39 40 41 42 |
# File 'lib/rspec_starter/environment.rb', line 38 def task(task_name, **args) step_id = next_id klass = RspecStarter.helpers.class_for_task_name(task_name) @step_info[step_id] = TaskContext.new(environment: self, id: step_id, step_class: klass, requested_args: args) end |
#unique_task_classes ⇒ Object
29 30 31 |
# File 'lib/rspec_starter/environment.rb', line 29 def unique_task_classes @step_info.values.select(&:is_task?).collect(&:step_class).uniq end |