attr_similar 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/attr_similar.rb CHANGED
@@ -5,24 +5,14 @@ module AttrSimilar
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  module ClassMethods
8
- def attr_similar(attributes)
9
- self.similar_attributes = attributes
8
+ def attr_similar(threshold_or_thresholds, *attributes)
9
+ if threshold_or_thresholds.is_a?(Array) && threshold_or_thresholds.size != attributes.size
10
+ raise 'Threshold count must equal number of attributes'
11
+ end
12
+ define_method :find_first_similar do |scope|
13
+ AttrSimilar::SimilarityMatching.find_first_similar(scope, self, threshold_or_thresholds, attributes)
14
+ end
10
15
  end
11
-
12
- def similar_attributes
13
- @@similar_attributes ||= []
14
- end
15
-
16
- def similar_attributes=(value)
17
- @@similar_attributes = value
18
- end
19
- end
20
-
21
- included do
22
- end
23
-
24
- def sample_method
25
- AttrSimilar::SimilarityMatching.sample_method(self.class.similar_attributes)
26
16
  end
27
17
  end
28
18
 
@@ -1,7 +1,50 @@
1
1
  module AttrSimilar
2
2
  module SimilarityMatching
3
- def self.sample_method(value)
4
- value
3
+ def self.find_first_similar(scope, entity, threshold_or_thresholds, attributes)
4
+ # Only consider attributes on entity with non-blank values
5
+ filtered_attributes = attributes.select { |attribute| !entity.send(attribute).blank? }
6
+ return nil if filtered_attributes.size == 0
7
+
8
+ # Use single threshold or threshold determined by number of filtered attributes
9
+ threshold = if threshold_or_thresholds.is_a?(Array)
10
+ threshold_or_thresholds[filtered_attributes.size - 1]
11
+ else
12
+ threshold_or_thresholds
13
+ end
14
+
15
+ scope = scope.where('id != ?', entity.id) if entity.id
16
+
17
+ # Build up per-attribute entity lists and candidate entity list
18
+ per_attribute_entity_lists, candidate_entities = filtered_attributes.inject([[], []]) do |memo, attribute|
19
+ entities = scope.where(attribute => entity.send(attribute))
20
+ if entities.size > 0
21
+ memo[0].concat([entities]) # Add to per_attribute_entity_lists
22
+ memo[1].concat(entities) # Add to candidate_entities
23
+ end
24
+ memo
25
+ end
26
+
27
+ # No similar entities if count of per-attribute entity lists is below threshold
28
+ return nil if per_attribute_entity_lists.size < threshold
29
+
30
+ per_attribute_entity_id_lists = per_attribute_entity_lists.map { |list| list.map(&:id) }
31
+
32
+ candidate_entity_map = candidate_entities.inject({}) do |map, candidate_entity|
33
+ map[candidate_entity.id] = candidate_entity
34
+ map
35
+ end
36
+ candidate_entity_ids = candidate_entity_map.keys
37
+
38
+ # Find entities that are in at least "threshold" lists
39
+ candidate_entity_ids.each do |candidate_entity_id|
40
+ count = per_attribute_entity_id_lists.reduce(0) do |count, list|
41
+ count += list.include?(candidate_entity_id) ? 1 : 0
42
+ end
43
+ return candidate_entity_map[candidate_entity_id] if count >= threshold
44
+ end
45
+
46
+ # No similar entities
47
+ nil
5
48
  end
6
49
  end
7
50
  end
@@ -1,4 +1,4 @@
1
1
  module AttrSimilar
2
- VERSION = '0.0.0'
2
+ VERSION = '0.0.1'
3
3
  end
4
4
 
@@ -1,8 +1,24 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class AttrSimilarTest < ActiveSupport::TestCase
4
- test 'foo' do
5
- assert_equal [1, 2, 3], Manufacturer.new.sample_method
4
+ test 'find_first_similar' do
5
+ w1 = create(
6
+ :widget,
7
+ :address => 'address',
8
+ :birthdate => '1970-01-01',
9
+ :first_name => 'first-name',
10
+ :last_name => 'last-name',
11
+ :preferred_name => 'preferred_name'
12
+ )
13
+ w2 = build(
14
+ :widget,
15
+ :address => 'address',
16
+ :birthdate => '1970-01-01',
17
+ :first_name => 'first-name',
18
+ :last_name => 'last-name',
19
+ :preferred_name => 'preferred_name'
20
+ )
21
+ assert_equal w1, w2.find_first_similar(Widget)
6
22
  end
7
23
  end
8
24
 
