SlideShare a Scribd company logo
1 of 89
Download to read offline
What’s culture
and tools in
Ruby worlds.
                  SHIBATA Hiroshi
     Eiwa System Management,Inc.
SHIBATA Hiroshi
   a.k.a hsbt

shibata.hiroshi@gmail.com




  tDiary commiter
http://www.hsbt.org/

http://github.com/hsbt/

http://twitter.com/hsbt/
asakusa.rb
Sapporo
RubyKaigi
   03
SapporoRubyKaigi01
SapporoRubyKaigi02
tDiary
RubyKaigi
  2010
Conflicts
   and
Resolutions
ThoughtWorks
Sudhindra Rao
Sudhindra Rao
Culture
ESM
Culture
 and
 Tool
Why?
Ruby World
Conference
  2010
http://www.flickr.com/photos/14403423@N05/4979310028
RSpec
metric_fu
Rails
mock / stub
rspec-mocks
rr
mocha
flexmock
rr
stub
stub(User).find { 'value' }

User.find -> ‘value’

any_incetance_of(User) do |u|
    stub(u).name { ‘alice’ }
end
@u = User.new
@u.name -> ‘alice’
mock
mock(User).find.twice { 'value' }

User.find -> ‘value’


mock(User).all.mock!.count { 10 }

User.all.count -> 10
Expectations

class User
  self.def import!
    File.open(‘export.csv’).read
  end
end
Expectations
before
  mock(File).open.with_any_args.
  mock!.read { ‘alice,bob’ }
end

it “#impot!” do
  User.import!.
    should eq ‘alice,bob’
end
webmock
stub_request(:post, "www.example.com").
  with(:body => "alice").
  to_return(:status => 200)



stub_request(:post, "www.example.com").
  to_timeout
stub

mock
Test Fixture
# wineries.yml                # wines.yml
sunnyside:                    merlot:
  name: Sunnyside Vineyards     name: Sunnyside Reserve
  city: Sonoma                  year: 2003
  state: CA                     family: Merlot
  country: USA                  winery: sunnyside



            rake db:fixtures:load
harmful
fixture
replacement
factory_girl
FactoryGirl.define do
    factory :user do
      first_name 'John'
      last_name 'Doe'
      admin false
    end
end
user = Factory.build(:user)
user = Factory.create(:user)
factory_girl
FactoryGirl.sequence :email do |n|
  "person#{n}@example.com"
end

Factory.next :email
# => "person1@example.com"
Machinist
 Post.blueprint do
   author
   title { "Post #{sn}" }
   body   { "Lorem ipsum..." }
 end

post = Post.make
post = Post.make!(:body => ‘bob’)
mongodb support

Machinist Mongo

  Fabrication
Capybara
end-to-end test

integration test

acceptance test
DSL
feature '          ' do
  background do
    setup_tdiary
  end
  scenario '              ' do
    visit '/'
    within('title') do
      page.should have_content('      ') }
    end
    within('h1') do
      page.should have_content('      ')
    end
    page.should have_css('a[href="update.rb"]')
! end
end
Selenium Webdriver
RSpec.configure do |config|
  config.include Capybara, :type
=> :acceptance

  Capybara.register_driver :selenium do |app|
    Capybara::Driver::Selenium.new
(app, :browser => :chrome)
  end

  config.before(:all, :selenium => true) do
    Capybara.current_driver = :selenium
  end
end
http://www.flickr.com/photos/mfp/4186901873
Continuous
Integration
paralell_tests
% rake parallel:spec
/Users/hsbt/.gem/ruby/1.8/gems/
parallel_tests-0.4.9/lib/parallel_tests.rb:
6: warning: already initialized constant
VERSION
2 processes for 63 specs, ~ 31 specs per
process
No DRb server is running. Running in local
process instead ...
No DRb server is running. Running in local
process instead ...
............................................
............................................
.....................
http://www.ne.jp/asahi/t/wada/articles/Refactoring_and_Test.pdf
Spork
require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path(File.join
(File.dirname
(__FILE__),'..','config','environment'))
  require 'email_spec'
  require 'database_cleaner'
end
Guard::RSpec/Zentest
Continuous
Integration
DRY
get_number → number
                 size or count
  map
     if not item → unless item
nil? or empty?        flatten
RSpec::Matchers.define :be_encoded_sjis do
  match do |actual|
    NKF.guess(actual) == NKF::SJIS
  end

  description do
    "be encoded with Shift_JIS"
  end
end
•http://github.com/rspec/rspec
•http://github.com/jscruggs/metric_fu
•http://github.com/btakita/rr
•http://github.com/bblimke/webmock
•http://github.com/thoughtbot/factory_girl
•http://github.com/notahat/machinist
•http://github.com/nmerouze/machinist_mongo
•http://github.com/paulelliott/fabrication
•http://github.com/jnicklas/capybara
•http://code.google.com/p/selenium/
•http://hudson-ci.org/
•http://github.com/grosser/parallel_tests
•http://github.com/timcharper/spork
•http://github.com/guard/guard-rspec
Sapporo rubykaigi03

More Related Content

More from Hiroshi SHIBATA

More from Hiroshi SHIBATA (20)

Why ANDPAD commit Ruby and RubyKaigi?
Why ANDPAD commit Ruby and RubyKaigi?Why ANDPAD commit Ruby and RubyKaigi?
Why ANDPAD commit Ruby and RubyKaigi?
 
RailsGirls から始める エンジニアリングはじめの一歩
RailsGirls から始める エンジニアリングはじめの一歩RailsGirls から始める エンジニアリングはじめの一歩
RailsGirls から始める エンジニアリングはじめの一歩
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
 
Roadmap for RubyGems 4 and Bundler 3
Roadmap for RubyGems 4 and Bundler 3Roadmap for RubyGems 4 and Bundler 3
Roadmap for RubyGems 4 and Bundler 3
 
The Future of library dependency management of Ruby
 The Future of library dependency management of Ruby The Future of library dependency management of Ruby
The Future of library dependency management of Ruby
 
Ruby Security the Hard Way
Ruby Security the Hard WayRuby Security the Hard Way
Ruby Security the Hard Way
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled Bundler
 
What's new in RubyGems3
What's new in RubyGems3What's new in RubyGems3
What's new in RubyGems3
 
Productive Organization with Ruby
Productive Organization with RubyProductive Organization with Ruby
Productive Organization with Ruby
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Sapporo rubykaigi03