Tres Gemas De Ruby
Upcoming SlideShare
Loading in...5
×
 

Tres Gemas De Ruby

on

  • 819 views

Lighting talk about Rake, RSpec and WebRat

Lighting talk about Rake, RSpec and WebRat

Statistics

Views

Total Views
819
Views on SlideShare
815
Embed Views
4

Actions

Likes
0
Downloads
1
Comments
0

4 Embeds 4

http://www.slideshare.net 1
http://translate.googleusercontent.com 1
http://blog.continuum.cl 1
http://www.linkedin.com 1

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

Tres Gemas De Ruby Tres Gemas De Ruby Presentation Transcript

  • Tres gemas de Ruby Leo Soto M. Lenguajes Dinámicos Chile
  • 1. Rake
  • ¿Algo así como Make?
  • ps: $(NAME).ps %.ps: %.dvi dvips $(DVIPSOPT) $< -o $@ hyper: $(NAME).dtx $(NAME).sty pdflatex "relaxletmakehyperrefactiveinput $(NAME).dtx" $(NAME).pdf: $(NAME).dtx $(NAME).sty pdflatex $(NAME).dtx archive: @ tar -czf $(ARCHNAME) $(ARCHIVE) @ echo $(ARCHNAME) clean: rm -f $(NAME). {log,toc,lot,lof,idx,ilg,ind,aux,blg,bbl,dvi,ins,out} distclean: clean rm -f $(NAME).{ps,sty,pdf} $(ARCHNAME)
  • http://www.flickr.com/photos/ross/28330560/
  • Dos grandes diferencias:
  • task :compile do mxmlc 'FlexApp', OUTPUT_FOLDER, ['libs/ThunderBoltAS3_Flex.swc'] end task :test do mxmlc 'TestRunner', '', ['libs/flexunit.swc'] run_swf 'TestRunner.swf' end task :copy_to_main_project => [:compile] do sh "cp -af #{FILES_TO_COPY} #{OUTPUT_FOLDER}" end task :clean do sh "rm -rf #{OUTPUT_FOLDER}/*" end task :default => [:compile, :copy_to_main_project]
  • task :compile do mxmlc 'FlexApp', OUTPUT_FOLDER, ['libs/ThunderBoltAS3_Flex.swc'] end task :test do mxmlc 'TestRunner', '', ['libs/flexunit.swc'] run_swf 'TestRunner.swf' end task :copy_to_main_project => [:compile] do sh "cp -af #{FILES_TO_COPY} #{OUTPUT_FOLDER}" end task :clean do sh "rm -rf #{OUTPUT_FOLDER}/*" end task :default => [:compile, :copy_to_main_project]
  • def mxmlc(file, output_folder, include_libraries=nil, warnings=false, debug=true) # Uses fcshd <http://code.google.com/p/flex-compiler-shell-daemon/> # if found: if command_exists? "fcshd.py" and not ENV['IGNORE_FCSH'] # fcshd wants absolute paths file = File.expand_path(file) output_folder = File.expand_path(output_folder) if include_libraries include_libraries = include_libraries.map { |x| File.expand_path(x) } end cmdline = mxmlc_cmdline(file, output_folder, include_libraries, warnings, debug) sh "fcshd.py "mxmlc #{cmdline}"" else cmdline = mxmlc_cmdline(file, output_folder, include_libraries, warnings, debug) sh "$FLEX_HOME/bin/mxmlc #{cmdline}" end end
  • task :compile do mxmlc 'FlexApp', OUTPUT_FOLDER, ['libs/ThunderBoltAS3_Flex.swc'] end task :test do mxmlc 'TestRunner', '', ['libs/flexunit.swc'] run_swf 'TestRunner.swf' end task :copy_to_main_project => [:compile] do sh "cp -af #{FILES_TO_COPY} #{OUTPUT_FOLDER}" end task :clean do sh "rm -rf #{OUTPUT_FOLDER}/*" end task :default => [:compile, :copy_to_main_project]
  • def run_swf(swf) FLASH_PLAYERS.each do |cmd| if command_exists? cmd sh "#{cmd} #{swf}" return end end end
  • Y metaprogramming!
  • namespace :rpc do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox "rpc" end task :run => [:compile] do run_sandbox "rpc" end end namespace :graph do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox "graph" end task :run => [:compile] do run_sandbox "graph" end end namespace :lang do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox "lang" end task :run => [:compile] do run_sandbox "lang" end end
  • $ rake rpc:compile $ rake graph:compile
  • namespace :rpc do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox "rpc" end task :run => [:compile] do run_sandbox "rpc" end end namespace :graph do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox "graph" end task :run => [:compile] do run_sandbox "graph" end end namespace :lang do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox "lang" end task :run => [:compile] do run_sandbox "lang" end end
  • def flex_sandbox(*names) names.each do |name| namespace name do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox name end task :run => [:compile] do run_sandbox name end end end namespace :sandboxes do task :compile => names.map { |name| "#{name}:compile" } task :run => names.map { |name| "#{name}:run"} end end
  • def flex_sandbox(*names) names.each do |name| namespace name do task :compile => [:bigflexlib, :semanticflash] do compile_sandbox name end task :run => [:compile] do run_sandbox name end end end namespace :sandboxes do task :compile => names.map { |name| "#{name}:compile" } task :run => names.map { |name| "#{name}:run"} end end flex_sandbox :rpc, :graph, :lang
  • $ rake rpc:compile $ rake graph:compile
  • $ rake rpc:compile $ rake graph:compile $ rake sandboxes:compile
  • 2. RSpec
  • xUnit vs RSpec:
  • class FactorialTestCase < TestCase def test_factorial_method_added_to_integer_numbers assert_true 1.respond_to?(:factorial) end def test_factorial_of_zero assert_equals 0.factorial, 1 end def test_factorial_of_positives assert_equals 1.factorial, 1 assert_equals 2.factorial, 2 assert_equals 3.factorial, 6 assert_equals 20.factorial, 2432902008176640000 end def test_factorial_of_negatives assert_raises ArgumentError do -1.factorial end end end
  • describe '#factorial' do it "adds a factorial method to integer numbers" do 1.respond_to?(:factorial).should be_true end it "defines the factorial of 0 as 1" do 0.factorial.should == 1 end it "calculates the factorial of any positive integer" do 1.factorial.should == 1 2.factorial.should == 2 3.factorial.should == 6 20.factorial.should == 2432902008176640000 end it "raises an exception when applied to negative numbers" do -1.factorial.should raise_error(ArgumentError) end end
  • describe '#prime?' do it "adds a prime method to integer numbers" do 1.respond_to?(:prime?).should be_true end it "returns true for prime numbers" do 2.should be_prime 3.should be_prime 11.should be_prime 97.should be_prime 727.should be_prime end it "returns false for non prime numbers" do 20.should_not be_prime 999.should_not be_prime end end
  • One more thing...
  • One more thing... 3. WebRat
  • describe "creating a new CEO letter campaign" do before do click_link 'Campaigns' click_link 'New CEO Letter Campaign' end it "persists delivery method, start date and end date" do check 'Email' click_button 'Create campaign' response.body.should contain_text("1 Delivery method: Email") response.body.should contain("12/12/2009") response.body.should contain("6/12/2010") end it "allows an email campaign" do check 'Email' click_button 'Create campaign' response.body.should contain_text("1 Delivery method: Email") end end
  • http://rake.rubyforge.org/ http://rspec.info/ http://gitrdoc.com/brynary/webrat/tree/master/
  • http://rake.rubyforge.org/ http://rspec.info/ http://gitrdoc.com/brynary/webrat/tree/master/ ¡Gracias!