Intro to Ruby (and RSpec)
Upcoming SlideShare
Loading in...5
×
 

Intro to Ruby (and RSpec)

on

  • 1,639 views

An introduction to the Ruby language and RSpec

An introduction to the Ruby language and RSpec

Statistics

Views

Total Views
1,639
Views on SlideShare
1,639
Embed Views
0

Actions

Likes
0
Downloads
26
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Intro to Ruby (and RSpec) Intro to Ruby (and RSpec) Presentation Transcript

  • THE RUBY LANGUAGE
  • THE RUBY LANGUAGE• Originally by Yukihiro "Matz" Matsumoto• “Ruby is designed for programmer productivity and fun, following the principles of good user interface design. He stresses that systems design needs to emphasize human, rather than computer, needs.” http://en.wikipedia.org/wiki/Ruby_(programming_language)#History• Ruby 1.0 was released in 1996.
  • RUBY LANGUAGE OVERVIEW• Dynamically typed• Interpreted• Can be modified at runtime• Object oriented• Blocks & lambdas• Nice support for Regular Expressions
  • RUBY VERSIONSruby -v•1.8.6 – Still around but mostly supplanted by 1.8.7•1.8.7 – some 1.9 features, compatible w/ 1.8.6•1.9.2 – latest version, many VMs, Rails 2.3+
  • RUBY VMS• MRI (Matzs Ruby Interpreter) the original Ruby, default for 1.8• YARV (yet another Ruby VM) faster than MRI, default for 1.9• JRuby (Java)• Rubinius (pure ruby)• IronRuby (.NET)• MacRuby, HotCocoa• HotRuby/RubyJS (Flash/Javascript)
  • LETS GET STARTED• IRB: InteractiveRuBy>> 4>> 4 + 4
  • EVERYTHING IS AN OBJECT“test”.upcase“test”.class“test”.methods
  • EVERYTHING EVALUATES TO SOMETHING2+2(2+2).zero?
  • METHODS ARE MESSAGESthing.do(4)thing.do 4thing.send “do”, 4
  • OPERATORS ARE METHODSthing.do 4 3+2thing.do(4) 3.+(2)thing.send “do”, 4 3.send "+", 2
  • DEFINING CLASSES• Let’s write some code!
  • INTRODUCTION TO RSPEC• Describe the feature• Verify expectation
  • RSPEC SYNTAXdescribe Something doend
  • RSPEC SYNTAXdescribe Something do it "should do whatever it should do"end
  • RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do endend
  • RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do s = Something.new endend
  • RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do s = Something.new s.do_whatever(3, 2, 1) endend
  • RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do s = Something.new s.do_whatever(3, 2, 1).should == "blast off!" endend
  • RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do s = Something.new s.do_whatever(3, 2, 1).should == "blast off!" endend
  • • Lets try it!