geordi 3.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +36 -2
- data/Gemfile.lock +1 -1
- data/README.md +46 -3
- data/lib/geordi/COMMAND_TEMPLATE +2 -3
- data/lib/geordi/chromedriver_updater.rb +7 -8
- data/lib/geordi/cli.rb +0 -1
- data/lib/geordi/commands/_setup_vnc.rb +22 -22
- data/lib/geordi/commands/bundle_install.rb +1 -1
- data/lib/geordi/commands/capistrano.rb +4 -4
- data/lib/geordi/commands/clean.rb +6 -5
- data/lib/geordi/commands/commit.rb +1 -1
- data/lib/geordi/commands/console.rb +11 -3
- data/lib/geordi/commands/create_database_yml.rb +2 -2
- data/lib/geordi/commands/create_databases.rb +1 -1
- data/lib/geordi/commands/cucumber.rb +16 -9
- data/lib/geordi/commands/delete_dumps.rb +5 -5
- data/lib/geordi/commands/deploy.rb +19 -19
- data/lib/geordi/commands/drop_databases.rb +3 -3
- data/lib/geordi/commands/dump.rb +8 -9
- data/lib/geordi/commands/firefox.rb +2 -2
- data/lib/geordi/commands/migrate.rb +3 -3
- data/lib/geordi/commands/png_optimize.rb +5 -5
- data/lib/geordi/commands/rake.rb +1 -1
- data/lib/geordi/commands/remove_executable_flags.rb +2 -2
- data/lib/geordi/commands/rspec.rb +5 -5
- data/lib/geordi/commands/security_update.rb +76 -19
- data/lib/geordi/commands/server.rb +2 -2
- data/lib/geordi/commands/setup.rb +3 -3
- data/lib/geordi/commands/shell.rb +7 -3
- data/lib/geordi/commands/tests.rb +1 -1
- data/lib/geordi/commands/unit.rb +2 -2
- data/lib/geordi/commands/update.rb +2 -2
- data/lib/geordi/commands/with_rake.rb +2 -2
- data/lib/geordi/commands/yarn_install.rb +1 -1
- data/lib/geordi/cucumber.rb +18 -17
- data/lib/geordi/db_cleaner.rb +21 -22
- data/lib/geordi/dump_loader.rb +5 -4
- data/lib/geordi/firefox_for_selenium.rb +17 -19
- data/lib/geordi/gitpt.rb +10 -53
- data/lib/geordi/interaction.rb +2 -6
- data/lib/geordi/remote.rb +17 -6
- data/lib/geordi/settings.rb +155 -0
- data/lib/geordi/util.rb +14 -9
- data/lib/geordi/version.rb +1 -1
- metadata +4 -3
@@ -10,9 +10,9 @@ def server(port = nil)
|
|
10
10
|
invoke_cmd 'yarn_install'
|
11
11
|
require 'geordi/util'
|
12
12
|
|
13
|
-
announce 'Booting a development server'
|
13
|
+
Interaction.announce 'Booting a development server'
|
14
14
|
port ||= options.port
|
15
|
-
note "URL: http://#{File.basename(Dir.pwd)}.vcap.me:#{port}"
|
15
|
+
Interaction.note "URL: http://#{File.basename(Dir.pwd)}.vcap.me:#{port}"
|
16
16
|
puts
|
17
17
|
|
18
18
|
command = Util.server_command
|
@@ -25,8 +25,8 @@ option :test, type: :boolean, aliases: '-t', desc: 'After setup, run tests'
|
|
25
25
|
|
26
26
|
def setup
|
27
27
|
if File.exist? 'bin/setup'
|
28
|
-
announce 'Running bin/setup'
|
29
|
-
note "Geordi's own setup routine is skipped"
|
28
|
+
Interaction.announce 'Running bin/setup'
|
29
|
+
Interaction.note "Geordi's own setup routine is skipped"
|
30
30
|
|
31
31
|
Util.system! 'bin/setup'
|
32
32
|
else
|
@@ -34,7 +34,7 @@ def setup
|
|
34
34
|
invoke_cmd 'migrate'
|
35
35
|
end
|
36
36
|
|
37
|
-
success 'Successfully set up the project.'
|
37
|
+
Interaction.success 'Successfully set up the project.'
|
38
38
|
|
39
39
|
invoke_cmd 'dump', options.dump, load: true if options.dump
|
40
40
|
invoke_cmd 'tests' if options.test
|
@@ -2,18 +2,22 @@ desc 'shell TARGET', 'Open a shell on a Capistrano deploy target'
|
|
2
2
|
long_desc <<-LONGDESC
|
3
3
|
Example: `geordi shell production`
|
4
4
|
|
5
|
-
Lets you select the server to connect to when called with `--select-server`:
|
5
|
+
Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
|
6
6
|
|
7
7
|
geordi shell production -s
|
8
|
+
|
9
|
+
If you already know the number of the server you want to connect to, just pass it along:
|
10
|
+
|
11
|
+
geordi shell production -s2
|
8
12
|
LONGDESC
|
9
13
|
|
10
|
-
option :select_server,
|
14
|
+
option :select_server, type: :string, aliases: '-s'
|
11
15
|
|
12
16
|
# This method has a triple 'l' because :shell is a Thor reserved word. However,
|
13
17
|
# it can still be called with `geordi shell` :)
|
14
18
|
def shelll(target, *_args)
|
15
19
|
require 'geordi/remote'
|
16
20
|
|
17
|
-
announce 'Opening a shell on ' + target
|
21
|
+
Interaction.announce 'Opening a shell on ' + target
|
18
22
|
Geordi::Remote.new(target).shell(options)
|
19
23
|
end
|
data/lib/geordi/commands/unit.rb
CHANGED
@@ -4,9 +4,9 @@ def unit
|
|
4
4
|
invoke_cmd 'bundle_install'
|
5
5
|
invoke_cmd 'yarn_install'
|
6
6
|
|
7
|
-
announce 'Running Test::Unit'
|
7
|
+
Interaction.announce 'Running Test::Unit'
|
8
8
|
Util.system! 'bundle exec rake test'
|
9
9
|
else
|
10
|
-
note 'Test::Unit not employed.'
|
10
|
+
Interaction.note 'Test::Unit not employed.'
|
11
11
|
end
|
12
12
|
end
|
@@ -21,12 +21,12 @@ option :dump, type: :string, aliases: '-d', banner: 'TARGET',
|
|
21
21
|
option :test, type: :boolean, aliases: '-t', desc: 'After updating, run tests'
|
22
22
|
|
23
23
|
def update
|
24
|
-
announce 'Updating repository'
|
24
|
+
Interaction.announce 'Updating repository'
|
25
25
|
Util.system! 'git pull', show_cmd: true
|
26
26
|
|
27
27
|
invoke_cmd 'migrate'
|
28
28
|
|
29
|
-
success 'Successfully updated the project.'
|
29
|
+
Interaction.success 'Successfully updated the project.'
|
30
30
|
|
31
31
|
invoke_cmd 'dump', options.dump, load: true if options.dump
|
32
32
|
invoke_cmd 'tests' if options.test
|
@@ -4,10 +4,10 @@ def with_rake
|
|
4
4
|
invoke_cmd 'bundle_install'
|
5
5
|
invoke_cmd 'yarn_install'
|
6
6
|
|
7
|
-
announce 'Running tests with `rake`'
|
7
|
+
Interaction.announce 'Running tests with `rake`'
|
8
8
|
Util.system! 'rake'
|
9
9
|
else
|
10
|
-
note '`rake` does not run tests.'
|
10
|
+
Interaction.note '`rake` does not run tests.'
|
11
11
|
:did_not_perform
|
12
12
|
end
|
13
13
|
end
|
@@ -2,7 +2,7 @@ desc 'yarn-install', 'Runs yarn install if required', hide: true
|
|
2
2
|
|
3
3
|
def yarn_install
|
4
4
|
if File.exist?('package.json') && !system('yarn check --integrity > /dev/null 2>&1')
|
5
|
-
announce 'Yarn install'
|
5
|
+
Interaction.announce 'Yarn install'
|
6
6
|
Util.system! 'yarn install'
|
7
7
|
end
|
8
8
|
end
|
data/lib/geordi/cucumber.rb
CHANGED
@@ -5,10 +5,10 @@ require 'tempfile'
|
|
5
5
|
# version of Geordi.
|
6
6
|
require File.expand_path('interaction', __dir__)
|
7
7
|
require File.expand_path('firefox_for_selenium', __dir__)
|
8
|
+
require File.expand_path('settings', __dir__)
|
8
9
|
|
9
10
|
module Geordi
|
10
11
|
class Cucumber
|
11
|
-
include Geordi::Interaction
|
12
12
|
|
13
13
|
VNC_DISPLAY = ':17'.freeze
|
14
14
|
VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024".freeze
|
@@ -17,13 +17,14 @@ module Geordi
|
|
17
17
|
|
18
18
|
def run(files, cucumber_options, options = {})
|
19
19
|
self.argv = files + cucumber_options.map { |option| option.split('=') }.flatten
|
20
|
+
self.settings = Geordi::Settings.new
|
20
21
|
|
21
22
|
consolidate_rerun_txt_files
|
22
23
|
show_features_to_run
|
23
|
-
setup_vnc
|
24
|
+
setup_vnc if settings.use_vnc?
|
24
25
|
|
25
26
|
command = use_parallel_tests?(options) ? parallel_execution_command : serial_execution_command
|
26
|
-
note_cmd(command) if options[:verbose]
|
27
|
+
Interaction.note_cmd(command) if options[:verbose]
|
27
28
|
|
28
29
|
puts # Make newline
|
29
30
|
system command # Util.system! would reset the Firefox PATH
|
@@ -34,11 +35,11 @@ module Geordi
|
|
34
35
|
error = capture_stderr do
|
35
36
|
system(VNC_VIEWER_COMMAND)
|
36
37
|
end
|
37
|
-
unless
|
38
|
-
if
|
39
|
-
|
38
|
+
unless $?.success?
|
39
|
+
if $?.exitstatus == 127
|
40
|
+
Interaction.fail 'VNC viewer not found. Install it with `geordi vnc --setup`.'
|
40
41
|
else
|
41
|
-
note 'VNC viewer could not be opened:'
|
42
|
+
Interaction.note 'VNC viewer could not be opened:'
|
42
43
|
puts error
|
43
44
|
puts
|
44
45
|
end
|
@@ -60,13 +61,13 @@ module Geordi
|
|
60
61
|
ENV['BROWSER'] = ENV['LAUNCHY_BROWSER'] = File.expand_path('../../bin/launchy_browser', __dir__)
|
61
62
|
ENV['DISPLAY'] = VNC_DISPLAY
|
62
63
|
|
63
|
-
note 'Run `geordi vnc` to view the Selenium test browsers'
|
64
|
+
Interaction.note 'Run `geordi vnc` to view the Selenium test browsers'
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
private
|
68
69
|
|
69
|
-
attr_accessor :argv
|
70
|
+
attr_accessor :argv, :settings
|
70
71
|
|
71
72
|
def serial_execution_command
|
72
73
|
format_args = []
|
@@ -77,7 +78,7 @@ module Geordi
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def parallel_execution_command
|
80
|
-
note 'Using parallel_tests'
|
81
|
+
Interaction.note 'Using parallel_tests'
|
81
82
|
self.argv = argv - command_line_features
|
82
83
|
|
83
84
|
type_arg = Util.gem_version('parallel_tests') > Gem::Version.new('0.7.0') ? 'cucumber' : 'features'
|
@@ -115,15 +116,15 @@ module Geordi
|
|
115
116
|
|
116
117
|
def show_features_to_run
|
117
118
|
if command_line_options.include? '@solo'
|
118
|
-
note 'All features tagged with @solo'
|
119
|
+
Interaction.note 'All features tagged with @solo'
|
119
120
|
elsif command_line_options.include? 'rerun'
|
120
|
-
note 'Rerunning failed scenarios'
|
121
|
+
Interaction.note 'Rerunning failed scenarios'
|
121
122
|
elsif features_to_run.empty?
|
122
|
-
note 'All features in features/'
|
123
|
+
Interaction.note 'All features in features/'
|
123
124
|
else
|
124
125
|
notification = 'Only: ' + features_to_run.join(', ')
|
125
126
|
notification << ' (from rerun.txt)' if (features_to_run == rerun_txt_features) && (features_to_run != command_line_features)
|
126
|
-
note notification
|
127
|
+
Interaction.note notification
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
@@ -173,7 +174,7 @@ module Geordi
|
|
173
174
|
def consolidate_rerun_txt_files
|
174
175
|
parallel_rerun_files = Dir.glob('parallel_rerun*.txt')
|
175
176
|
unless parallel_rerun_files.empty?
|
176
|
-
note 'Consolidating parallel_rerun.txt files ...'
|
177
|
+
Interaction.note 'Consolidating parallel_rerun.txt files ...'
|
177
178
|
|
178
179
|
rerun_content = []
|
179
180
|
parallel_rerun_files.each do |filename|
|
@@ -218,10 +219,10 @@ module Geordi
|
|
218
219
|
98 # was already running after all
|
219
220
|
true
|
220
221
|
when 127 # not installed
|
221
|
-
warn 'Could not launch VNC server. Install it with `geordi vnc --setup`.'
|
222
|
+
Interaction.warn 'Could not launch VNC server. Install it with `geordi vnc --setup`.'
|
222
223
|
false
|
223
224
|
else
|
224
|
-
warn 'Starting VNC failed:'
|
225
|
+
Interaction.warn 'Starting VNC failed:'
|
225
226
|
puts error
|
226
227
|
puts
|
227
228
|
false
|
data/lib/geordi/db_cleaner.rb
CHANGED
@@ -4,14 +4,13 @@ require 'tempfile'
|
|
4
4
|
|
5
5
|
module Geordi
|
6
6
|
class DBCleaner
|
7
|
-
include Geordi::Interaction
|
8
7
|
|
9
8
|
def initialize(extra_flags)
|
10
9
|
puts 'Please enter your sudo password if asked, for db operations as system users'
|
11
10
|
puts "We're going to run `sudo -u postgres psql` for PostgreSQL"
|
12
11
|
puts ' and `sudo mysql` for MariaDB (which uses PAM auth)'
|
13
12
|
`sudo true`
|
14
|
-
|
13
|
+
Interaction.fail 'sudo access is required for database operations as database users' if $? != 0
|
15
14
|
@derivative_dbname = /_(test\d*|development|cucumber)$/
|
16
15
|
base_directory = ENV['XDG_CONFIG_HOME']
|
17
16
|
base_directory = Dir.home.to_s if base_directory.nil?
|
@@ -66,7 +65,7 @@ HEREDOC
|
|
66
65
|
tmpfile_content.push(['keep', db_name]) unless db_name.empty?
|
67
66
|
end
|
68
67
|
if warn_manual_whitelist
|
69
|
-
warn <<-ERROR_MSG.gsub(/^\s*/, '')
|
68
|
+
Interaction.warn <<-ERROR_MSG.gsub(/^\s*/, '')
|
70
69
|
Your whitelist #{whitelist} seems to have been generated manually.
|
71
70
|
In that case, make sure to use only one database name per line and omit the 'keep' prefix."
|
72
71
|
|
@@ -88,10 +87,10 @@ HEREDOC
|
|
88
87
|
lines.each do |line|
|
89
88
|
next if line.start_with?('#')
|
90
89
|
unless line.split.length == 2
|
91
|
-
|
90
|
+
Interaction.fail "Invalid edit to whitelist file: \`#{line}\` - Syntax is: ^[keep|drop] dbname$"
|
92
91
|
end
|
93
92
|
unless %w[keep drop k d].include? line.split.first
|
94
|
-
|
93
|
+
Interaction.fail "Invalid edit to whitelist file: \`#{line}\` - must start with either drop or keep."
|
95
94
|
end
|
96
95
|
db_status, db_name = line.split
|
97
96
|
if db_status == 'keep'
|
@@ -108,7 +107,7 @@ HEREDOC
|
|
108
107
|
unless extra_flags.nil?
|
109
108
|
if extra_flags.include? 'port'
|
110
109
|
port = Integer(extra_flags.split('=')[1].split[0])
|
111
|
-
|
110
|
+
Interaction.fail "Port #{port} is not open" unless Geordi::Util.is_port_open? port
|
112
111
|
end
|
113
112
|
cmd << " #{extra_flags}"
|
114
113
|
end
|
@@ -121,15 +120,15 @@ HEREDOC
|
|
121
120
|
cmd << " #{extra_flags}" unless extra_flags.nil?
|
122
121
|
unless File.exist? File.join(Dir.home, '.my.cnf')
|
123
122
|
puts "Please enter your MySQL/MariaDB password for account 'root'."
|
124
|
-
warn "You should create a ~/.my.cnf file instead, or you'll need to enter your MySQL root password for each db."
|
125
|
-
warn 'See https://makandracards.com/makandra/50813-store-mysql-passwords-for-development for more information.'
|
123
|
+
Interaction.warn "You should create a ~/.my.cnf file instead, or you'll need to enter your MySQL root password for each db."
|
124
|
+
Interaction.warn 'See https://makandracards.com/makandra/50813-store-mysql-passwords-for-development for more information.'
|
126
125
|
cmd << ' -p' # need to ask for password now
|
127
126
|
end
|
128
127
|
Open3.popen3("#{cmd} -e 'QUIT'") do |_stdin_2, _stdout_2, _stderr_2, thread_2|
|
129
|
-
|
128
|
+
Interaction.fail 'Could not connect to MySQL/MariaDB' unless thread_2.value.exitstatus == 0
|
130
129
|
end
|
131
130
|
elsif mysql_error == '2013' # connection to port or socket failed
|
132
|
-
|
131
|
+
Interaction.fail 'MySQL/MariaDB connection failed, is this the correct port?'
|
133
132
|
end
|
134
133
|
end
|
135
134
|
cmd
|
@@ -141,10 +140,10 @@ HEREDOC
|
|
141
140
|
unless extra_flags.nil?
|
142
141
|
begin
|
143
142
|
port = Integer(extra_flags.split('=')[1])
|
144
|
-
|
143
|
+
Interaction.fail "Port #{port} is not open" unless Geordi::Util.is_port_open? port
|
145
144
|
rescue ArgumentError
|
146
145
|
socket = extra_flags.split('=')[1]
|
147
|
-
|
146
|
+
Interaction.fail "Socket #{socket} does not exist" unless File.exist? socket
|
148
147
|
end
|
149
148
|
cmd << " #{extra_flags}"
|
150
149
|
end
|
@@ -172,7 +171,7 @@ HEREDOC
|
|
172
171
|
end
|
173
172
|
|
174
173
|
def clean_mysql
|
175
|
-
announce 'Checking for MySQL databases'
|
174
|
+
Interaction.announce 'Checking for MySQL databases'
|
176
175
|
database_list = list_all_dbs('mysql')
|
177
176
|
# confirm_deletion includes option for whitelist editing
|
178
177
|
deletable_dbs = confirm_deletion('mysql', database_list)
|
@@ -181,19 +180,19 @@ HEREDOC
|
|
181
180
|
if @mysql_command.include? '-p'
|
182
181
|
puts "Please enter your MySQL/MariaDB account 'root' for: DROP DATABASE #{db}"
|
183
182
|
else
|
184
|
-
note "Dropping MySQL/MariaDB database #{db}"
|
183
|
+
Interaction.note "Dropping MySQL/MariaDB database #{db}"
|
185
184
|
end
|
186
185
|
`#{@mysql_command} -e 'DROP DATABASE \`#{db}\`;'`
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
190
189
|
def clean_postgres
|
191
|
-
announce 'Checking for Postgres databases'
|
190
|
+
Interaction.announce 'Checking for Postgres databases'
|
192
191
|
database_list = list_all_dbs('postgres')
|
193
192
|
deletable_dbs = confirm_deletion('postgres', database_list)
|
194
193
|
return if deletable_dbs.nil?
|
195
194
|
deletable_dbs.each do |db|
|
196
|
-
note "Dropping PostgreSQL database `#{db}`."
|
195
|
+
Interaction.note "Dropping PostgreSQL database `#{db}`."
|
197
196
|
`#{@postgres_command} -c 'DROP DATABASE "#{db}";'`
|
198
197
|
end
|
199
198
|
end
|
@@ -207,27 +206,27 @@ HEREDOC
|
|
207
206
|
until %w[y n].include? proceed
|
208
207
|
deletable_dbs = filter_whitelisted(dbtype, database_list)
|
209
208
|
if deletable_dbs.empty?
|
210
|
-
note "No #{dbtype} databases found that were not whitelisted"
|
211
|
-
if prompt('Edit the whitelist? [y]es or [n]o') == 'y'
|
209
|
+
Interaction.note "No #{dbtype} databases found that were not whitelisted"
|
210
|
+
if Interaction.prompt('Edit the whitelist? [y]es or [n]o') == 'y'
|
212
211
|
proceed = 'e'
|
213
212
|
else
|
214
213
|
return []
|
215
214
|
end
|
216
215
|
end
|
217
216
|
if proceed.empty?
|
218
|
-
note "The following #{dbtype} databases are not whitelisted and could be deleted:"
|
217
|
+
Interaction.note "The following #{dbtype} databases are not whitelisted and could be deleted:"
|
219
218
|
deletable_dbs.sort.each do |db|
|
220
219
|
puts db
|
221
220
|
end
|
222
|
-
note "Those #{dbtype} databases are not whitelisted and could be deleted."
|
223
|
-
proceed = prompt('Proceed? [y]es, [n]o or [e]dit whitelist')
|
221
|
+
Interaction.note "Those #{dbtype} databases are not whitelisted and could be deleted."
|
222
|
+
proceed = Interaction.prompt('Proceed? [y]es, [n]o or [e]dit whitelist')
|
224
223
|
end
|
225
224
|
case proceed
|
226
225
|
when 'e'
|
227
226
|
proceed = '' # reset user selection
|
228
227
|
edit_whitelist dbtype
|
229
228
|
when 'n'
|
230
|
-
success 'Not deleting anything'
|
229
|
+
Interaction.success 'Not deleting anything'
|
231
230
|
return []
|
232
231
|
when 'y'
|
233
232
|
return deletable_dbs
|
data/lib/geordi/dump_loader.rb
CHANGED
@@ -5,7 +5,6 @@ require 'geordi/util'
|
|
5
5
|
|
6
6
|
module Geordi
|
7
7
|
class DumpLoader
|
8
|
-
include Geordi::Interaction
|
9
8
|
|
10
9
|
def initialize(file)
|
11
10
|
@dump_file = file
|
@@ -14,7 +13,9 @@ module Geordi
|
|
14
13
|
def development_database_config
|
15
14
|
require 'yaml'
|
16
15
|
|
17
|
-
|
16
|
+
evaluated_config_file = ERB.new(File.read('config/database.yml')).result
|
17
|
+
# Allow aliases and a special set of classes like symbols and time objects
|
18
|
+
@config ||= YAML.safe_load(evaluated_config_file, [Symbol, Time], [], true)
|
18
19
|
@config['development']
|
19
20
|
end
|
20
21
|
alias_method :config, :development_database_config
|
@@ -47,13 +48,13 @@ module Geordi
|
|
47
48
|
available_dumps = Dir.glob(dumps_glob).sort
|
48
49
|
|
49
50
|
HighLine.new.choose(*available_dumps) do |menu|
|
50
|
-
menu.hidden('') {
|
51
|
+
menu.hidden('') { Interaction.fail 'Abort.' }
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
56
|
def load
|
56
|
-
note 'Source file: ' + dump_file
|
57
|
+
Interaction.note 'Source file: ' + dump_file
|
57
58
|
|
58
59
|
source_command = send("#{config['adapter']}_command")
|
59
60
|
Util.system! source_command, fail_message: "An error occured loading #{File.basename(dump_file)}"
|
@@ -4,7 +4,6 @@ require File.expand_path('interaction', __dir__)
|
|
4
4
|
|
5
5
|
module Geordi
|
6
6
|
module FirefoxForSelenium
|
7
|
-
extend Geordi::Interaction
|
8
7
|
|
9
8
|
FIREFOX_FOR_SELENIUM_BASE_PATH = Pathname.new('~/bin/firefoxes').expand_path
|
10
9
|
FIREFOX_FOR_SELENIUM_PROFILE_NAME = 'firefox-for-selenium'.freeze
|
@@ -19,14 +18,14 @@ module Geordi
|
|
19
18
|
|
20
19
|
if version && (version != 'system')
|
21
20
|
unless FirefoxForSelenium.binary(version).exist?
|
22
|
-
warn "Firefox #{version} not found"
|
21
|
+
Interaction.warn "Firefox #{version} not found"
|
23
22
|
|
24
|
-
note strip_heredoc(<<-INSTRUCTIONS)
|
23
|
+
Interaction.note Util.strip_heredoc(<<-INSTRUCTIONS)
|
25
24
|
Install it with
|
26
25
|
geordi firefox --setup #{version}
|
27
26
|
INSTRUCTIONS
|
28
27
|
|
29
|
-
prompt('Run tests anyway?', 'n', /y|yes/) ||
|
28
|
+
Interaction.prompt('Run tests anyway?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
|
30
29
|
end
|
31
30
|
|
32
31
|
path(version)
|
@@ -46,13 +45,12 @@ module Geordi
|
|
46
45
|
|
47
46
|
if path
|
48
47
|
ENV['PATH'] = "#{path}:#{ENV['PATH']}"
|
49
|
-
note 'Firefox for Selenium set up'
|
48
|
+
Interaction.note 'Firefox for Selenium set up'
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
|
54
53
|
class Installer
|
55
|
-
include Geordi::Interaction
|
56
54
|
|
57
55
|
def initialize(version)
|
58
56
|
@version = version
|
@@ -98,7 +96,7 @@ module Geordi
|
|
98
96
|
def say_hello
|
99
97
|
execute_command('clear')
|
100
98
|
|
101
|
-
puts strip_heredoc(<<-HELLO)
|
99
|
+
puts Util.strip_heredoc(<<-HELLO)
|
102
100
|
Whenever Firefox updates, Selenium breaks. This is annoying. This
|
103
101
|
script will help you create an unchanging version of Firefox for your
|
104
102
|
Selenium tests.
|
@@ -117,31 +115,31 @@ module Geordi
|
|
117
115
|
- It will live in #{path}
|
118
116
|
HELLO
|
119
117
|
|
120
|
-
prompt "Press ENTER when you're ready to begin."
|
118
|
+
Interaction.prompt "Press ENTER when you're ready to begin."
|
121
119
|
end
|
122
120
|
|
123
121
|
def check_if_run_before
|
124
122
|
if original_binary.exist?
|
125
|
-
note 'This version seems to be already installed.'
|
126
|
-
prompt 'Press ENTER to continue anyway or press CTRL+C to abort.'
|
123
|
+
Interaction.note 'This version seems to be already installed.'
|
124
|
+
Interaction.prompt 'Press ENTER to continue anyway or press CTRL+C to abort.'
|
127
125
|
end
|
128
126
|
end
|
129
127
|
|
130
128
|
def download_firefox
|
131
129
|
path.mkpath
|
132
130
|
|
133
|
-
puts strip_heredoc(<<-INSTRUCTION)
|
131
|
+
puts Util.strip_heredoc(<<-INSTRUCTION)
|
134
132
|
Please download an old version of Firefox from: #{download_url}
|
135
133
|
Unpack it with: tar xjf firefox-#{@version}.tar.bz2 -C #{path} --strip-components=1
|
136
134
|
Now #{path.join('firefox')} should be the firefox binary, not a directory.
|
137
135
|
INSTRUCTION
|
138
|
-
prompt 'Continue?'
|
136
|
+
Interaction.prompt 'Continue?'
|
139
137
|
|
140
138
|
File.file?(binary) || raise("Could not find #{binary}")
|
141
139
|
end
|
142
140
|
|
143
141
|
def create_separate_profile
|
144
|
-
note "Creating a separate profile named '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}' so your own profile will be safe..."
|
142
|
+
Interaction.note "Creating a separate profile named '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}' so your own profile will be safe..."
|
145
143
|
# don't use the patched firefox binary for this, we don't want to give
|
146
144
|
# a -p option here
|
147
145
|
execute_command("PATH=#{path}:$PATH firefox -no-remote -CreateProfile #{FIREFOX_FOR_SELENIUM_PROFILE_NAME}")
|
@@ -149,11 +147,11 @@ module Geordi
|
|
149
147
|
end
|
150
148
|
|
151
149
|
def patch_old_firefox
|
152
|
-
note "Patching #{binary} so it uses the new profile and never re-uses windows from other Firefoxes..."
|
150
|
+
Interaction.note "Patching #{binary} so it uses the new profile and never re-uses windows from other Firefoxes..."
|
153
151
|
execute_command("mv #{binary} #{original_binary}")
|
154
152
|
execute_command("mv #{binary}-bin #{original_binary}-bin")
|
155
153
|
patched_binary = Tempfile.new('firefox')
|
156
|
-
patched_binary.write strip_heredoc(<<-PATCH)
|
154
|
+
patched_binary.write Util.strip_heredoc(<<-PATCH)
|
157
155
|
#!/usr/bin/env ruby
|
158
156
|
exec('#{original_binary}', '-no-remote', '-P', '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}', *ARGV)
|
159
157
|
PATCH
|
@@ -164,7 +162,7 @@ module Geordi
|
|
164
162
|
end
|
165
163
|
|
166
164
|
def configure_old_firefox
|
167
|
-
puts strip_heredoc(<<-INSTRUCTION)
|
165
|
+
puts Util.strip_heredoc(<<-INSTRUCTION)
|
168
166
|
You will now have to do some manual configuration.
|
169
167
|
|
170
168
|
This script will open the patched copy of Firefox when you press ENTER.
|
@@ -178,15 +176,15 @@ module Geordi
|
|
178
176
|
Firefox profile
|
179
177
|
INSTRUCTION
|
180
178
|
|
181
|
-
prompt 'Will open the patched copy of Firefox now'
|
179
|
+
Interaction.prompt 'Will open the patched copy of Firefox now'
|
182
180
|
run_firefox_for_selenium
|
183
181
|
end
|
184
182
|
|
185
183
|
def kkthxbb
|
186
|
-
success "Congratulations, you're done!"
|
184
|
+
Interaction.success "Congratulations, you're done!"
|
187
185
|
|
188
186
|
puts
|
189
|
-
puts strip_heredoc(<<-INSTRUCTION)
|
187
|
+
puts Util.strip_heredoc(<<-INSTRUCTION)
|
190
188
|
Your patched copy of Firefox will be used when you run Cucumber using
|
191
189
|
the cucumber script that comes with the geordi gem. If you cannot use
|
192
190
|
`geordi cucumber`, but still need the test browser set up, you can use:
|