Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ find
- .
- ./features
- ./features/add_note.feature
- ./features/step_definitions
- ./features/step_definitions/add_note_step.rb
- ./notepad.rb
- ./Rakefile
- ./test
- ./test/test_notepad.rb
- $ cat notepad.rb
- $notes = []
- def add note
- $notes << note
- end
- if __FILE__ == $0
- # ...
- puts "Hello, this line will not be executed during the tests."
- # ...
- end
- $ cat Rakefile
- require 'rake/testtask'
- require 'cucumber/rake/task'
- Rake::TestTask.new do |t|
- t.libs << "test"
- t.test_files = FileList['test/test*.rb']
- t.verbose = true
- end
- Cucumber::Rake::Task.new(:cucumber) do |t|
- t.cucumber_opts = ["features"]
- end
- $ cat test/test_notepad.rb
- require 'test/unit'
- require_relative '../notepad.rb'
- class TestNotepad < Test::Unit::TestCase
- def test_add
- add "Do stuff."
- assert_equal($notes.size, 1)
- assert_equal($notes.first, "Do stuff.")
- end
- end
- $ cat features/add_note.feature
- Feature: Notepad
- Scenario: Add a note
- Given I add the note "Watch TV"
- Then I should see the note "Watch TV"
- $ cat features/step_definitions/add_note_step.rb
- require_relative "../../notepad.rb"
- Given /^I add the note "(.*?)"$/ do |note|
- add note
- end
- Then /^I should see the note "(.*?)"$/ do |note|
- raise unless $notes.include? note
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement