Skip to content

Instantly share code, notes, and snippets.

Avatar

Nikolaj Andersen andersennl

View GitHub Profile
@andersennl
andersennl / blog.md
Created May 1, 2018 — forked from JacobBennett/blog.md
Clean up your Vue modules with ES6 Arrow Functions
View blog.md

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
View gist:c7e49b82bc1fbe7810ab
MyExceptions = [RangeError, RegexpError, IOError].freeze
begin
raise IOError, "should be rescued"
rescue *MyExceptions => e
puts e
end
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@andersennl
andersennl / Brewupdateissues
Last active Aug 29, 2015
Brew update issues
View Brewupdateissues
➜ folder brew update
error: Your local changes to the following files would be overwritten by merge:
Library/Formula/readline.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
➜ folder brew --config
HOMEBREW_VERSION: 0.9.5