Skip to content

Instantly share code, notes, and snippets.

View boddhisattva's full-sized avatar
🌷
Vasudhaiva Kutumbakam 🙂

Mohnish G J boddhisattva

🌷
Vasudhaiva Kutumbakam 🙂
View GitHub Profile
@boddhisattva
boddhisattva / setup_system_tests_with_rspec_devise_rails6.md
Last active November 9, 2023 20:58
Setup System tests to work with RSpec, Devise and Rails 6

Setting this up took quite a bit of time and research for me, so just thought of sharing the learnings along the way that led to a working setup.

  • Initial error that I was getting with running System tests in Rails 6

    System test integration requires Rails >= 5.1 and has a hard dependency on a webserver and `capybara`, please add capybara to your Gemfile and configure a webserver (e.g. `Capybara.server = :webrick`) before attempting to use system tests.
    • since the error above says specify Capybara in the Gemfile, a part of my Gemfile looked like below:
@boddhisattva
boddhisattva / getting_started.md
Last active April 28, 2023 23:16
Writing a spec from scratch for a plain ruby script(no rails) using TDD

Steps -

  • Create the filename.rb file for which you’d like to create a filename_spec.rb
  • Run the command rspec --init from the same working directory as to where you have filename.rb
  • the above command will create a .rspec file for you
  • It will create a new spec directory within which you need to place your specs
  • It will create spec_helper.rb where you need continually require the ruby files that you would want to write specs for
  • Create the filename_spec.rb within the spec directory
  • [optional] Edit the .rspec file to add the option: --format documentation
  • The above addition gives your running tests more readability as to what they do or what they stand for when they are run.
@boddhisattva
boddhisattva / sublime_text3_shortcuts.md
Last active February 9, 2020 05:46
Sublime Text 3(ST3) shortcuts for Mac OSX that I use as part of my daily workflow
SE No Command Action
1 cmd + option + down arrow Go to Definition(a new feature in ST3)
2 cmd + ctrl + g Select all occurrences of a word within a file at once
3 cmd + d Selects the next occurence of the same word
4 Hold cmd key and click on multiple lines to get multiple cursors Allows for editing multiple things at a time
5 cmd + ctrl + p Open a project(once saved via Project(Prj) -> Save Prj as)
6 cmd + ] Indents the highlighted code towards the right
7 cmd + [ Indents the highlighted code towards the left
8 cmd + r Search for a method
@boddhisattva
boddhisattva / Guardfile
Created March 6, 2019 11:38
Guardfile code for running the exercise related tests in Exercism's Ruby Track
guard :minitest, test_folders: '.' do
watch(%r{^(.*/)?([^/]+)\.rb$}) do |match_data|
test_file = if match_data[2].include? "test"
match_data[2].split('_').first
else
match_data[2]
end
"./#{test_file}_test.rb"
@boddhisattva
boddhisattva / spec.rb
Last active December 27, 2018 07:48
Red-Green-Refactor by Example related exercise as part of the Fundamentals of TDD course in Upcase (https://thoughtbot.com/upcase/videos/red-green-refactor-by-example)
require 'rspec/autorun'
class Person
def initialize(first_name: , middle_name: nil, last_name: )
@first_name = first_name
@middle_name = middle_name
@last_name = last_name
end
@boddhisattva
boddhisattva / rna_transcription_v3.ex
Created October 24, 2018 10:34
RNA Transcript exercise v3
defmodule DNA do
@nucleotides %{?A => ?U, ?C => ?G, ?G => ?C, ?T => ?A }
@doc """
Transcribes a character list representing DNA nucleotides to RNA
## Examples
iex> DNA.to_rna('ACTG')
'UGAC'
defmodule RNATranscription do
@guanine ?G
@adenine ?A
@cystosine ?C
@uracil ?U
@thymine ?T
@doc """
Transcribes a character list representing DNA nucleotides to RNA
@boddhisattva
boddhisattva / rna_transcription.ex
Last active October 24, 2018 10:18
RNA Transcription Exercise - Elixir
defmodule RNATranscription do
@guanine "G"
@adenine "A"
@cystosine "C"
@uracil "U"
@thymine "T"
@doc """
Transcribes a character list representing DNA nucleotides to RNA
@boddhisattva
boddhisattva / elixir-syntax-highlighting-support-example.md
Last active September 29, 2018 09:54
How to highlight elixir code in your markdown files - an example

Elixir syntax highlighting example

 list = [1, 2, 3]
 [a, b, c] =  list
 
 def foo do
   IO.puts "foo"
 end
@boddhisattva
boddhisattva / supervisors_in_iex.md
Last active May 12, 2018 23:39
Trying out supervisors with Elixir:)