Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2012
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. $ find
  2. .
  3. ./features
  4. ./features/add_note.feature
  5. ./features/step_definitions
  6. ./features/step_definitions/add_note_step.rb
  7. ./notepad.rb
  8. ./Rakefile
  9. ./test
  10. ./test/test_notepad.rb
  11. $ cat notepad.rb
  12. $notes = []
  13.  
  14. def add note
  15. $notes << note
  16. end
  17.  
  18. if __FILE__ == $0
  19. # ...
  20. puts "Hello, this line will not be executed during the tests."
  21. # ...
  22. end
  23. $ cat Rakefile
  24. require 'rake/testtask'
  25. require 'cucumber/rake/task'
  26.  
  27. Rake::TestTask.new do |t|
  28. t.libs << "test"
  29. t.test_files = FileList['test/test*.rb']
  30. t.verbose = true
  31. end
  32.  
  33. Cucumber::Rake::Task.new(:cucumber) do |t|
  34. t.cucumber_opts = ["features"]
  35. end
  36. $ cat test/test_notepad.rb
  37. require 'test/unit'
  38. require_relative '../notepad.rb'
  39.  
  40. class TestNotepad < Test::Unit::TestCase
  41. def test_add
  42. add "Do stuff."
  43. assert_equal($notes.size, 1)
  44. assert_equal($notes.first, "Do stuff.")
  45. end
  46. end
  47. $ cat features/add_note.feature
  48. Feature: Notepad
  49. Scenario: Add a note
  50. Given I add the note "Watch TV"
  51. Then I should see the note "Watch TV"
  52. $ cat features/step_definitions/add_note_step.rb
  53. require_relative "../../notepad.rb"
  54.  
  55. Given /^I add the note "(.*?)"$/ do |note|
  56. add note
  57. end
  58.  
  59. Then /^I should see the note "(.*?)"$/ do |note|
  60. raise unless $notes.include? note
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement