From 48e5fc96909a06bca3c2737d2505185ae120759a Mon Sep 17 00:00:00 2001 From: Mark Meves Date: Wed, 15 Dec 2010 04:42:18 -0500 Subject: [PATCH] Refactor palindromic shared context to work with rspec2.3 Make a temporary, more focused 'palindromic2' tag (@todo temporary) (26 examples, 0 failures) (Run filtered using {:palindromic2=>true}) @smell is it clear enough what is going on? can it be cleaned up? --- .../interval_skip_list/palindromic_fixture.rb | 42 +++++++++++++------ .../palindromic_fixture_spec.rb | 3 +- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/spec/runtime/interval_skip_list/palindromic_fixture.rb b/spec/runtime/interval_skip_list/palindromic_fixture.rb index 02a03c6..aaf4a39 100644 --- a/spec/runtime/interval_skip_list/palindromic_fixture.rb +++ b/spec/runtime/interval_skip_list/palindromic_fixture.rb @@ -1,23 +1,39 @@ -shared_examples_for "the palindromic fixture" do - attr_reader :list, :node +module PalindromicFixtureSharedContext + extend RSpec::Core::SharedContext include IntervalSkipListSpecHelper - before do + attr_reader :list, :node + + def construct_interval_skip_list @list = IntervalSkipList.new end - it_should_behave_like "#next_node_height is deterministic" def expected_node_heights [3, 2, 1, 3, 1, 2, 3] end - before do - list.insert(1..3, :a) - list.insert(1..5, :b) - list.insert(1..7, :c) - list.insert(1..9, :d) - list.insert(1..11, :e) - list.insert(1..13, :f) - list.insert(5..13, :g) + def populate_interval_skip_list + @list.insert(1..3, :a) + @list.insert(1..5, :b) + @list.insert(1..7, :c) + @list.insert(1..9, :d) + @list.insert(1..11, :e) + @list.insert(1..13, :f) + @list.insert(5..13, :g) + end + + def make_it_determinisitic + extend NextNodeHeightIsDeterministicSharedContext # use the method without getting the filter + next_node_height_is_deterministic + end + + before :each do + construct_interval_skip_list + make_it_determinisitic + populate_interval_skip_list end -end \ No newline at end of file +end + +shared_examples_for "the palindromic fixture" do + # @todo needs cleanup! +end diff --git a/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb b/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb index 719ae24..95124a1 100644 --- a/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +++ b/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb @@ -1,7 +1,8 @@ require 'runtime/interval_skip_list/spec_helper' -describe "The palindromic fixture", :palindromic => true do +describe "The palindromic fixture", :palindromic2 => true do it_should_behave_like "the palindromic fixture" + include PalindromicFixtureSharedContext describe " #nodes" do describe "[0]" do