Class: RspecStarter::Runner
- Inherits:
-
Object
- Object
- RspecStarter::Runner
- Includes:
- Help
- Defined in:
- lib/rspec_starter/runner.rb
Overview
This is a simple class that encapulates the process of running RSpec. When a Runner is created, it creates a set of steps that will be executed, in order, when the ‘run’ method is invoked. Each step encapsulates an action that can be taken to help invoke Rspec. Steps are typically independent do not depend on information from other steps. However this is not a hard rule. If more complex steps are needed, feel free to create them. Each steps knows about the main runner object, so the runner object is a good place to store shared info.
Instance Attribute Summary collapse
-
#step_num ⇒ Object
readonly
Returns the value of attribute step_num.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
-
#xvfb_installed ⇒ Object
readonly
Returns the value of attribute xvfb_installed.
Instance Method Summary collapse
- #app_uses_rails? ⇒ Boolean
-
#initialize(defaults) ⇒ Runner
constructor
A new instance of Runner.
- #is_linux? ⇒ Boolean
- #is_mac? ⇒ Boolean
- #operating_system_name ⇒ Object
- #run ⇒ Object
- #xvfb_installed? ⇒ Boolean
Methods included from Help
#calling_file_name, #should_show_help?, #show_help
Constructor Details
#initialize(defaults) ⇒ Runner
Returns a new instance of Runner.
22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec_starter/runner.rb', line 22 def initialize(defaults) @steps = [] @step_num = 1 @xvfb_installed = RspecStarter.which("xvfb-run") @steps << VerifyXvfbStep.new(defaults, self) @steps << PrepareDatabaseStep.new(defaults, self) @steps << RemoveTmpFolderStep.new(defaults, self) @steps << InvokeRspecStep.new(defaults, self) end |
Instance Attribute Details
#step_num ⇒ Object (readonly)
Returns the value of attribute step_num.
20 21 22 |
# File 'lib/rspec_starter/runner.rb', line 20 def step_num @step_num end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
20 21 22 |
# File 'lib/rspec_starter/runner.rb', line 20 def steps @steps end |
#xvfb_installed ⇒ Object (readonly)
Returns the value of attribute xvfb_installed.
20 21 22 |
# File 'lib/rspec_starter/runner.rb', line 20 def xvfb_installed @xvfb_installed end |
Instance Method Details
#app_uses_rails? ⇒ Boolean
44 45 46 |
# File 'lib/rspec_starter/runner.rb', line 44 def app_uses_rails? File.file?(File.join(Dir.pwd, 'config', 'application.rb')) end |
#is_linux? ⇒ Boolean
55 56 57 |
# File 'lib/rspec_starter/runner.rb', line 55 def is_linux? == 'Linux' end |
#is_mac? ⇒ Boolean
59 60 61 |
# File 'lib/rspec_starter/runner.rb', line 59 def is_mac? == 'MacOS' end |
#operating_system_name ⇒ Object
48 49 50 51 52 53 |
# File 'lib/rspec_starter/runner.rb', line 48 def result = `uname` return 'Linux' if result.include?('Linux') return 'MacOS' if result.include?('Darwin') 'Unknown' end |
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rspec_starter/runner.rb', line 32 def run return show_help if should_show_help? # If we show help, exit and don't do anything else. @steps.each do |step| if step.should_execute? step.execute @step_num += 1 break if step.failed? end end end |
#xvfb_installed? ⇒ Boolean
63 64 65 |
# File 'lib/rspec_starter/runner.rb', line 63 def xvfb_installed? @xvfb_installed end |