This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run "echo TODO > README" | |
if yes?("Do you want to use RSpec(yes/no)") | |
plugin "rspec", :git => "git://github.com/dchelimsky/rspec.git" | |
plugin "rspec-rails", :git => "git://github.com/dchelimsky/rspec-rails.git" | |
generate :rspec | |
elsif yes?("Do you want to use shoulda and factory girl(yes/no)") | |
gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com" | |
gem "factory_girl", :source => "http://gemcutter.org" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Created By Bagwan Pankaj (RailsJaipur) “http://bagwanpankaj.com/” | |
#This file is an extension of default webrat steps. some of the webrat steps have been extended | |
#in this file so that one need not to write unrequired steps. | |
#Extends default | |
#USE: When I follow // | |
When /^I follow \/([^\/]*)\/$/ do |regexp_link| | |
click_link(regexp_link) | |
end | |
#USE: When I follow // within "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Testt | |
define_method :foo do | |
"welcome" | |
end | |
end | |
Testt.new().foo | |
=> "welcome" | |
module Hello | |
define_method :foo do |name| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
enable_starttls_auto: true | |
address: "smtp.gmail.com" | |
port: 587 | |
domain: 'http://' | |
authentication: plain | |
user_name: "user@domain_name" | |
password: your-password | |
production: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem install shortly [-v=<your-version-of-choice>] | |
#or for Bundler user | |
gem 'shortly' #then | |
bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#first we create a subclass of class string | |
class MyString < String | |
end | |
MyString.new | |
# => "" | |
#now we are going to override this method by some Ruby magic | |
MyString.class_eval do | |
def empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hs = Hash.new | |
hs[:absent_key] | |
# => {} | |
hs[:absent_key][:some_other_key] | |
# NoMethodError: undefined method `[]' for nil:NilClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Hash becomes more compatible | |
#Do you know you can write hash in ruby like you do in other languages. | |
hs = {first: 1, second: 2, third: 3, fourth: 4} | |
# => {:first=>1, :second=>2, :third=>3, :fourth=>4} | |
hs.class | |
# => Hash | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#rvm use 1.9.2 | |
#ruby19 allows default arguments to be in beginning of method's arguments. | |
def test_default_argument(a = 1, b) | |
"a:#{a},b:#{b}" | |
end | |
test_default_argument(3) | |
#=> "a:1,b:3" |
OlderNewer