Skip to content

Commit

Permalink
Simple implementation of series and step methods without reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
btakita committed Aug 1, 2009
1 parent 667db3e commit 0ec7dcf
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rspec/series.rb
@@ -0,0 +1,10 @@
dir = File.dirname(__FILE__)
require "#{dir}/series/example_group_methods"
require "#{dir}/series/series_methods"

module Spec
ExampleGroup.class_eval do
extend Spec::Series::ExampleGroupMethods
include Spec::Series::SeriesMethods
end
end
14 changes: 14 additions & 0 deletions lib/rspec/series/example_group_methods.rb
@@ -0,0 +1,14 @@
module Spec
module Series
module ExampleGroupMethods
def self.included(mod)
p mod
puts "#{__FILE__}:#{__LINE__}"
end

def series(*args, &block)
it(*args, &block)
end
end
end
end
9 changes: 9 additions & 0 deletions lib/rspec/series/series_methods.rb
@@ -0,0 +1,9 @@
module Spec
module Series
module SeriesMethods
def step(description)
yield
end
end
end
end
31 changes: 31 additions & 0 deletions spec/series_spec.rb
@@ -0,0 +1,31 @@
require "#{File.dirname(__FILE__)}/spec_helper"

describe "A Series" do
already_run = false

it "can run a series" do
return if already_run
already_run = true
example_group = self.class

steps_run = []
example_group.instance_eval do
series "can run multiple steps" do
step "one" do
steps_run << 1
end
step "two" do
steps_run << 2
end
step "three" do
steps_run << 3
end
end
end

err, output = StringIO.new, StringIO.new
example_group.run(Spec::Runner::Options.new(err, output))
steps_run.should == [1,2,3]
end

end
11 changes: 11 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,11 @@
require "rubygems"
require "spec"
require "spec/autorun"
require "rr"
$:.unshift(File.expand_path("#{File.dirname(__FILE__)}/../lib"))
require "rspec/series"
ARGV.push("-b", "-fn")

Spec::Runner.configure do |config|
config.mock_with RR::Adapters::Rspec
end

0 comments on commit 0ec7dcf

Please sign in to comment.