Skip to content

Instantly share code, notes, and snippets.

View andyl's full-sized avatar
🎯
Focusing

andyl

🎯
Focusing
View GitHub Profile
@andyl
andyl / test1_spec.rb
Created March 21, 2011 01:28
Rspec Stub Test
# test1_spec.rb - run this using "rspec test1_spec.rb"
require 'rspec'
class Test1
def initialize
sayhi
end
def sayhi
puts "HI"
end
You can become a registered Vim user by sending at least 10 euro. This works
similar to sponsoring Vim, see |sponsor| above. Registration was made
possible for the situation where your boss or bookkeeper may be willing to
register software, but does not like the terms "sponsoring" and "donation".
c
d
e
# test2_spec.rb - call using 'rspec test2_spec.rb'
require 'rspec'
class Test2
attr_accessor :msg
def initialize
@msg = sayhi
end
def sayhi
# test2_spec.rb - call using 'rspec test2_spec.rb'
require 'rspec'
require 'mocha'
RSpec::configure do |config|
config.mock_with :mocha
end
class Test2
def run_in_background(&block)
Process.fork do
Process.fork do
puts "Launching Background Process"
Daemons.call &block
puts "Background Process has been Launched"
end
exit
end
end
class User < ActiveRecord::Base
# ----- Devise -----
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable #, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
require 'spec_helper'
describe User do
describe "Object Attributes" do
before(:each) { @obj = User.new }
specify { @obj.should respond_to(:first_name) }
specify { @obj.should respond_to(:last_name) }
specify { @obj.should respond_to(:login) }
end
require 'rubygems'
require 'parslet'
class Address < Parslet::Parser
# Single character rules
rule(:comma) { str(',') >> space? }
rule(:space) { match('\s').repeat }
rule(:space?) { space.maybe }
rule(:newline) { str("\n").repeat }
rule(:digit) { match('[0-9]') }
require 'rubygems'
require 'parslet'
class Address < Parslet::Parser
# Single character rules
rule(:comma) { str(',') >> space? }
rule(:space) { match('\s').repeat }
rule(:space?) { space.maybe }
rule(:newline) { str("\n").repeat }
rule(:digit) { match('[0-9]') }