Skip to content

Instantly share code, notes, and snippets.

View PareshGupta's full-sized avatar

Parry Gupta PareshGupta

  • Vinsol | Stadium
  • New Delhi
View GitHub Profile
@PareshGupta
PareshGupta / Capybara.md
Created May 22, 2018 07:21 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@PareshGupta
PareshGupta / mysql.database.yml
Created January 21, 2018 18:39 — forked from jwo/mysql.database.yml
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
@PareshGupta
PareshGupta / install_chrome_driver
Created September 28, 2017 20:21 — forked from thotmx/install_chrome_driver
Install chromedriver in Ubuntu (14.04)
$ sudo apt-get install chromium-chromedriver
$ sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
@PareshGupta
PareshGupta / attribute_spec_helper.rb
Created September 18, 2017 13:19
Rspec matcher for attr_accessor, attr_reader and attr_writer
# `have_attr_reader` matcher for attr_reader
RSpec::Matchers.define :have_attr_reader do |field|
match do |object_instance|
object_instance.respond_to?(field)
end
failure_message do |object_instance|
"expected attr_reader for #{ field } on #{ object_instance }"
end
@PareshGupta
PareshGupta / mac_terminal.sh
Created July 6, 2017 05:54
This script is for removing the system and user name from mac terminal. This script is to be appended into .bash_profile
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="$GREEN\u@$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
@PareshGupta
PareshGupta / spec_helper.rb
Created April 1, 2016 07:49 — forked from pauljamesrussell/spec_helper.rb
RSpec matcher for ensuring a model is accepting nested attributes for an association, and accepting/rejecting the right values.
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
model.send("#{association}").clear