@@ -1,4 +1,3 @@
1
1
  class Manufacturer < ActiveRecord::Base
2
- attr_similar [1, 2, 3]
3
2
  end
4
3
 
@@ -1,3 +1,15 @@
1
1
  class Widget < ActiveRecord::Base
2
+ attr_accessible :address,
3
+ :birthdate,
4
+ :first_name,
5
+ :last_name,
6
+ :preferred_name
7
+
8
+ attr_similar [1, 2, 2, 3, 3],
9
+ :address,
10
+ :birthdate,
11
+ :first_name,
12
+ :last_name,
13
+ :preferred_name
2
14
  end
3
15
 
@@ -5,6 +5,9 @@ default: &default
5
5
  timeout: 5000
6
6
  host: localhost
7
7
 
8
+ development:
9
+ <<: *default
10
+
8
11
  test:
9
12
  <<: *default
10
13
 
Binary file
@@ -1,8 +1,11 @@
1
1
  class CreateWidgets < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :widgets do |t|
4
- t.belongs_to :manufacturer
5
- t.string :name
4
+ t.string :address
5
+ t.date :birthdate
6
+ t.string :first_name
7
+ t.string :last_name
8
+ t.string :preferred_name
6
9
 
7
10
  t.timestamps
8
11
  end
@@ -19,10 +19,13 @@ ActiveRecord::Schema.define(:version => 20131027192834) do
19
19
  end
20
20
 
21
21
  create_table "widgets", :force => true do |t|
22
- t.integer "manufacturer_id"
23
- t.string "name"
24
- t.datetime "created_at", :null => false
25
- t.datetime "updated_at", :null => false
22
+ t.string "address"
23
+ t.date "birthdate"
24
+ t.string "first_name"
25
+ t.string "last_name"
26
+ t.string "preferred_name"
27
+ t.datetime "created_at", :null => false
28
+ t.datetime "updated_at", :null => false
26
29
  end
27
30
 
28
31
  end
