Skip to content

Instantly share code, notes, and snippets.

@nruth
nruth / redirector.js
Last active April 29, 2016 15:46
ember.js acceptance test window.location redirector abstraction service
import Ember from 'ember';
export default Ember.Service.extend({
redirectTo(href) {
window.location.href = href;
},
replace(href) {
window.location.replace(href);
},
reload() {
@nruth
nruth / selenium.rb
Last active March 22, 2023 13:10
translating old capybara selenium/chrome preferences and switches to new
# load into test setup after `require 'capybara/rails'`
# some sources for below flags and profile settings
# https://stackoverflow.com/questions/43143014/chrome-is-being-controlled-by-automated-test-software/43145088
# https://sqa.stackexchange.com/questions/26051/chrome-driver-2-28-chrome-is-being-controlled-by-automated-test-software-notif
# http://stackoverflow.com/questions/12211781/how-to-maximize-window-in-chrome-using-webdriver-python
# update sources for new Options object
# https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver.rb
begin
import Ember from 'ember';
import config from 'medify-bmat-grader/config/environment';
export function prefixRootUrl([href]) {
if (config.environment !== 'production') {
return `${config.rootURL}${href}`;
} else {
return href;
}
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@nruth
nruth / find_warn.rb
Last active July 17, 2019 09:39
Finding where deprecation warnings are coming from (Capybara, Rails, etc, anything that calls Kernel#warn)
TracePoint.trace(:c_call) do |tp|
# the various methods on tp tell you where warn is defined, but we want to know about the call stack,
# in particular the test code that the test library didn't like and decided to warn us about,
# so let's Array#grep the caller strings, filtering out the rspec library lines
if tp.method_id == :warn
app_lines = caller(0).grep(%r{enough-of-your-app-code-path-to-match/})
app_lines_without_reporter = app_lines.grep_v(/name-of-your-rspec-support-file-holding-this-code/)
p app_lines_without_reporter.join("\n")
p
end
@nruth
nruth / unpod.rb
Last active September 3, 2019 18:12
Ember Shucker - unpodding old projects (stupid simple grep/mv ruby fileutils script)
# pods aren't really a thing going forward, and come up as a problem during paid code reivews
# there is/was an alternative in the works to do with modules, but it's best to be on the old
# default ember-cli directory structure so that any new codemods can work
require 'fileutils'
app_pods = "app/pods"
puts "Shucking Routes"
routes = Dir.glob(File.join(app_pods, "**", "route.js"))