$ rails g model User
belongs_to
has_one
#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) |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
<!-- app/views/devise/omniauth/link_user.html.erb --> | |
<h2>Link your account</h2> | |
<%= form_for(@user, :url => user_omniauth_link_url, :html => { :method => :put }) do |f| %> | |
<p>You already have an account, that was created with email and password. To link your Facebook account, please enter your password. If you can't remember your password, you can recover it by clicking the link below.</p> | |
<%= render "devise/shared/error_messages" %> | |
<div> |
# Call scopes directly from your URL params: | |
# | |
# @products = Product.filter(params.slice(:status, :location, :starts_with)) | |
module Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Call the class methods with names based on the keys in <tt>filtering_params</tt> | |
# with their associated values. For example, "{ status: 'delayed' }" would call |
# Borrowed from https://github.com/y310/rspec-retry/blob/master/lib/rspec/retry.rb | |
CAPYBARA_TIMEOUT_RETRIES = 3 | |
RSpec.configure do |config| | |
config.around(:each, type: :feature) do |ex| | |
example = RSpec.current_example | |
CAPYBARA_TIMEOUT_RETRIES.times do |i| | |
example.instance_variable_set('@exception', nil) | |
self.instance_variable_set('@__memoized', nil) # clear let variables |
It took me a long time to warm up to pull requests. My early experiences with code review were all a tremendous waste of time: they were a bottleneck to getting things done, a forum for people to conduct their ongoing feuds or both. After years of being staunchly against pull requests, I've come around on them in the last year at Terrible Labs.
Start with cthe big picture and get more detailed from there.
My pull request should be trying to accomplish only one thing and that should be explained in enough detail in the commit message for you to understand, did I succeed? If something is confusing: you're not sure how this system works, or how this new piece of code fits in with other parts of the system, let me know and we can clarify it together.
DO NOT COPY AND PASTE! You must type it all out yourself for this to be valuable. To make sure of that, the "quotation marks" in the code will copy and paste oddly so copy and pasting will not work :) Practice, practice, practice
Let’s create a person in javascript. We could use a variable...
var person = "John Doe";
To print our person’s name we could do...