Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Forked from patmaddox/custom_example_group.rb
Created April 19, 2009 11:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchelimsky/98041 to your computer and use it in GitHub Desktop.
Save dchelimsky/98041 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spec'
class MyExampleGroup < Spec::ExampleGroup
before(:each) do
puts "in before(:each)"
my_custom_method
end
class << self
# available in groups
def custom_example_group_method
puts "hello from a custom example group class"
end
end
# available in examples
def custom_example_method
puts "hello from a custom example group instance"
end
Spec::Example::ExampleGroupFactory.register :mine, self
end
describe "custom example group", :type => :mine do
custom_example_group_method
it "provides access to instance methods" do
custom_example_method
end
end
require 'rubygems'
require 'spec'
module Spec
module Matchers
def equal_my_foo
Matcher.new :equal_my_foo, @foo do |expected|
match do |actual|
actual.should == expected
end
end
end
end
end
describe "matcher" do
it "should have access to an instance variable" do
@foo = :bar
:bar.should equal_my_foo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment