Intro to Ruby (and RSpec)

  • 1,268 views
Uploaded on

An introduction to the Ruby language and RSpec

An introduction to the Ruby language and RSpec

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,268
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
26
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. THE RUBY LANGUAGE
  • 2. 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.
  • 3. RUBY LANGUAGE OVERVIEW• Dynamically typed• Interpreted• Can be modified at runtime• Object oriented• Blocks & lambdas• Nice support for Regular Expressions
  • 4. 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+
  • 5. 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)
  • 6. LETS GET STARTED• IRB: InteractiveRuBy>> 4>> 4 + 4
  • 7. EVERYTHING IS AN OBJECT“test”.upcase“test”.class“test”.methods
  • 8. EVERYTHING EVALUATES TO SOMETHING2+2(2+2).zero?
  • 9. METHODS ARE MESSAGESthing.do(4)thing.do 4thing.send “do”, 4
  • 10. OPERATORS ARE METHODSthing.do 4 3+2thing.do(4) 3.+(2)thing.send “do”, 4 3.send "+", 2
  • 11. DEFINING CLASSES• Let’s write some code!
  • 12. INTRODUCTION TO RSPEC• Describe the feature• Verify expectation
  • 13. RSPEC SYNTAXdescribe Something doend
  • 14. RSPEC SYNTAXdescribe Something do it "should do whatever it should do"end
  • 15. RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do endend
  • 16. RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do s = Something.new endend
  • 17. RSPEC SYNTAXdescribe Something do it "should do whatever it should do" do s = Something.new s.do_whatever(3, 2, 1) endend
  • 18. 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
  • 19. 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
  • 20. • Lets try it!