Skip to content

Instantly share code, notes, and snippets.

@zhimin
Created May 18, 2012 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhimin/2722735 to your computer and use it in GitHub Desktop.
Save zhimin/2722735 to your computer and use it in GitHub Desktop.
The test case of executing two rspec behaviours with line numbers
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
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
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
@zhimin
Copy link
Author

zhimin commented May 18, 2012

Download three files in the same folder, then run drive_rspec_runner.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment