Class: RspecStarter::LegacyRunner
- Inherits:
-
Object
- Object
- RspecStarter::LegacyRunner
show all
- Includes:
- Help
- Defined in:
- lib/rspec_starter/legacy/legacy_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
Instance Method Summary
collapse
Methods included from Help
#calling_file_name, #should_show_help?, #show_help
Constructor Details
Returns a new instance of LegacyRunner.
Instance Attribute Details
#step_num ⇒ Object
Returns the value of attribute step_num.
19
20
21
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 19
def step_num
@step_num
end
|
#steps ⇒ Object
Returns the value of attribute steps.
19
20
21
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 19
def steps
@steps
end
|
#xvfb_installed ⇒ Object
Returns the value of attribute xvfb_installed.
19
20
21
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 19
def xvfb_installed
@xvfb_installed
end
|
Instance Method Details
#finalize_exit ⇒ Object
84
85
86
87
88
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 84
def finalize_exit
exit(1) if @run_rspec_step.rspec_exit_status.nonzero?
exit(1) if @prep_db_step.exit_status.nonzero?
exit(0)
end
|
#is_linux? ⇒ Boolean
72
73
74
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 72
def is_linux?
operating_system_name == 'Linux'
end
|
#is_mac? ⇒ Boolean
76
77
78
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 76
def is_mac?
operating_system_name == 'MacOS'
end
|
#operating_system_name ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 64
def operating_system_name
result = `uname`
return 'Linux' if result.include?('Linux')
return 'MacOS' if result.include?('Darwin')
'Unknown'
end
|
#project_has_lib_dir? ⇒ Boolean
60
61
62
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 60
def project_has_lib_dir?
Dir.exist?("#{Dir.pwd}/lib")
end
|
#project_is_rails_app? ⇒ Boolean
47
48
49
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 47
def project_is_rails_app?
File.file?(File.join(Dir.pwd, 'config', 'application.rb'))
end
|
#project_is_rails_engine? ⇒ Boolean
51
52
53
54
55
56
57
58
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 51
def project_is_rails_engine?
return false unless project_has_lib_dir?
Dir["#{Dir.pwd}/lib/**/*.rb"].each do |file|
return true if File.readlines(file).detect { |line| line.match(/\s*class\s+.*<\s+::Rails::Engine/) }
end
false
end
|
#run ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 33
def run
return show_help if should_show_help?
@steps.each do |step|
next unless step.should_execute?
step.execute
@step_num += 1
break if step.failed?
end
finalize_exit
end
|
#xvfb_installed? ⇒ Boolean
80
81
82
|
# File 'lib/rspec_starter/legacy/legacy_runner.rb', line 80
def xvfb_installed?
@xvfb_installed
end
|