Permalink
Browse files

Change shared example with filter to be a SharedContext for rspec 2.3

  in rspec 2.3, it looks like shared example groups will not allow
  you to specify before filters that descend down to children, only
  to specify examples.  Rather, we need to create a SharedContext module
  and include it in the example groups.

  @todo refactor after 'deterministic' migration is done
  • Loading branch information...
1 parent df9a998 commit eacbdbefd3cc849a8cf90938a182d2bc8e0c43dc @hipe hipe committed Dec 15, 2010
Showing with 20 additions and 2 deletions.
  1. +20 −2 spec/runtime/interval_skip_list/spec_helper.rb
@@ -4,13 +4,31 @@ class IntervalSkipList
public :insert_node, :delete_node, :nodes, :head, :next_node_height
end
-shared_examples_for "#next_node_height is deterministic" do
- before do
+module NextNodeHeightIsDeterministicSharedContext
+ extend RSpec::Core::SharedContext
+
+ before :each do
+ next_node_height_is_deterministic
+ end
+
+ # we might call this explicitly in some filters? @todo refactor if we don't
+ def next_node_height_is_deterministic
node_heights = expected_node_heights.dup
stub(list).next_node_height { node_heights.shift }
end
end
+shared_examples_for "#next_node_height is deterministic" do
+ # this is kept here so as not to get fatal error on unmigrated tests
+ # but it is being phased out for the above SharedContext because
+ # shared examples apparently cannot have inheiritable before filters
+
+ # before do
+ # node_heights = expected_node_heights.dup
+ # stub(list).next_node_height { node_heights.shift }
+ # end
+end
+
module IntervalSkipListSpecHelper
def contain_marker(marker)
ContainMarkers.new(list, [marker])

0 comments on commit eacbdbe

Please sign in to comment.