Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created November 29, 2011 00:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dnagir/1402753 to your computer and use it in GitHub Desktop.
jRuby and RSpec shared examples issue
shared_examples_for "weird" do |options={}|
# Uncomment to make it work in jruby
#options = {} unless options.respond_to? :to_hash
it "should be a hash" do
options.should be_a Hash
end
end
describe "shared example issue" do
it_behaves_like "weird", {}
it_behaves_like "weird" # here, the options is an RSpec example class
end
> rvm use 1.9.3 && rspec sample_spec.rb
Using /Users/dnagir/.rvm/gems/ruby-1.9.3-p0
..
Finished in 0.3487 seconds
2 examples, 0 failures
> echo $JRUBY_OPTS
--1.9
> rvm use jruby && rspec sample_spec.rb
Using /Users/dnagir/.rvm/gems/jruby-1.6.5
.F
Failures:
1) shared example issue behaves like weird should be a hash
Failure/Error: options.should be_a Hash
expected #<Class:0x728edb84>::Nested_2 to be a kind of Hash
Shared Example Group: "weird" called from ./sample_spec.rb:14
# ./sample_spec.rb:7:in `(root)'
Finished in 0.843 seconds
2 examples, 1 failure
Failed examples:
rspec ./sample_spec.rb:6 # shared example issue behaves like weird should be a hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment