Effective Testing  with Ruby    (c)2012 YourGolf Online Inc. All Rights Reserved.
Self Introduction✴Name: Akira Sosa✴I m working at YourGolf Online Inc.✴I m responsible for development
Currently✴Providing No.1 smart phone application for golfers✴The number of downloads is over 1,000,000!!
In the future✴We are planing to launch SNS platform for golfers all around the world.
We had an issueOur environment changes more andmore quickly.However, we have to continueproviding our value to the world.
YourGolf Development     AGILE!!     (c)2012 YourGolf Online Inc. All Rights Reserved.
Why Testing?                  In Agile Development• We are testing    repeatedly.•    Small team without    specialist.   ...
Why Testing?                   In Agile Development                                                                 Analys...
Why Ruby?• Ruby community is high-quality and  active community.• So, there are a lot of useful testing  libraries and too...
Top Languages on github     (c)2012 YourGolf Online Inc. All Rights Reserved.
Top Languages on github     (c)2012 YourGolf Online Inc. All Rights Reserved.
Why Ruby?• Ruby community is high-quality and active  community.• So, there are a lot of useful testing  libraries and too...
Libraries and Tools• Rspec• Timecop• Factory Girl• Capybara, Capybara-webkit• VCR         (c)2012 YourGolf Online Inc. All...
Timecop•   It provides "time travel" and "time freezing"    capabilities, making it dead simple to test time-    dependent...
Timecop•   It provides "time travel" and "time freezing"    capabilities, making it dead simple to test time-    dependent...
Timecop•   It provides "time travel" and "time freezing"    capabilities, making it dead simple to test time-    dependent...
Timecopdescribe "API rate limit" do  context "when accessed more than 100 times" do    before do      @rate_limit = Factor...
Timecopdescribe "API rate limit" do  context "when accessed more than 100 times" do    before do      @rate_limit = Factor...
Timecopdescribe "API rate limit" do  context "when accessed more than 100 times" do    before do      @rate_limit = Factor...
Timecopdescribe "API rate limit" do  context "when accessed more than 100 times" do    before do      @rate_limit = Factor...
Factory Girl• Factory Girl is a fixtures replacement  with a straightforward definition syntax.                             ...
Factory DefinitionFactoryGirl.define do  factory :user do    sequence(:email) {|n| "email#{n}@factory.com" }    factory :ad...
Factory DefinitionFactoryGirl.define do  factory :user do    sequence(:email) {|n| "email#{n}@factory.com" }    factory :ad...
Capybara, Capybara-            webkit  •   It helps us creating acceptance test code.  •   It simulates how a real user wo...
VCR • It records your test suites HTTP    interactions and replay them during    future test runs for fast, deterministic,...
Cam on nhieu!   (c)2012 YourGolf Online Inc. All Rights Reserved.
Upcoming SlideShare
Loading in...5
×

Effective Testing with Ruby

601

Published on

