-
-
Save cee-dub/623589 to your computer and use it in GitHub Desktop.
Revisions
-
cee-dub revised this gist
Oct 19, 2010 . 1 changed file with 8 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,10 @@ def should_be_a_subset(superset, records_selected_by_scope, &condition) flunk "Your superset is empty" if superset.empty? flunk "Your scope did not select any records" if records_selected_by_scope.empty? records_selected_by_block, records_excluded_by_block = superset.partition(&condition) flunk "Your test condition did not select any records" if records_selected_by_block.empty? flunk "Your test condition did not exclude any records" if records_excluded_by_block.empty? records_selected_by_scope.map(&:id).should =~ records_selected_by_block.map(&:id) end -
cee-dub revised this gist
Oct 13, 2010 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,11 @@ def should_be_a_subset(all_objects, constrained_scope, &condition) flunk "Your superset is empty" if all_objects.empty? flunk "Your constrained set is empty" if constrained_scope.empty? selected_objects, excluded_objects = all_objects.partition(&condition) flunk "Your test condition did not select any items" if selected_objects.empty? flunk "Your test condition did not exclude any items" if excluded_objects.empty? constrained_scope.map(&:id).sort.should == selected_objects.map(&:id).sort (all_objects.map(&:id) - constrained_scope.map(&:id)).sort.should == excluded_objects.map(&:id).sort end -
cee-dub revised this gist
Oct 13, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,5 +8,5 @@ def should_be_a_subset(all_objects, constrained_scope, &condition) constrained_scope.map(&:id).sort.should == objects_for_which_condition_is_true.map(&:id).sort (all_objects.map(&:id) - constrained_scope.map(&:id)).sort.should == objects_for_which_condition_is_false.map(&:id).sort end -
cee-dub renamed this gist
Oct 13, 2010 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,8 @@ def should_be_a_subset(all_objects, constrained_scope, &condition) flunk "Your constrained set is empty" if constrained_scope.empty? objects_for_which_condition_is_true, objects_for_which_condition_is_false = all_objects.partition(&condition) flunk "Your test condition did not select any items" if objects_for_which_condition_is_true.empty? flunk "Your test condition did not exclude any items" if objects_for_which_condition_is_false.empty? constrained_scope.map(&:id).sort.should == objects_for_which_condition_is_true.map(&:id).sort -
zbrock revised this gist
Oct 7, 2010 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,5 +9,4 @@ def should_be_a_subset(all_objects, constrained_scope, &condition) constrained_scope.map(&:id).sort.should == objects_for_which_condition_is_true.map(&:id).sort (all_objects.map(&:id) - constrained_scope.map(&:id)).should == objects_for_which_condition_is_false.map(&:id) end -
zbrock created this gist
Oct 7, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ def should_be_a_subset(all_objects, constrained_scope, &condition) flunk "Your superset is empty" if all_objects.empty? flunk "Your constrained set is empty" if constrained_scope.empty? objects_for_which_condition_is_true, objects_for_which_condition_is_false = all_objects.partition(&condition) objects_for_which_condition_is_true.should_not be_empty objects_for_which_condition_is_false.should_not be_empty constrained_scope.map(&:id).sort.should == objects_for_which_condition_is_true.map(&:id).sort (all_objects.map(&:id) - constrained_scope.map(&:id)).should == objects_for_which_condition_is_false.map(&:id) (all_objects - constrained_scope).should == objects_for_which_condition_is_false end