Skip to content

Instantly share code, notes, and snippets.

View azabaj's full-sized avatar

Ferenc Fekete azabaj

View GitHub Profile
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
@azabaj
azabaj / rspec_model_testing_template.rb
Created October 29, 2016 21:39 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# 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:
# comments/_form.html.erb
<div class="new_comment">
<%= form_for(@comment, :url => project_message_comments_path(@project,@message)) do |f| %>
<%= error_messages @comment %>
<p><%= f.label :content, 'Szólj hozzá!' %>
<%= f.text_area :content, :class => 'text maxwidth' %></p>
<div class="submit_wrapper">
<%= f.submit 'Elküldöm a hozzászólást' %>
</div>
<% end %>
["Test", "Foo", "Bar"].grep 'Foo' => ["Foo"]
["Test", "Foo", "Bar"].grep /ba/i => ["Bar"]
>> [nil, 1, "test", 2.5].grep Numeric => [1, 2.5]
>> [1,5,9,7].grep 5..7 => [5, 7]
def some_method
returning [] do |some_var|
some_var << 'foo'
some_var << 'bar'
end
end