-
-
Save dchelimsky/98041 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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