Sha256: 62b3970cfb3e4c15992970734a9a22211c32e5dd6f67c2e06f501efb5da22e32

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

$shared_specs = {}

module Kernel
  # Stores the passed in block for inclusion in test cases.
  #
  #   share "User" do
  #     it "should authenticate" do
  #       "me".should == "me"
  #     end
  #   end
  #   
  #   describe "User, in general" do
  #     shared_specs_for 'User'
  #   end
  #   
  #   describe "User, in another case" do
  #     shared_specs_for 'User'
  #   end
  #
  #   2 tests, 2 assertions, 0 failures, 0 errors
  def share(name, &specs_block)
    $shared_specs[name] = specs_block
  end
end

module SharedSpecsInclusionHelper
  # Include the specified shared specs in this test case.
  #
  #   share "User" do
  #     it "should authenticate" do
  #       "me".should == "me"
  #     end
  #   end
  #   
  #   describe "User, in general" do
  #     shared_specs_for 'User'
  #   end
  #   
  #   describe "User, in another case" do
  #     shared_specs_for 'User'
  #   end
  #
  #   2 tests, 2 assertions, 0 failures, 0 errors
  def shared_specs_for(name)
    self.class_eval &$shared_specs[name]
  end
end
Test::Unit::TestCase.send(:extend, SharedSpecsInclusionHelper)

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
Fingertips-on-test-spec-0.1.2 lib/test/spec/share.rb
Fingertips-on-test-spec-0.2.0 lib/test/spec/share.rb
Fingertips-on-test-spec-0.2.1 lib/test/spec/share.rb
Fingertips-on-test-spec-0.2.2 lib/test/spec/share.rb
Fingertips-on-test-spec-0.2.3 lib/test/spec/share.rb
seamusabshere-on_test_spec-1.0.1 lib/test/spec/share.rb
seamusabshere-on_test_spec-1.0.2 lib/test/spec/share.rb
seamusabshere-on_test_spec-1.0.3 lib/test/spec/share.rb
on-test-spec-0.2.6 lib/test/spec/share.rb
on-test-spec-0.2.5 lib/test/spec/share.rb
on-test-spec-0.2.4 lib/test/spec/share.rb