geordi 5.2.3 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/exe/launchy_browser DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This script is a part of Geordi. It is used by the cucumber command to have
4
- # launchy open error pages from tests in the users browser, as apposed to
5
- # opening it within VNC.
6
-
7
- # For unknown reasons, #require cannot find 'geordi/cucumber', so we need to
8
- # require it this way. Hours have been spent trying to require 'geordi/cucumber'.
9
- require File.expand_path('../../lib/geordi/cucumber', __FILE__)
10
- Geordi::Cucumber.new.restore_env
11
-
12
- require 'rubygems'
13
- require 'launchy'
14
-
15
- Launchy.open(ARGV.first)
@@ -1,64 +0,0 @@
1
- desc '-setup-vnc', 'Setup VNC for running Selenium tests there', hide: true
2
- def _setup_vnc
3
- `clear`
4
-
5
- Interaction.note 'This script will help you install a VNC server and a VNC viewer.'
6
- puts
7
- puts Util.strip_heredoc <<-TEXT
8
- With those you will be able to use our cucumber script without being
9
- disturbed by focus-stealing Selenium windows. Instead, they will open
10
- inside a VNC session.
11
-
12
- You can still inspect everything with:
13
- TEXT
14
- Interaction.note_cmd 'geordi vnc'
15
- puts
16
- Interaction.note 'Please open a second shell to execute instructions.'
17
- Interaction.prompt 'Continue ...'
18
-
19
- Interaction.announce 'Setup VNC server'
20
-
21
- vnc_server_installed = system('which vncserver > /dev/null 2>&1')
22
- if vnc_server_installed
23
- Interaction.success 'It appears you already have a VNC server installed. Good job!'
24
- else
25
- puts 'Please run:'
26
- Interaction.note_cmd 'sudo apt-get install tightvncserver'
27
- puts 'In case this package is not available, you may try vnc4server instead.'
28
- Interaction.prompt 'Continue ...'
29
-
30
- puts
31
-
32
- Interaction.note 'We will now set a password for your VNC server.'
33
- puts Util.strip_heredoc <<-TEXT
34
- When running our cucumber script, this password will be used while also
35
- restricting access to the local machine. However, if you start a vncserver
36
- without our cucumber script, keep in mind that a user with this password
37
- can connect to your machine.
38
-
39
- TEXT
40
- puts 'Please run:'
41
- Interaction.note_cmd 'vncpasswd'
42
- Interaction.warn 'Enter a secure password!'
43
- Interaction.prompt 'Continue ...'
44
- end
45
-
46
- Interaction.announce 'Setup VNC viewer'
47
-
48
- vnc_viewer_installed = system('which vncviewer > /dev/null 2>&1')
49
- if vnc_viewer_installed
50
- Interaction.success 'It appears you already have a VNC viewer installed. Good job!'
51
- else
52
- puts 'Please run:'
53
- Interaction.note_cmd 'sudo apt-get install xtightvncviewer'
54
- Interaction.prompt 'Continue ...'
55
- end
56
-
57
- puts
58
- puts Util.strip_heredoc <<-TEXT
59
- All done. Our cucumber script will now automatically run Selenium features
60
- in VNC.
61
- TEXT
62
-
63
- Interaction.success 'Happy cuking!'
64
- end
@@ -1,32 +0,0 @@
1
- desc 'firefox COMMAND', 'Run a command with VNC and test browser set up (alias: chrome)'
2
- long_desc <<-LONGDESC
3
- Example: `geordi firefox b cucumber` or `geordi firefox --setup 24.0`
4
-
5
- Useful when you need Firefox for Selenium or the VNC set up, but can't use the
6
- `geordi cucumber` command. This command is aliased `chrome` for users running
7
- Selenium in Chrome.
8
- LONGDESC
9
-
10
- option :setup, banner: 'FIREFOX_VERSION',
11
- desc: 'Install a special test runner Firefox with the given version'
12
-
13
- def firefox(*command)
14
- if options.setup
15
- Interaction.fail 'Firefox version required (e.g. --setup 24.0)' if options.setup == 'setup'
16
-
17
- require 'geordi/firefox_for_selenium'
18
- Geordi::FirefoxForSelenium.install(options.setup)
19
-
20
- else
21
- require 'geordi/cucumber'
22
-
23
- Cucumber.new.setup_vnc
24
- FirefoxForSelenium.setup_firefox
25
-
26
- puts
27
- Interaction.note_cmd command.join(' ')
28
- system *command # Util.run! would reset the Firefox PATH
29
- end
30
- end
31
-
32
- map 'chrome' => 'firefox'
@@ -1,18 +0,0 @@
1
- desc 'vnc', 'Show the hidden VNC window'
2
- long_desc <<-LONGDESC
3
- Example: `geordi vnc` or `geordi vnc --setup`
4
-
5
- Launch a VNC session to the hidden screen where `geordi cucumber` runs Selenium
6
- tests.
7
- LONGDESC
8
-
9
- option :setup, type: :boolean, desc: 'Guide through the setup of VNC'
10
-
11
- def vnc
12
- if options.setup
13
- invoke_geordi :_setup_vnc
14
- else
15
- require 'geordi/cucumber'
16
- Geordi::Cucumber.new.launch_vnc_viewer
17
- end
18
- end
@@ -1,200 +0,0 @@
1
- require 'pathname'
2
- require 'tempfile'
3
- require File.expand_path('interaction', __dir__)
4
-
5
- module Geordi
6
- module FirefoxForSelenium
7
-
8
- FIREFOX_FOR_SELENIUM_BASE_PATH = Pathname.new('~/bin/firefoxes').expand_path
9
- FIREFOX_FOR_SELENIUM_PROFILE_NAME = 'firefox-for-selenium'.freeze
10
- FIREFOX_VERSION_FILE = Pathname.new('.firefox-version')
11
-
12
- def self.install(version)
13
- Installer.new(version).run
14
- end
15
-
16
- def self.path_from_config
17
- version = FIREFOX_VERSION_FILE.exist? && File.read(FIREFOX_VERSION_FILE).strip
18
-
19
- if version && (version != 'system')
20
- unless FirefoxForSelenium.binary(version).exist?
21
- Interaction.warn "Firefox #{version} not found"
22
-
23
- Interaction.note Util.strip_heredoc(<<-INSTRUCTIONS)
24
- Install it with
25
- geordi firefox --setup #{version}
26
- INSTRUCTIONS
27
-
28
- Interaction.prompt('Run tests anyway?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
29
- end
30
-
31
- path(version)
32
- end
33
- end
34
-
35
- def self.path(version)
36
- FIREFOX_FOR_SELENIUM_BASE_PATH.join(version)
37
- end
38
-
39
- def self.binary(version, name = 'firefox')
40
- path(version).join(name)
41
- end
42
-
43
- def self.setup_firefox
44
- path = path_from_config
45
-
46
- if path
47
- ENV['PATH'] = "#{path}:#{ENV['PATH']}"
48
- Interaction.note 'Firefox for Selenium set up'
49
- end
50
- end
51
-
52
-
53
- class Installer
54
-
55
- def initialize(version)
56
- @version = version
57
- end
58
-
59
- def run
60
- say_hello
61
- check_if_run_before
62
- download_firefox
63
- create_separate_profile # do this before the patching because the patched binary calls firefox with a profile that does not yet exist
64
- patch_old_firefox
65
- configure_old_firefox
66
- kkthxbb
67
- end
68
-
69
-
70
- private
71
-
72
- def execute_command(cmd)
73
- system(cmd) || raise("Error while executing command: #{cmd}")
74
- end
75
-
76
- def run_firefox_for_selenium(args = '')
77
- execute_command("PATH=#{path}:$PATH firefox #{args}")
78
- end
79
-
80
- def path
81
- FirefoxForSelenium.path(@version)
82
- end
83
-
84
- def download_url
85
- "https://ftp.mozilla.org/pub/firefox/releases/#{@version}/"
86
- end
87
-
88
- def binary
89
- FirefoxForSelenium.binary(@version)
90
- end
91
-
92
- def original_binary
93
- FirefoxForSelenium.binary(@version, 'firefox-original')
94
- end
95
-
96
- def say_hello
97
- execute_command('clear')
98
-
99
- puts Util.strip_heredoc(<<-HELLO)
100
- Whenever Firefox updates, Selenium breaks. This is annoying. This
101
- script will help you create an unchanging version of Firefox for your
102
- Selenium tests.
103
-
104
- In particular, this new copy of Firefox will have the following
105
- properties:
106
-
107
- - It won't update itself with a newer version
108
- - It can co-exist with your regular Firefox installation (which you can
109
- update at will)
110
- - It will use a profile separate from the one you use for regular
111
- Firefox browsing
112
- - It will not try to re-use existing Firefox windows
113
- - It will automatically be used for your Selenium scenarios if you run
114
- your Cucumber using the cuc binary from the geordi gem.
115
- - It will live in #{path}
116
- HELLO
117
-
118
- Interaction.prompt "Press ENTER when you're ready to begin."
119
- end
120
-
121
- def check_if_run_before
122
- if original_binary.exist?
123
- Interaction.note 'This version seems to be already installed.'
124
- Interaction.prompt 'Press ENTER to continue anyway or press CTRL+C to abort.'
125
- end
126
- end
127
-
128
- def download_firefox
129
- path.mkpath
130
-
131
- puts Util.strip_heredoc(<<-INSTRUCTION)
132
- Please download an old version of Firefox from: #{download_url}
133
- Unpack it with: tar xjf firefox-#{@version}.tar.bz2 -C #{path} --strip-components=1
134
- Now #{path.join('firefox')} should be the firefox binary, not a directory.
135
- INSTRUCTION
136
- Interaction.prompt 'Continue?'
137
-
138
- File.file?(binary) || raise("Could not find #{binary}")
139
- end
140
-
141
- def create_separate_profile
142
- Interaction.note "Creating a separate profile named '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}' so your own profile will be safe..."
143
- # don't use the patched firefox binary for this, we don't want to give
144
- # a -p option here
145
- execute_command("PATH=#{path}:$PATH firefox -no-remote -CreateProfile #{FIREFOX_FOR_SELENIUM_PROFILE_NAME}")
146
- puts
147
- end
148
-
149
- def patch_old_firefox
150
- Interaction.note "Patching #{binary} so it uses the new profile and never re-uses windows from other Firefoxes..."
151
- execute_command("mv #{binary} #{original_binary}")
152
- execute_command("mv #{binary}-bin #{original_binary}-bin")
153
- patched_binary = Tempfile.new('firefox')
154
- patched_binary.write Util.strip_heredoc(<<-PATCH)
155
- #!/usr/bin/env ruby
156
- exec('#{original_binary}', '-no-remote', '-P', '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}', *ARGV)
157
- PATCH
158
- patched_binary.close
159
- execute_command("mv #{patched_binary.path} #{binary}")
160
- execute_command("chmod +x #{binary}")
161
- puts
162
- end
163
-
164
- def configure_old_firefox
165
- puts Util.strip_heredoc(<<-INSTRUCTION)
166
- You will now have to do some manual configuration.
167
-
168
- This script will open the patched copy of Firefox when you press ENTER.
169
- Please perform the following steps manually:
170
-
171
- - IMPORTANT: Quickly disable all automatic updates under Edit /
172
- Preferences / Advanced / Update
173
- - Disable the default browser check when Firefox launches
174
- - Check that the version number is correct (#{@version})
175
- - You should not see your bookmarks, add-ons, plugins from your regular
176
- Firefox profile
177
- INSTRUCTION
178
-
179
- Interaction.prompt 'Will open the patched copy of Firefox now'
180
- run_firefox_for_selenium
181
- end
182
-
183
- def kkthxbb
184
- Interaction.success "Congratulations, you're done!"
185
-
186
- puts
187
- puts Util.strip_heredoc(<<-INSTRUCTION)
188
- Your patched copy of Firefox will be used when you run Cucumber using
189
- the cucumber script that comes with the geordi gem. If you cannot use
190
- `geordi cucumber`, but still need the test browser set up, you can use:
191
-
192
- geordi firefox <any command>
193
-
194
- Enjoy!
195
- INSTRUCTION
196
- end
197
-
198
- end
199
- end
200
- end