How to eat Cucmber

  • 2,122 views
Uploaded on

 

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

Views

Total Views
2,122
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
15
Comments
0
Likes
4

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

Transcript

  • 1. Cucumber ( ) ○× sonic sonic id:nsgc
  • 2. http://cukes.info/
  • 3. Behaviour Driven Development with elegance and joy
  • 4. !
  • 5. Cucumber Cucumber Cucumber
  • 6. Cucumber Cucumber Cucumber
  • 7. Cucumber Cucumber Cucumber
  • 8. Cucumber ? 35 Rails id:moro
  • 9. Cucumber ? http://cukes.info/ Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business-readable domain- specific language and serves as documentation, automated tests and development-aid - all rolled into one format.
  • 10. Cucumber ? http://cukes.info/ all rolled into one format DSL
  • 11. ( )BDD ?
  • 12. ( )BDD ?
  • 13. ✓ Cucumber ✓ BDD ✓ BDD ✓ =
  • 14. Cucumber Cucumber Cucumber
  • 15. Cucumber
  • 16. Cucumber
  • 17. gem ✓ cucumber ✓ webrat ✓ nokogiri ※ ✓ rspec ✓ rspec-rails
  • 18. Webrat Ruby Acceptance Testing for Web applications class SignupTest < ActionController::IntegrationTest def test_trial_account_sign_up visit home_path click_link "Sign up" fill_in "Email", :with => "good@example.com" select "Free account" click_button "Register" end end
  • 19. Nokogiri HTML, XML, SAX, XSLT, Read require 'nokogiri' require 'open-uri' # Get a Nokogiri::HTML:Document for the page we’re interested in... doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) # Do funky things with it using Nokogiri::XML::Node methods... #### # Search for nodes by css doc.css('h3.r a.l').each do |link| puts link.content end #### # Search for nodes by xpath doc.xpath('//h3/a[@class="l"]').each do |link| puts link.content end #### # Or mix and match. doc.search('h3.r a.l', '//h3/a[@class="l"]').each do |link| puts link.content end
  • 20. Nokogiri HTML, XML, SAX, XSLT, Read require 'nokogiri' require 'open-uri' # Get a Nokogiri::HTML:Document for the page we’re interested in... doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) # Do funky things with it using Nokogiri::XML::Node methods... #### # Search for nodes by css doc.css('h3.r a.l').each do |link| puts link.content end #### # Search for nodes by xpath doc.xpath('//h3/a[@class="l"]').each do |link| puts link.content end #### # Or mix and match. doc.search('h3.r a.l', '//h3/a[@class="l"]').each do |link| puts link.content end
  • 21. Cucumber
  • 22. $ruby script/generate cucumber
  • 23. $ruby script/generate cucumber
  • 24. features/step_definitions/webrat_steps.rb
  • 25. features/step_definitions/webrat_steps.rb step features/step_definitions step step webrat_step.rb Given, When, Then Webrat Rspec
  • 26. Webrat webrat_step.rb Rdoc visit(url = nil, http_method visit path_to(page_name) URL = :get, data = {}) click_button(button) click_button(value = nil) fill_in(field_locator, options fill_in(field, :with => value) = {}) ) RDocul.us http://docs.rdocul.us/webrat/master/ ramaze-users Webrat http://route477.net/ramaze/?Webrat
  • 27. ✓ features/support/env.rb cucumber ✓ features/support/paths.rb path_to
  • 28. Cucumber
  • 29. $ruby script/generate feature Memo
  • 30. $ruby script/generate feature Memo
  • 31. features/manage_memos.feature
  • 32. features/manage_memos.feature feature Feature: Scenario: Step Given When Then And
  • 33. features/manage_memos.feature
  • 34. features/manage_memos.feature
  • 35. Cucumber
  • 36. ✓ $rake features $cucumber featutes ✓ $cucumber features/manage_memos.feature
  • 37. ✓ gem cucumber, webrat ✓ ruby script/generate cucumber cucumber ✓ ruby script/generate feature XXX XXX ✓ rake features cucumber
  • 38. Cucumber Cucumber Cucumber
  • 39. features/manage_memos.feature
  • 40. features/manage_memos.feature ‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’ ( ! )
  • 41. ✓ step_definition step ✓
  • 42. ?
  • 43. moro-miso step_definition “ ” $gem sources --add http://gems.github.com $gem install moro-miso Cuke step_definition miso (id:moro ) http://d.hatena.ne.jp/moro/20090603/1244042258
  • 44. $ruby script/generate miso
  • 45. features/step_definitions/webrat_ja_steps.rb
  • 46. ★ -l ja $cucumber features/manage_memos.feature -l ja $cucumber features -l ja
  • 47. • •
  • 48. NO MONEY
  • 49. ?
  • 50. ?
  • 51. ✓ step_definition feature ✓ step_definition moro- miso ✓ step ✓ Rspec BDD
  • 52. Cucumber ( ) ○× sonic sonic id:nsgc
  • 53. Cucumber ( ) ○× sonic sonic id:nsgc
  • 54. • Cucumber • • Rainbow •( ) !
  • 55. • • autospec • • cucumber.el • Nokogiri xpath
  • 56. !