Created
August 20, 2010 05:03
-
-
Save myronmarston/539649 to your computer and use it in GitHub Desktop.
This file contains 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 'rspec' | |
shared_examples_for :a_foo do |supported_features| | |
it 'responds to #to_s' do | |
subject.should respond_to(:to_s) | |
end | |
it 'responds to #bar' do | |
subject.should respond_to(:bar) | |
end if supported_features.include?(:bar) | |
it 'responds to #bazz' do | |
subject.should respond_to(:bazz) | |
end if supported_features.include?(:bazz) | |
end | |
class Foo1 | |
def bar; 'bar!'; end | |
end | |
class Foo2 | |
def bar; 'bar!'; end | |
def bazz; 'bazz!'; end | |
end | |
describe Foo1 do | |
it_should_behave_like :a_foo, [:bar] | |
end | |
describe Foo2 do | |
it_should_behave_like :a_foo, [:bar, :bazz] | |
end |
This file contains 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
ruby-1.8.6-p399 ➜ code ruby rspec_example.rb | |
Finished in 0.00008 seconds | |
0 examples, 0 failures | |
rspec_example.rb:11:in `include?': wrong argument type Symbol (expected Module) (TypeError) | |
from rspec_example.rb:11 | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/module_eval_with_args.rb:45:in `class_eval' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/module_eval_with_args.rb:45:in `extract_static_instance_method_defs_from' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/module_eval_with_args.rb:36:in `initialize' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/module_eval_with_args.rb:36:in `new' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/module_eval_with_args.rb:36:in `extract_static_instance_method_defs_from' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/module_eval_with_args.rb:27:in `module_eval_with_args' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/example_group.rb:70:in `it_should_behave_like' | |
... 6 levels... | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/example_group.rb:129:in `subclass' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/example_group.rb:116:in `describe' | |
from /Users/mmarston/.rvm/gems/ruby-1.8.6-p399/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/extensions/object.rb:7:in `describe' | |
from rspec_example.rb:27 |
This file contains 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
ruby-1.8.7-p299 ➜ code ruby rspec_example.rb | |
..... | |
Finished in 0.00335 seconds | |
5 examples, 0 failures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment