Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change ClientMock to prepare_nested_set_data method helper

  • Loading branch information...
commit 14c9e87a8b0233798480980d69cb2ef7b66dd610 1 parent 70480dc
Paweł Kondzior authored
Showing with 11 additions and 13 deletions.
  1. +2 −2 spec/nested_set_spec.rb
  2. +9 −11 spec/spec_helper.rb
View
4 spec/nested_set_spec.rb
@@ -2,7 +2,7 @@
describe "Sequel Nested Set Class" do
before(:each) do
- ClientMock.reset
+ prepare_nested_set_data
@root = Client.filter(:name => 'Top Level').first
@node1 = Client.filter(:name => 'Child 1').first
@node2 = Client.filter(:name => 'Child 2').first
@@ -53,7 +53,7 @@
describe "Sequel Nested Set Instance" do
before(:each) do
- ClientMock.reset
+ prepare_nested_set_data
@root = Client.filter(:name => 'Top Level').first
@node1 = Client.filter(:name => 'Child 1').first
@node2 = Client.filter(:name => 'Child 2').first
View
20 spec/spec_helper.rb
@@ -22,17 +22,15 @@ class Client < Sequel::Model
Client.create_table
-class ClientMock
- def self.reset
- Client.drop_table if Client.table_exists?
- Client.create_table!
- DB[:clients] << {"name"=>"Top Level 2", "lft"=>11, "id"=>6, "rgt"=>12}
- DB[:clients] << {"name"=>"Child 2.1", "lft"=>5, "id"=>4, "parent_id"=>3, "rgt"=>6}
- DB[:clients] << {"name"=>"Child 1", "lft"=>2, "id"=>2, "parent_id"=>1, "rgt"=>3}
- DB[:clients] << {"name"=>"Top Level", "lft"=>1, "id"=>1, "rgt"=>10}
- DB[:clients] << {"name"=>"Child 2", "lft"=>4, "id"=>3, "parent_id"=>1, "rgt"=>7}
- DB[:clients] << {"name"=>"Child 3", "lft"=>8, "id"=>5, "parent_id"=>1, "rgt"=>9}
- end
+def prepare_nested_set_data
+ Client.drop_table if Client.table_exists?
+ Client.create_table!
+ DB[:clients] << {"name"=>"Top Level 2", "lft"=>11, "id"=>6, "rgt"=>12}
+ DB[:clients] << {"name"=>"Child 2.1", "lft"=>5, "id"=>4, "parent_id"=>3, "rgt"=>6}
+ DB[:clients] << {"name"=>"Child 1", "lft"=>2, "id"=>2, "parent_id"=>1, "rgt"=>3}
+ DB[:clients] << {"name"=>"Top Level", "lft"=>1, "id"=>1, "rgt"=>10}
+ DB[:clients] << {"name"=>"Child 2", "lft"=>4, "id"=>3, "parent_id"=>1, "rgt"=>7}
+ DB[:clients] << {"name"=>"Child 3", "lft"=>8, "id"=>5, "parent_id"=>1, "rgt"=>9}
end
Please sign in to comment.
Something went wrong with that request. Please try again.