Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

The test case of executing two rspec behaviours with line numbers

View add_spec.rb
1 2 3 4 5 6 7 8 9 10 11 12 13
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
View add_spec.rb
1 2 3 4 5 6 7 8 9 10 11 12 13
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
View add_spec.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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
Owner
zhimin commented

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
Something went wrong with that request. Please try again.