How to eat Cucmber

2,297
-1

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,297
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
16
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

How to eat Cucmber

  1. 1. Cucumber ( ) ○× sonic sonic id:nsgc
  2. 2. http://cukes.info/
  3. 3. Behaviour Driven Development with elegance and joy
  4. 4. !
  5. 5. Cucumber Cucumber Cucumber
  6. 6. Cucumber Cucumber Cucumber
  7. 7. Cucumber Cucumber Cucumber
  8. 8. Cucumber ? 35 Rails id:moro
  9. 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. 10. Cucumber ? http://cukes.info/ all rolled into one format DSL
  11. 11. ( )BDD ?
  12. 12. ( )BDD ?
  13. 13. ✓ Cucumber ✓ BDD ✓ BDD ✓ =
  14. 14. Cucumber Cucumber Cucumber
  15. 15. Cucumber
  16. 16. Cucumber
  17. 17. gem ✓ cucumber ✓ webrat ✓ nokogiri ※ ✓ rspec ✓ rspec-rails
  18. 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. 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. 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. 21. Cucumber
  22. 22. $ruby script/generate cucumber
  23. 23. $ruby script/generate cucumber
  24. 24. features/step_definitions/webrat_steps.rb
  25. 25. features/step_definitions/webrat_steps.rb step features/step_definitions step step webrat_step.rb Given, When, Then Webrat Rspec
  26. 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. 27. ✓ features/support/env.rb cucumber ✓ features/support/paths.rb path_to
  28. 28. Cucumber
  29. 29. $ruby script/generate feature Memo
  30. 30. $ruby script/generate feature Memo
  31. 31. features/manage_memos.feature
  32. 32. features/manage_memos.feature feature Feature: Scenario: Step Given When Then And
  33. 33. features/manage_memos.feature
  34. 34. features/manage_memos.feature
  35. 35. Cucumber
  36. 36. ✓ $rake features $cucumber featutes ✓ $cucumber features/manage_memos.feature
  37. 37. ✓ gem cucumber, webrat ✓ ruby script/generate cucumber cucumber ✓ ruby script/generate feature XXX XXX ✓ rake features cucumber
  38. 38. Cucumber Cucumber Cucumber
  39. 39. features/manage_memos.feature
  40. 40. features/manage_memos.feature ‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’, ‘ ’ ( ! )
  41. 41. ✓ step_definition step ✓
  42. 42. ?
  43. 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. 44. $ruby script/generate miso
  45. 45. features/step_definitions/webrat_ja_steps.rb
  46. 46. ★ -l ja $cucumber features/manage_memos.feature -l ja $cucumber features -l ja
  47. 47. • •
  48. 48. NO MONEY
  49. 49. ?
  50. 50. ?
  51. 51. ✓ step_definition feature ✓ step_definition moro- miso ✓ step ✓ Rspec BDD
  52. 52. Cucumber ( ) ○× sonic sonic id:nsgc
  53. 53. Cucumber ( ) ○× sonic sonic id:nsgc
  54. 54. • Cucumber • • Rainbow •( ) !
  55. 55. • • autospec • • cucumber.el • Nokogiri xpath
  56. 56. !

×