Binary file
@@ -0,0 +1,27 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+  (30.5ms) select sqlite_version(*)
4
+  (174.8ms) CREATE TABLE "manufacturers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
5
+  (187.1ms) CREATE TABLE "widgets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "manufacturer_id" integer, "name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
6
+  (199.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
7
+  (144.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
8
+  (0.1ms) SELECT version FROM "schema_migrations"
9
+  (187.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192834')
10
+  (166.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192625')
11
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
12
+ Connecting to database specified by database.yml
13
+  (0.1ms) select sqlite_version(*)
14
+  (148.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
15
+  (144.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
16
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
17
+ Migrating to CreateManufacturers (20131027192625)
18
+  (0.1ms) begin transaction
19
+  (0.9ms) CREATE TABLE "manufacturers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
20
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20131027192625')
21
+  (170.6ms) commit transaction
22
+ Migrating to CreateWidgets (20131027192834)
23
+  (0.1ms) begin transaction
24
+  (0.9ms) CREATE TABLE "widgets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "address" varchar(255), "birthdate" date, "first_name" varchar(255), "last_name" varchar(255), "preferred_name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
25
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20131027192834')
26
+  (161.1ms) commit transaction
27
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
@@ -476,3 +476,489 @@ Connecting to database specified by database.yml
476
476
   (0.0ms) rollback transaction
477
477
   (0.0ms) begin transaction
478
478
   (0.0ms) rollback transaction
479
+ Connecting to database specified by database.yml
480
+  (0.5ms) begin transaction
481
+  (0.1ms) rollback transaction
482
+  (0.1ms) begin transaction
483
+  (0.0ms) rollback transaction
484
+  (0.0ms) begin transaction
485
+  (0.1ms) rollback transaction
486
+  (0.0ms) begin transaction
487
+  (0.0ms) rollback transaction
488
+ Connecting to database specified by database.yml
489
+  (0.5ms) begin transaction
490
+  (0.1ms) rollback transaction
491
+  (0.1ms) begin transaction
492
+  (0.0ms) rollback transaction
493
+  (0.0ms) begin transaction
494
+  (0.0ms) rollback transaction
495
+  (0.0ms) begin transaction
496
+  (0.0ms) rollback transaction
497
+ Connecting to database specified by database.yml
498
+  (0.6ms) begin transaction
499
+  (0.2ms) rollback transaction
500
+  (0.1ms) begin transaction
501
+  (0.1ms) rollback transaction
502
+  (0.0ms) begin transaction
503
+  (0.0ms) rollback transaction
504
+ Connecting to database specified by database.yml
505
+  (0.5ms) begin transaction
506
+  (0.1ms) rollback transaction
507
+  (0.1ms) begin transaction
508
+  (0.1ms) rollback transaction
509
+  (0.0ms) begin transaction
510
+  (0.0ms) rollback transaction
511
+ Connecting to database specified by database.yml
512
+  (0.5ms) begin transaction
513
+  (0.1ms) rollback transaction
514
+  (0.1ms) begin transaction
515
+  (0.1ms) rollback transaction
516
+  (0.0ms) begin transaction
517
+  (0.0ms) rollback transaction
518
+ Connecting to database specified by database.yml
519
+  (0.5ms) begin transaction
520
+  (0.1ms) rollback transaction
521
+  (0.1ms) begin transaction
522
+  (0.1ms) rollback transaction
523
+  (0.0ms) begin transaction
524
+  (0.0ms) rollback transaction
525
+ Connecting to database specified by database.yml
526
+  (0.4ms) begin transaction
527
+  (0.1ms) rollback transaction
528
+  (0.1ms) begin transaction
529
+  (0.1ms) rollback transaction
530
+  (0.1ms) begin transaction
531
+  (0.0ms) rollback transaction
532
+  (0.0ms) begin transaction
533
+  (0.0ms) rollback transaction
534
+ Connecting to database specified by database.yml
535
+  (0.5ms) begin transaction
536
+  (0.1ms) rollback transaction
537
+  (0.1ms) begin transaction
538
+  (0.0ms) rollback transaction
539
+  (0.0ms) begin transaction
540
+  (0.0ms) rollback transaction
541
+  (0.0ms) begin transaction
542
+  (0.0ms) rollback transaction
543
+ Connecting to database specified by database.yml
544
+  (0.5ms) begin transaction
545
+  (0.1ms) rollback transaction
546
+  (0.1ms) begin transaction
547
+  (0.1ms) rollback transaction
548
+  (0.0ms) begin transaction
549
+  (0.0ms) rollback transaction
550
+  (0.0ms) begin transaction
551
+  (0.0ms) rollback transaction
552
+ Connecting to database specified by database.yml
553
+  (0.5ms) begin transaction
554
+  (0.1ms) rollback transaction
555
+  (0.1ms) begin transaction
556
+  (0.1ms) rollback transaction
557
+  (0.1ms) begin transaction
558
+  (0.0ms) rollback transaction
559
+  (0.0ms) begin transaction
560
+  (0.0ms) rollback transaction
561
+ Connecting to database specified by database.yml
562
+  (0.5ms) begin transaction
563
+  (0.1ms) rollback transaction
564
+  (0.1ms) begin transaction
565
+  (0.1ms) rollback transaction
566
+  (0.0ms) begin transaction
567
+  (0.0ms) rollback transaction
568
+  (0.0ms) begin transaction
569
+  (0.0ms) rollback transaction
570
+ Connecting to database specified by database.yml
571
+  (0.5ms) begin transaction
572
+  (0.1ms) rollback transaction
573
+ Connecting to database specified by database.yml
574
+  (0.5ms) begin transaction
575
+  (0.1ms) rollback transaction
576
+ Connecting to database specified by database.yml
577
+ Connecting to database specified by database.yml
578
+ Connecting to database specified by database.yml
579
+  (0.5ms) begin transaction
580
+  (0.1ms) rollback transaction
581
+  (0.1ms) begin transaction
582
+  (0.0ms) rollback transaction
583
+  (0.0ms) begin transaction
584
+  (0.0ms) rollback transaction
585
+  (0.0ms) begin transaction
586
+  (0.0ms) rollback transaction
587
+  (0.0ms) begin transaction
588
+  (0.0ms) rollback transaction
589
+  (0.0ms) begin transaction
590
+  (0.0ms) rollback transaction
591
+  (0.0ms) begin transaction
592
+  (0.0ms) rollback transaction
593
+  (0.0ms) begin transaction
594
+  (0.1ms) rollback transaction
595
+  (0.1ms) begin transaction
596
+  (0.1ms) rollback transaction
597
+  (0.1ms) begin transaction
598
+  (0.1ms) rollback transaction
599
+  (0.1ms) begin transaction
600
+  (0.0ms) rollback transaction
601
+  (0.0ms) begin transaction
602
+  (0.1ms) rollback transaction
603
+  (0.1ms) begin transaction
604
+  (0.0ms) rollback transaction
605
+  (0.0ms) begin transaction
606
+  (0.0ms) rollback transaction
607
+ Connecting to database specified by database.yml
608
+  (0.5ms) begin transaction
609
+  (0.1ms) rollback transaction
610
+  (0.1ms) begin transaction
611
+  (0.0ms) rollback transaction
612
+  (0.0ms) begin transaction
613
+  (0.0ms) rollback transaction
614
+  (0.0ms) begin transaction
615
+  (0.0ms) rollback transaction
616
+  (0.0ms) begin transaction
617
+  (0.0ms) rollback transaction
618
+  (0.0ms) begin transaction
619
+  (0.0ms) rollback transaction
620
+  (0.0ms) begin transaction
621
+  (0.0ms) rollback transaction
622
+  (0.0ms) begin transaction
623
+  (0.1ms) SAVEPOINT active_record_1
624
+ SQL (5.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
625
+  (0.1ms) RELEASE SAVEPOINT active_record_1
626
+  (0.2ms) rollback transaction
627
+  (0.0ms) begin transaction
628
+  (0.0ms) SAVEPOINT active_record_1
629
+ SQL (0.7ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
630
+  (0.1ms) RELEASE SAVEPOINT active_record_1
631
+  (0.0ms) SAVEPOINT active_record_1
632
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
633
+  (0.0ms) RELEASE SAVEPOINT active_record_1
634
+  (0.2ms) rollback transaction
635
+  (0.0ms) begin transaction
636
+  (0.0ms) SAVEPOINT active_record_1
637
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
638
+  (0.0ms) RELEASE SAVEPOINT active_record_1
639
+  (0.0ms) SAVEPOINT active_record_1
640
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
641
+  (0.0ms) RELEASE SAVEPOINT active_record_1
642
+  (0.2ms) rollback transaction
643
+  (0.0ms) begin transaction
644
+  (0.0ms) rollback transaction
645
+  (0.0ms) begin transaction
646
+  (0.0ms) SAVEPOINT active_record_1
647
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
648
+  (0.1ms) RELEASE SAVEPOINT active_record_1
649
+  (0.1ms) rollback transaction
650
+  (0.0ms) begin transaction
651
+  (0.0ms) SAVEPOINT active_record_1
652
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
653
+  (0.1ms) RELEASE SAVEPOINT active_record_1
654
+  (0.1ms) rollback transaction
655
+  (0.0ms) begin transaction
656
+  (0.0ms) SAVEPOINT active_record_1
657
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:47:54 UTC +00:00]]
658
+  (0.0ms) RELEASE SAVEPOINT active_record_1
659
+  (0.1ms) rollback transaction
660
+ Connecting to database specified by database.yml
661
+ Connecting to database specified by database.yml
662
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
663
+ Migrating to CreateManufacturers (20131027192625)
664
+ Migrating to CreateWidgets (20131027192834)
665
+  (0.2ms) select sqlite_version(*)
666
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
667
+ Connecting to database specified by database.yml
668
+  (1.5ms) select sqlite_version(*)
669
+  (170.8ms) CREATE TABLE "manufacturers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
670
+  (164.7ms) CREATE TABLE "widgets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "manufacturer_id" integer, "name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
671
+  (166.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
672
+  (155.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
673
+  (0.1ms) SELECT version FROM "schema_migrations"
674
+  (188.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192834')
675
+  (177.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192625')
676
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
677
+ Connecting to database specified by database.yml
678
+ Connecting to database specified by database.yml
679
+ Connecting to database specified by database.yml
680
+ Connecting to database specified by database.yml
681
+ Connecting to database specified by database.yml
682
+  (0.5ms) begin transaction
683
+  (0.1ms) rollback transaction
684
+  (0.1ms) begin transaction
685
+  (0.0ms) rollback transaction
686
+  (0.0ms) begin transaction
687
+  (0.0ms) rollback transaction
688
+  (0.0ms) begin transaction
689
+  (0.0ms) rollback transaction
690
+  (0.0ms) begin transaction
691
+  (0.0ms) rollback transaction
692
+  (0.0ms) begin transaction
693
+  (0.0ms) rollback transaction
694
+  (0.0ms) begin transaction
695
+  (0.0ms) rollback transaction
696
+  (0.0ms) begin transaction
697
+  (0.1ms) SAVEPOINT active_record_1
698
+ SQL (5.0ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
699
+  (0.1ms) RELEASE SAVEPOINT active_record_1
700
+  (0.1ms) rollback transaction
701
+  (0.0ms) begin transaction
702
+  (0.0ms) SAVEPOINT active_record_1
703
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
704
+  (0.0ms) RELEASE SAVEPOINT active_record_1
705
+  (0.0ms) SAVEPOINT active_record_1
706
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
707
+  (0.0ms) RELEASE SAVEPOINT active_record_1
708
+  (0.2ms) rollback transaction
709
+  (0.0ms) begin transaction
710
+  (0.0ms) SAVEPOINT active_record_1
711
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
712
+  (0.0ms) RELEASE SAVEPOINT active_record_1
713
+  (0.0ms) SAVEPOINT active_record_1
714
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
715
+  (0.0ms) RELEASE SAVEPOINT active_record_1
716
+  (0.1ms) rollback transaction
717
+  (0.0ms) begin transaction
718
+  (0.1ms) rollback transaction
719
+  (0.1ms) begin transaction
720
+  (0.0ms) SAVEPOINT active_record_1
721
+ SQL (0.7ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
722
+  (0.1ms) RELEASE SAVEPOINT active_record_1
723
+  (0.1ms) rollback transaction
724
+  (0.0ms) begin transaction
725
+  (0.0ms) SAVEPOINT active_record_1
726
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
727
+  (0.1ms) RELEASE SAVEPOINT active_record_1
728
+  (0.1ms) rollback transaction
729
+  (0.0ms) begin transaction
730
+  (0.0ms) SAVEPOINT active_record_1
731
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 20:59:17 UTC +00:00]]
732
+  (0.0ms) RELEASE SAVEPOINT active_record_1
733
+  (0.1ms) rollback transaction
734
+ Connecting to database specified by database.yml
735
+  (0.5ms) begin transaction
736
+  (0.1ms) rollback transaction
737
+  (0.1ms) begin transaction
738
+  (0.0ms) rollback transaction
739
+  (0.0ms) begin transaction
740
+  (0.0ms) rollback transaction
741
+  (0.0ms) begin transaction
742
+  (0.0ms) rollback transaction
743
+  (0.0ms) begin transaction
744
+  (0.0ms) rollback transaction
745
+  (0.0ms) begin transaction
746
+  (0.0ms) rollback transaction
747
+  (0.0ms) begin transaction
748
+  (0.1ms) rollback transaction
749
+  (0.1ms) begin transaction
750
+  (0.1ms) SAVEPOINT active_record_1
751
+ SQL (40.7ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:54 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:54 UTC +00:00]]
752
+  (0.1ms) RELEASE SAVEPOINT active_record_1
753
+  (0.1ms) rollback transaction
754
+  (0.0ms) begin transaction
755
+  (0.0ms) SAVEPOINT active_record_1
756
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
757
+  (0.1ms) RELEASE SAVEPOINT active_record_1
758
+  (0.0ms) SAVEPOINT active_record_1
759
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
760
+  (0.0ms) RELEASE SAVEPOINT active_record_1
761
+  (0.2ms) rollback transaction
762
+  (0.0ms) begin transaction
763
+  (0.0ms) SAVEPOINT active_record_1
764
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
765
+  (0.1ms) RELEASE SAVEPOINT active_record_1
766
+  (0.0ms) SAVEPOINT active_record_1
767
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
768
+  (0.0ms) RELEASE SAVEPOINT active_record_1
769
+  (0.1ms) rollback transaction
770
+  (0.0ms) begin transaction
771
+  (0.1ms) rollback transaction
772
+  (0.1ms) begin transaction
773
+  (0.0ms) SAVEPOINT active_record_1
774
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
775
+  (0.1ms) RELEASE SAVEPOINT active_record_1
776
+  (0.1ms) rollback transaction
777
+  (0.0ms) begin transaction
778
+  (0.0ms) SAVEPOINT active_record_1
779
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
780
+  (0.0ms) RELEASE SAVEPOINT active_record_1
781
+  (0.1ms) rollback transaction
782
+  (0.0ms) begin transaction
783
+  (0.0ms) SAVEPOINT active_record_1
784
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:00:55 UTC +00:00]]
785
+  (0.0ms) RELEASE SAVEPOINT active_record_1
786
+  (0.1ms) rollback transaction
787
+ Connecting to database specified by database.yml
788
+  (0.5ms) begin transaction
789
+  (0.1ms) rollback transaction
790
+  (0.1ms) begin transaction
791
+  (0.0ms) rollback transaction
792
+  (0.0ms) begin transaction
793
+  (0.0ms) rollback transaction
794
+  (0.0ms) begin transaction
795
+  (0.0ms) rollback transaction
796
+  (0.0ms) begin transaction
797
+  (0.0ms) rollback transaction
798
+  (0.0ms) begin transaction
799
+  (0.0ms) rollback transaction
800
+  (0.0ms) begin transaction
801
+  (0.0ms) rollback transaction
802
+  (0.0ms) begin transaction
803
+  (0.1ms) SAVEPOINT active_record_1
804
+ SQL (40.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
805
+  (0.1ms) RELEASE SAVEPOINT active_record_1
806
+  (0.2ms) rollback transaction
807
+  (0.0ms) begin transaction
808
+  (0.0ms) SAVEPOINT active_record_1
809
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
810
+  (0.1ms) RELEASE SAVEPOINT active_record_1
811
+  (0.0ms) SAVEPOINT active_record_1
812
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
813
+  (0.0ms) RELEASE SAVEPOINT active_record_1
814
+  (0.2ms) rollback transaction
815
+  (0.0ms) begin transaction
816
+  (0.0ms) SAVEPOINT active_record_1
817
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
818
+  (0.0ms) RELEASE SAVEPOINT active_record_1
819
+  (0.0ms) SAVEPOINT active_record_1
820
+ SQL (0.3ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
821
+  (0.0ms) RELEASE SAVEPOINT active_record_1
822
+  (0.2ms) rollback transaction
823
+  (0.0ms) begin transaction
824
+  (0.1ms) rollback transaction
825
+  (0.1ms) begin transaction
826
+  (0.0ms) SAVEPOINT active_record_1
827
+ SQL (0.6ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
828
+  (0.1ms) RELEASE SAVEPOINT active_record_1
829
+  (0.1ms) rollback transaction
830
+  (0.0ms) begin transaction
831
+  (0.0ms) SAVEPOINT active_record_1
832
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
833
+  (0.0ms) RELEASE SAVEPOINT active_record_1
834
+  (0.1ms) rollback transaction
835
+  (0.0ms) begin transaction
836
+  (0.0ms) SAVEPOINT active_record_1
837
+ SQL (0.5ms) INSERT INTO "widgets" ("created_at", "manufacturer_id", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00], ["manufacturer_id", nil], ["name", nil], ["updated_at", Sat, 09 Nov 2013 21:01:45 UTC +00:00]]
838
+  (0.0ms) RELEASE SAVEPOINT active_record_1
839
+  (0.1ms) rollback transaction
840
+ Connecting to database specified by database.yml
841
+ Connecting to database specified by database.yml
842
+  (0.5ms) begin transaction
843
+  (0.1ms) rollback transaction
844
+ Connecting to database specified by database.yml
845
+  (0.5ms) begin transaction
846
+  (0.1ms) rollback transaction
847
+ Connecting to database specified by database.yml
848
+  (0.5ms) begin transaction
849
+  (0.1ms) rollback transaction
850
+ Connecting to database specified by database.yml
851
+  (0.5ms) begin transaction
852
+  (0.1ms) rollback transaction
853
+ Connecting to database specified by database.yml
854
+  (1.7ms) select sqlite_version(*)
855
+  (177.8ms) CREATE TABLE "manufacturers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
856
+  (176.0ms) CREATE TABLE "widgets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "manufacturer_id" integer, "name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
857
+  (177.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
858
+  (144.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
859
+  (0.1ms) SELECT version FROM "schema_migrations"
860
+  (176.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192834')
861
+  (155.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192625')
862
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
863
+ Connecting to database specified by database.yml
864
+  (0.5ms) begin transaction
865
+  (0.1ms) rollback transaction
866
+ Connecting to database specified by database.yml
867
+  (0.5ms) begin transaction
868
+  (0.1ms) rollback transaction
869
+ Connecting to database specified by database.yml
870
+ Connecting to database specified by database.yml
871
+  (1.9ms) select sqlite_version(*)
872
+  (184.4ms) CREATE TABLE "manufacturers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
873
+  (165.0ms) CREATE TABLE "widgets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "manufacturer_id" integer, "name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
874
+  (188.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
875
+  (166.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
876
+  (0.1ms) SELECT version FROM "schema_migrations"
877
+  (187.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192834')
878
+  (200.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192625')
879
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
880
+ Connecting to database specified by database.yml
881
+  (1.9ms) select sqlite_version(*)
882
+  (189.1ms) CREATE TABLE "manufacturers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
883
+  (197.9ms) CREATE TABLE "widgets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "address" varchar(255), "birthdate" date, "first_name" varchar(255), "last_name" varchar(255), "preferred_name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
884
+  (199.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
885
+  (155.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
886
+  (0.1ms) SELECT version FROM "schema_migrations"
887
+  (165.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192834')
888
+  (144.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20131027192625')
889
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
890
+ Connecting to database specified by database.yml
891
+  (0.5ms) begin transaction
892
+  (0.1ms) SAVEPOINT active_record_1
893
+ SQL (5.7ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address-00001"], ["birthdate", Thu, 01 Jan 1970], ["created_at", Sat, 09 Nov 2013 21:19:08 UTC +00:00], ["first_name", "first-name-00001"], ["last_name", "last-name-00001"], ["preferred_name", "preferred-name-00001"], ["updated_at", Sat, 09 Nov 2013 21:19:08 UTC +00:00]]
894
+  (0.1ms) RELEASE SAVEPOINT active_record_1
895
+  (0.2ms) rollback transaction
896
+ Connecting to database specified by database.yml
897
+  (0.5ms) begin transaction
898
+  (0.1ms) rollback transaction
899
+ Connecting to database specified by database.yml
900
+  (0.4ms) begin transaction
901
+  (0.1ms) rollback transaction
902
+ Connecting to database specified by database.yml
903
+  (0.5ms) begin transaction
904
+  (0.1ms) SAVEPOINT active_record_1
905
+ SQL (5.6ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address-00001"], ["birthdate", Thu, 08 Jun 1989], ["created_at", Sat, 09 Nov 2013 21:27:00 UTC +00:00], ["first_name", "first-name-00001"], ["last_name", "last-name-00001"], ["preferred_name", "preferred-name-00001"], ["updated_at", Sat, 09 Nov 2013 21:27:00 UTC +00:00]]
906
+  (0.1ms) RELEASE SAVEPOINT active_record_1
907
+  (0.2ms) rollback transaction
908
+ Connecting to database specified by database.yml
909
+  (0.5ms) begin transaction
910
+  (0.1ms) SAVEPOINT active_record_1
911
+ SQL (5.6ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address-00001"], ["birthdate", Mon, 15 Feb 1999], ["created_at", Sat, 09 Nov 2013 21:27:27 UTC +00:00], ["first_name", "first-name-00001"], ["last_name", "last-name-00001"], ["preferred_name", "preferred-name-00001"], ["updated_at", Sat, 09 Nov 2013 21:27:27 UTC +00:00]]
912
+  (0.1ms) RELEASE SAVEPOINT active_record_1
913
+  (0.0ms) SAVEPOINT active_record_1
914
+ SQL (0.4ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address-00002"], ["birthdate", Wed, 21 Sep 2011], ["created_at", Sat, 09 Nov 2013 21:27:27 UTC +00:00], ["first_name", "first-name-00002"], ["last_name", "last-name-00002"], ["preferred_name", "preferred-name-00002"], ["updated_at", Sat, 09 Nov 2013 21:27:27 UTC +00:00]]
915
+  (0.0ms) RELEASE SAVEPOINT active_record_1
916
+  (0.2ms) rollback transaction
917
+ Connecting to database specified by database.yml
918
+  (0.5ms) begin transaction
919
+  (0.1ms) SAVEPOINT active_record_1
920
+ SQL (5.6ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address"], ["birthdate", Thu, 01 Jan 1970], ["created_at", Sat, 09 Nov 2013 21:29:55 UTC +00:00], ["first_name", "first-name"], ["last_name", "last-name"], ["preferred_name", "preferred_name"], ["updated_at", Sat, 09 Nov 2013 21:29:55 UTC +00:00]]
921
+  (0.1ms) RELEASE SAVEPOINT active_record_1
922
+  (0.3ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."address" = 'address'
923
+ Widget Load (0.2ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."address" = 'address'
924
+  (0.2ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."birthdate" = '1970-01-01'
925
+ Widget Load (0.2ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."birthdate" = '1970-01-01'
926
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."first_name" = 'first-name'
927
+ Widget Load (0.2ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."first_name" = 'first-name'
928
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."last_name" = 'last-name'
929
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."last_name" = 'last-name'
930
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."preferred_name" = 'preferred_name'
931
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."preferred_name" = 'preferred_name'
932
+  (0.3ms) rollback transaction
933
+ Connecting to database specified by database.yml
934
+  (0.5ms) begin transaction
935
+  (0.1ms) SAVEPOINT active_record_1
936
+ SQL (5.6ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address"], ["birthdate", Thu, 01 Jan 1970], ["created_at", Sat, 09 Nov 2013 21:30:17 UTC +00:00], ["first_name", "first-name"], ["last_name", "last-name"], ["preferred_name", "preferred_name"], ["updated_at", Sat, 09 Nov 2013 21:30:17 UTC +00:00]]
937
+  (0.1ms) RELEASE SAVEPOINT active_record_1
938
+  (0.2ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."address" = 'address'
939
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."address" = 'address'
940
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."birthdate" = '1970-01-01'
941
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."birthdate" = '1970-01-01'
942
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."first_name" = 'first-name'
943
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."first_name" = 'first-name'
944
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."last_name" = 'last-name'
945
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."last_name" = 'last-name'
946
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."preferred_name" = 'preferred_name'
947
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."preferred_name" = 'preferred_name'
948
+  (0.2ms) rollback transaction
949
+ Connecting to database specified by database.yml
950
+  (0.8ms) begin transaction
951
+  (0.1ms) SAVEPOINT active_record_1
952
+ SQL (81.8ms) INSERT INTO "widgets" ("address", "birthdate", "created_at", "first_name", "last_name", "preferred_name", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["address", "address"], ["birthdate", Thu, 01 Jan 1970], ["created_at", Sat, 09 Nov 2013 21:36:17 UTC +00:00], ["first_name", "first-name"], ["last_name", "last-name"], ["preferred_name", "preferred_name"], ["updated_at", Sat, 09 Nov 2013 21:36:17 UTC +00:00]]
953
+  (0.1ms) RELEASE SAVEPOINT active_record_1
954
+  (0.3ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."address" = 'address'
955
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."address" = 'address'
956
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."birthdate" = '1970-01-01'
957
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."birthdate" = '1970-01-01'
958
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."first_name" = 'first-name'
959
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."first_name" = 'first-name'
960
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."last_name" = 'last-name'
961
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."last_name" = 'last-name'
962
+  (0.1ms) SELECT COUNT(*) FROM "widgets" WHERE "widgets"."preferred_name" = 'preferred_name'
963
+ Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."preferred_name" = 'preferred_name'
964
+  (0.3ms) rollback transaction
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :widget do
3
+ sequence(:address) { |n| "address-#{'%05d' % n}" }
4
+ birthdate { TestHelper.random_date }
5
+ sequence(:first_name) { |n| "first-name-#{'%05d' % n}" }
6
+ sequence(:last_name) { |n| "last-name-#{'%05d' % n}" }
7
+ sequence(:preferred_name) { |n| "preferred-name-#{'%05d' % n}" }
8
+ end
9
+ end
10
+
@@ -1,12 +1,5 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class SimilarityMatchingTest < ActiveSupport::TestCase
4
- test 'sample_method true' do
5
- assert AttrSimilar::SimilarityMatching.sample_method(true)
6
- end
7
-
8
- test 'sample_method false' do
9
- assert !AttrSimilar::SimilarityMatching.sample_method(false)
10
- end
11
4
  end
12
5
 
data/test/test_helper.rb CHANGED
@@ -16,3 +16,15 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
16
16
  if ActiveSupport::TestCase.method_defined?(:fixture_path=)
17
17
  ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
18
18
  end
19
+
20
+ module TestHelper
21
+ def self.random_date
22
+ Date.today - 10000 * rand
23
+ end
24
+ end
25
+
26
+ class ActiveSupport::TestCase
27
+ include FactoryGirl::Syntax::Methods
28
+ include TestHelper
29
+ end
30
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_similar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-08 00:00:00.000000000 Z
12
+ date: 2013-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -88,9 +88,12 @@ files:
88
88
  - test/dummy/app/models/widget.rb
89
89
  - test/dummy/app/models/manufacturer.rb
90
90
  - test/dummy/app/helpers/application_helper.rb
91
+ - test/dummy/test/factories/widgets.rb
91
92
  - test/dummy/config.ru
93
+ - test/dummy/log/development.log
92
94
  - test/dummy/log/test.log
93
95
  - test/dummy/Rakefile
96
+ - test/dummy/db/development.sqlite3
94
97
  - test/dummy/db/schema.rb
95
98
  - test/dummy/db/migrate/20131027192625_create_manufacturers.rb
96
99
  - test/dummy/db/migrate/20131027192834_create_widgets.rb
@@ -152,9 +155,12 @@ test_files:
152
155
  - test/dummy/app/models/widget.rb
153
156
  - test/dummy/app/models/manufacturer.rb
154
157
  - test/dummy/app/helpers/application_helper.rb
158
+ - test/dummy/test/factories/widgets.rb
155
159
  - test/dummy/config.ru
160
+ - test/dummy/log/development.log
156
161
  - test/dummy/log/test.log
157
162
  - test/dummy/Rakefile
163
+ - test/dummy/db/development.sqlite3
158
164
  - test/dummy/db/schema.rb
159
165
  - test/dummy/db/migrate/20131027192625_create_manufacturers.rb
160
166
  - test/dummy/db/migrate/20131027192834_create_widgets.rb