Created
May 18, 2012 02:12
-
-
Save zhimin/2722735 to your computer and use it in GitHub Desktop.
The test case of executing two rspec behaviours with line numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Add" do # sample test rspec 1 | |
it "can add single digit" do | |
puts "Add 1 + 2" | |
(1+2).should == 3 | |
end | |
it "can add double digit" do | |
puts "Add 11 + 22" | |
(11+22).should == 33 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rspec' | |
err, out = StringIO.new, StringIO.new | |
args = ["add_spec.rb", "--line_number", "4"] | |
RSpec::Core::Runner.run(args, err, out) | |
RSpec.reset | |
args = ["minus_spec.rb", "--line_number", "10"] | |
RSpec::Core::Runner.run(args, err, out) | |
out.rewind; puts out.read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Minu" do | |
# No tests on line 4 | |
it "can minus single digit" do | |
puts "3 - 2" | |
(3-2).should == 1 | |
end | |
it "can minus double digit" do | |
puts "22 - 11" | |
(22-11).should == 11 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download three files in the same folder, then run drive_rspec_runner.rb