Get node's parent element with Capybara
To get parent of Capybara's node do the following:
node = page.find '#selector'
parent = node.find(:xpath, '..')
parent_of_parent = node.find(:xpath, '../..')
Related cards:
Rspec + Capybara + Rails4 + Spork (intergation tests setup with selenium and poltergeist)
Add in Gemfile:
group :development, :test do
gem 'rspec-rails'
gem 'spork-rails'
end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'email_spec'
gem 'poltergeist'
gem 'launchy'
gem 'selenium-webdriver'
end
Run ...
Setting up Javascript environment with NVM on Ubuntu 14.04
NVM provides you more convenient way to manage and set up your Javascript(Node.js) environment.
First install NVM, note git
must be installed on your sistem:
^
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git check...
ubuntu nginx with txid module
To install nginx with txid module
install nginx-full package:
sudo apt-get install nginx-full
download last nginx source:
wget http://nginx.org/download/nginx-1.9.9.tar.gz
examine what ...
Setting up RubyOnRails environment on Ubuntu 14.04
This tutorial is about setting up environment for RubyOnRails on Ubuntu 14.04.
First of all, update & upgrade your system:
sudo apt-get update
^
sudo apt-get upgrade
^
Install git
and curl
:
sudo apt-get install curl
^
sudo...
SSH config for simplify connection to many similar hosts
Suppose you have three hosts (host.one.domain.name, host.two.domain.name host.three.domain.name) with the same credentials, with access by ssh key, then any time when you need to connect to host you must type something like this:
ssh user@hos...
Capistrano deploy.rb examples
All examples here for deploy RoR application with unicorn, staging machine (where we deploys) available via ssh by ssh_key.
-
Deploy via remote_cache:
require 'rvm/capistrano' require 'bundler/capistrano' set :applicat...
How to create Nokogiri node if node name collide with Nokogiri::XML::Builder methods
Suppose you want to create node with name text
, but this method already present in Nokogiri::XML::Builder. The solution is to add underscore after node name:
Nokogiri::XML::Builder.new do |xml|
xml.text_ 'something' # this should create n...
Generating SSH Keys
If you don't have ssh key, open terminal and run following commands:
cd ~/.ssh
^
ssh-keygen -t rsa -C "your_email@example.com"
When you have ssh key, just copy public part to clipboard:
xclip -sel clip < ~/.ssh/id_rsa.pub
To...
Rails migration add float point field with scale and precision
class CreateFakes < ActiveRecord::Migration
def change
create_table :fakes do |t|
t.decimal :float_value, :precision => 4, :scale => 3
end
end
end
This will allow you to have 3 digits after the decimal point and 4 digits ...