geordi 5.2.2 → 6.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/geordi/util.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'geordi/interaction'
2
2
  require 'socket'
3
+ require 'bundler'
3
4
 
4
5
  module Geordi
5
6
  class Util
@@ -167,15 +168,10 @@ module Geordi
167
168
  # Get the version for the given gem by parsing Gemfile.lock.
168
169
  # Returns nil if the gem is not used.
169
170
  def gem_version(gem)
170
- # Lines look like `* will_paginate (2.3.15)` or `railslts-version (2.3.18.16 7f51cc7)`
171
- bundle_list.split("\n").each do |line|
172
- matches = line.match(/\* #{gem} \(([\d\.]+)/)
173
- next if matches.nil? || matches[1].nil?
171
+ lock_file = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile))
172
+ spec = lock_file.specs.detect { |spec| spec.name == gem }
174
173
 
175
- return Gem::Version.new(matches[1])
176
- end
177
-
178
- nil
174
+ spec && spec.version
179
175
  end
180
176
 
181
177
  def file_containing?(file, regex)
@@ -192,12 +188,6 @@ module Geordi
192
188
  string
193
189
  end
194
190
 
195
- private
196
-
197
- def bundle_list
198
- @bundle_list ||= `bundle list`
199
- end
200
-
201
191
  end
202
192
  end
203
193
  end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '5.2.2'.freeze
2
+ VERSION = '6.0.0-rc1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.2
4
+ version: 6.0.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-17 00:00:00.000000000 Z
11
+ date: 2021-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -32,12 +32,12 @@ executables:
32
32
  - b
33
33
  - dumple
34
34
  - geordi
35
- - launchy_browser
36
35
  extensions: []
37
36
  extra_rdoc_files: []
38
37
  files:
39
38
  - ".github/workflows/test.yml"
40
39
  - ".gitignore"
40
+ - ".rspec"
41
41
  - ".ruby-version"
42
42
  - CHANGELOG.md
43
43
  - Gemfile
@@ -48,15 +48,14 @@ files:
48
48
  - exe/b
49
49
  - exe/dumple
50
50
  - exe/geordi
51
- - exe/launchy_browser
52
51
  - geordi.gemspec
53
52
  - lib/geordi.rb
54
53
  - lib/geordi/COMMAND_TEMPLATE
55
54
  - lib/geordi/capistrano_config.rb
56
55
  - lib/geordi/chromedriver_updater.rb
57
56
  - lib/geordi/cli.rb
58
- - lib/geordi/commands/_setup_vnc.rb
59
57
  - lib/geordi/commands/apache_site.rb
58
+ - lib/geordi/commands/branch.rb
60
59
  - lib/geordi/commands/bundle_install.rb
61
60
  - lib/geordi/commands/capistrano.rb
62
61
  - lib/geordi/commands/chromedriver_update.rb
@@ -71,7 +70,6 @@ files:
71
70
  - lib/geordi/commands/docker.rb
72
71
  - lib/geordi/commands/drop_databases.rb
73
72
  - lib/geordi/commands/dump.rb
74
- - lib/geordi/commands/firefox.rb
75
73
  - lib/geordi/commands/migrate.rb
76
74
  - lib/geordi/commands/png_optimize.rb
77
75
  - lib/geordi/commands/rake.rb
@@ -85,14 +83,12 @@ files:
85
83
  - lib/geordi/commands/unit.rb
86
84
  - lib/geordi/commands/update.rb
87
85
  - lib/geordi/commands/version.rb
88
- - lib/geordi/commands/vnc.rb
89
86
  - lib/geordi/commands/with_rake.rb
90
87
  - lib/geordi/commands/yarn_install.rb
91
88
  - lib/geordi/cucumber.rb
92
89
  - lib/geordi/db_cleaner.rb
93
90
  - lib/geordi/docker.rb
94
91
  - lib/geordi/dump_loader.rb
95
- - lib/geordi/firefox_for_selenium.rb
96
92
  - lib/geordi/gitpt.rb
97
93
  - lib/geordi/interaction.rb
98
94
  - lib/geordi/remote.rb
@@ -103,7 +99,8 @@ homepage: https://makandra.com
103
99
  licenses:
104
100
  - MIT
105
101
  metadata: {}
106
- post_install_message:
102
+ post_install_message: " Support for sequential running of integration tests tagged
103
+ with @solo has been dropped.\n"
107
104
  rdoc_options: []
108
105
  require_paths:
109
106
  - lib
@@ -114,11 +111,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
111
  version: 2.2.0
115
112
  required_rubygems_version: !ruby/object:Gem::Requirement
116
113
  requirements:
117
- - - ">="
114
+ - - ">"
118
115
  - !ruby/object:Gem::Version
119
- version: '0'
116
+ version: 1.3.1
120
117
  requirements: []
121
- rubygems_version: 3.0.8
118
+ rubygems_version: 3.0.3
122
119
  signing_key:
123
120
  specification_version: 4
124
121
  summary: Collection of command line tools we use in our daily work with Ruby, Rails
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