Mike Mazur's blog
Events
- House of Genius Singapore is having their first session on Wednesday, December 7 at Amazon's offices. Check out their About page for more details on the nature of the event.
- Come see The Stand-up Economist at TAB tonight at 8pm.
Helps
"We have some DOM that looks like this:
<div><span /><a /></div>. We can style theawhich follows aspanwith the CSS rulespan + a, but it appears there's no rule to style thespanif it's followed by ana."
- This is more of a sad face than a help.
Interestings
As part of jQuery's slimming down effort, in the 1.7 release non-standard event properties are no longer copied from the native event object to the jQuery event object. Certain plugins may not be aware of this change yet.
Along the lines of jQuery 1.7,
.live()is also being deprecated. Please use.on()and.off()in its place.
Helps
"We are using
page.driver.browser.switch_to.alert.acceptin our cucumber steps in order to accept a JavaScript alert box. This appears to have an effect on the browser's behavior afterward, causing future scenarios to fail when they pass on their own. We're seeing timing issues, specifically around when the blur event is called when an input field loses focus. We didn't manage to find the root cause. Any ideas?"
- Sounds intense! No answers, though.
Interestings
It's not possible to stub a delegated method; stub it on the object delegated to instead.
In order to get an accurate number of days since the epoch, do this:
(Time.now.to_f / 60 / 60 / 24).round. The key here is theto_finstead ofto_ito prevent losing precision early on.
Interestings
We included a JavaScript file and set its src attribute to a file's RAW URL on github. After about 400 requests within an hour, github started returning 403.
Public Service Announcement:
local_assignsis a hash of local variables in a view. Useful when passing those variables on when rendering a partial; instead of enumerating the variables:render :partial 'foo', locals: { bar: bar, baz: baz}, pass the hash of locals:render :partial 'foo', locals: local_assigns
Helps
"Adding a JS alert box (with
remote:true, confirm: 'Are you sure?'on alink_to) causes the cucumber feature to fail. It looks like, after we accept the alert withpage.page.driver.browser.switch_to.alert.accept, the browser runs much slower than the cucumber feature, so while everything technically works, the feature fails. We worked around this by delaying cucumber withpage.should have_no_content('content inside removed li')but it feels like a hack. Does anyone know what could be wrong with our setup, or is this to be expected?"
- There were no comments other than the work-around we're already using.
"The pattern we use when testing ajax calls in Jasmine feels unsatisfactory because
expect($.ajax).toHaveBeenCalledWith({ /* all params here */});requires all the parameters passed to the ajax call to be specified in the expectation. This includes parameters we don't care about, such asbeforeSend(which is passed by Rails'remote: true). There must be a better way?"
- One suggestion was to use something like RSpec's
hash_including, or building it if it doesn't exist. Turns out, there's a pull request from earlier this year with just this improvement.
Interestings
To get the html of an element (ie: a 'ul') including itself, append the element to a new element (ie: an empty div), then get the html of the new element. For example:
$('<div>').append($('ul')).html(). The element's parent could also be used if the element is an only child.When appending an element which already exists in the DOM to another element, it will be moved from its present location in the DOM. This can be problematic when using the trick above to generate an element's html, and is fixed by cloning the element.
If you see 'Timezone Displacement out of range' when doing a
heroku db:push, it's probably because you're using Ruby 1.9.3 in development while Heroku runs 1.9.2. Don't do that.
Events
- GOV Camp at Suntec City TODAY, November 18, 2-10pm
