Skip to content

Instantly share code, notes, and snippets.

View al3rez's full-sized avatar

Alireza Bashiri al3rez

View GitHub Profile
### Keybase proof
I hereby claim:
* I am azbshiri on github.
* I am azbshiri (https://keybase.io/azbshiri) on keybase.
* I have a public key whose fingerprint is 5576 2694 3AF1 4E42 5673 F3CD 3D40 840A 6E62 F2DE
To claim this, I am signing this object:
{
"type": "object",
"required": ["user"],
"properties": {
"user" : {
"type" : "object",
"required" : [
"id",
"token",
"token_expired_at",
describe "Sign in" do
context "anonymous user" do
it "returns data in the specified format" do
sign_in_as_anonymous
expect(response).to match_response_schema("users/anonymous_detail")
end
end
end
@al3rez
al3rez / main.cr
Created December 13, 2017 19:00
Building a RESTful API with Crystal
require "http/server"
class Users::Me
include HTTP::Handler
def call(context)
return call_next(context) unless match?(context.request)
STDOUT.puts "getting user info..."
STDOUT.puts "done!"
@al3rez
al3rez / main.go
Last active March 27, 2018 03:30
Go already has RSpec!
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMain(m *testing.M) {
// before spec
err := m.Run()
require "byebug"
class CharFieldKlass
def initialize(*args)
end
def valid?
end
end
RSpec::Matchers.define :have_many do |expected|
match do |actual|
if actual.respond_to?(:reflect_on_association)
actual.reflect_on_association(expected)&.macro == :has_many
else
actual.class.reflect_on_association(expected)&.macro == :has_many
end
end
end
require "rails_helper"
RSpec.describe User, type: :model do
it { should have_many(:books) }
it "has many books" do
expect(User).to have_many(:books)
end
end
require "rails_helper"
RSpec.describe User, type: :model do
it { should have_many(:books) }
it "has many books" do
expect(User).to have_many(:books)
end
end
@al3rez
al3rez / .vimrc
Created November 27, 2018 10:43
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
filetype indent on
set backspace=indent,eol,start
set number
set nobackup
set noswapfile
autocmd!