Published in: Technology, Travel
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
601
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Effective Testing with Ruby

    1. 1. Effective Testing with Ruby (c)2012 YourGolf Online Inc. All Rights Reserved.
    2. 2. Self Introduction✴Name: Akira Sosa✴I m working at YourGolf Online Inc.✴I m responsible for development
    3. 3. Currently✴Providing No.1 smart phone application for golfers✴The number of downloads is over 1,000,000!!
    4. 4. In the future✴We are planing to launch SNS platform for golfers all around the world.
    5. 5. We had an issueOur environment changes more andmore quickly.However, we have to continueproviding our value to the world.
    6. 6. YourGolf Development AGILE!! (c)2012 YourGolf Online Inc. All Rights Reserved.
    7. 7. Why Testing? In Agile Development• We are testing repeatedly.• Small team without specialist. (c)2012 YourGolf Online Inc. All Rights Reserved.
    8. 8. Why Testing? In Agile Development Analyst• We are testing Tester Developer repeatedly.• Small team without specialist. Analyst Tester Developer (c)2012 YourGolf Online Inc. All Rights Reserved.
    9. 9. Why Ruby?• Ruby community is high-quality and active community.• So, there are a lot of useful testing libraries and tools. (c)2012 YourGolf Online Inc. All Rights Reserved.
    10. 10. Top Languages on github (c)2012 YourGolf Online Inc. All Rights Reserved.
    11. 11. Top Languages on github (c)2012 YourGolf Online Inc. All Rights Reserved.
    12. 12. Why Ruby?• Ruby community is high-quality and active community.• So, there are a lot of useful testing libraries and tools. (c)2012 YourGolf Online Inc. All Rights Reserved.
    13. 13. Libraries and Tools• Rspec• Timecop• Factory Girl• Capybara, Capybara-webkit• VCR (c)2012 YourGolf Online Inc. All Rights Reserved.
    14. 14. Timecop• It provides "time travel" and "time freezing" capabilities, making it dead simple to test time- dependent code. (c)2012 YourGolf Online Inc. All Rights Reserved.
    15. 15. Timecop• It provides "time travel" and "time freezing" capabilities, making it dead simple to test time- dependent code. $ sudo date 021423002005 (c)2012 YourGolf Online Inc. All Rights Reserved.
    16. 16. Timecop• It provides "time travel" and "time freezing" capabilities, making it dead simple to test time- dependent code. $ sudo date 021423002005 He should use Timecop! (c)2012 YourGolf Online Inc. All Rights Reserved.
    17. 17. Timecopdescribe "API rate limit" do context "when accessed more than 100 times" do before do @rate_limit = Factory.create(:rate_limit, count: 101) end it "will be not available" do @rate_limit.exceeded?.should be_true end it "can be reseted after 1 hour" do Timecop.travel(Time.now + 1.hours + 1.minutes) @rate_limit.exceeded?.should be_false end endend (c)2012 YourGolf Online Inc. All Rights Reserved.
    18. 18. Timecopdescribe "API rate limit" do context "when accessed more than 100 times" do before do @rate_limit = Factory.create(:rate_limit, count: 101) end it "will be not available" do @rate_limit.exceeded?.should be_true end it "can be reseted after 1 hour" do Timecop.travel(Time.now + 1.hours + 1.minutes) @rate_limit.exceeded?.should be_false end endend (c)2012 YourGolf Online Inc. All Rights Reserved.
    19. 19. Timecopdescribe "API rate limit" do context "when accessed more than 100 times" do before do @rate_limit = Factory.create(:rate_limit, count: 101) end it "will be not available" do @rate_limit.exceeded?.should be_true end it "can be reseted after 1 hour" do Timecop.travel(Time.now + 1.hours + 1.minutes) @rate_limit.exceeded?.should be_false end endend (c)2012 YourGolf Online Inc. All Rights Reserved.
    20. 20. Timecopdescribe "API rate limit" do context "when accessed more than 100 times" do before do @rate_limit = Factory.create(:rate_limit, count: 101) end it "will be not available" do @rate_limit.exceeded?.should be_true end it "can be reseted after 1 hour" do Timecop.travel(Time.now + 1.hours + 1.minutes) @rate_limit.exceeded?.should be_false end endend (c)2012 YourGolf Online Inc. All Rights Reserved.
    21. 21. Factory Girl• Factory Girl is a fixtures replacement with a straightforward definition syntax. I m tired of fixture files. Help me, please! Factory Girl can help him. (c)2012 YourGolf Online Inc. All Rights Reserved.
    22. 22. Factory DefinitionFactoryGirl.define do factory :user do sequence(:email) {|n| "email#{n}@factory.com" } factory :admin { admin true } end generates unique email factory :post do title "My Post" association :user endendClient Codedescribe User do it "can love each other" do no need to care for the jack = FactoryGirl.create(:user) uniqueness rose = FactoryGirl.create(:user) jack.girl_friend = rose jack.loves?(rose).should be_true endend
    23. 23. Factory DefinitionFactoryGirl.define do factory :user do sequence(:email) {|n| "email#{n}@factory.com" } factory :admin { admin true } end factory :post do title "My Post" association association :user endendClient Codedescribe Post do can define the association easily it "belongs to user" do post = FactoryGirl.create(:post) post.user.should be endend
    24. 24. Capybara, Capybara- webkit • It helps us creating acceptance test code. • It simulates how a real user would interact with your app.describe "the signup process", type: :request do before :each do FactoryGirl.create(email: user@example.com, password: secret) end it "signs me in" do within("#session") do fill_in Login, with: user@example.com fill_in Password, with: secret end click_link Sign in endend (c)2012 YourGolf Online Inc. All Rights Reserved.
    25. 25. VCR • It records your test suites HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.describe "VCR example group metadata", :vcr do it records an http request do make_http_request.should == Hello endend (c)2012 YourGolf Online Inc. All Rights Reserved.
    26. 26. Cam on nhieu! (c)2012 YourGolf Online Inc. All Rights Reserved.
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×