effective_addresses 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +151 -0
  3. data/Rakefile +23 -0
  4. data/app/assets/javascripts/effective_addresses.js +1 -0
  5. data/app/assets/javascripts/effective_addresses/address_fields.js.coffee +13 -0
  6. data/app/controllers/effective/addresses_controller.rb +16 -0
  7. data/app/helpers/effective_addresses_helper.rb +27 -0
  8. data/app/models/concerns/acts_as_addressable.rb +107 -0
  9. data/app/models/effective/address.rb +93 -0
  10. data/app/models/validators/billing_address_validator.rb +7 -0
  11. data/app/views/effective/addresses/_address_fields.html.haml +29 -0
  12. data/app/views/effective/addresses/_subregions.html.haml +1 -0
  13. data/config/routes.rb +4 -0
  14. data/db/migrate/01_create_effective_addresses.rb.erb +24 -0
  15. data/lib/effective_addresses.rb +16 -0
  16. data/lib/effective_addresses/engine.rb +28 -0
  17. data/lib/effective_addresses/version.rb +3 -0
  18. data/lib/generators/effective_addresses/install_generator.rb +32 -0
  19. data/lib/generators/templates/README +1 -0
  20. data/lib/generators/templates/effective_addresses.rb +12 -0
  21. data/lib/tasks/effective_addresses_tasks.rake +4 -0
  22. data/spec/controllers/addresses_controller_spec.rb +10 -0
  23. data/spec/dummy/README.rdoc +261 -0
  24. data/spec/dummy/Rakefile +7 -0
  25. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  26. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  27. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  28. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  29. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  30. data/spec/dummy/config.ru +4 -0
  31. data/spec/dummy/config/application.rb +65 -0
  32. data/spec/dummy/config/boot.rb +10 -0
  33. data/spec/dummy/config/database.yml +25 -0
  34. data/spec/dummy/config/environment.rb +5 -0
  35. data/spec/dummy/config/environments/development.rb +37 -0
  36. data/spec/dummy/config/environments/production.rb +67 -0
  37. data/spec/dummy/config/environments/test.rb +37 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/inflections.rb +15 -0
  40. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  41. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  42. data/spec/dummy/config/initializers/session_store.rb +8 -0
  43. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/spec/dummy/config/locales/en.yml +5 -0
  45. data/spec/dummy/config/routes.rb +58 -0
  46. data/spec/dummy/db/development.sqlite3 +0 -0
  47. data/spec/dummy/db/schema.rb +34 -0
  48. data/spec/dummy/db/test.sqlite3 +0 -0
  49. data/spec/dummy/log/development.log +103 -0
  50. data/spec/dummy/log/test.log +125 -0
  51. data/spec/dummy/public/404.html +26 -0
  52. data/spec/dummy/public/422.html +26 -0
  53. data/spec/dummy/public/500.html +25 -0
  54. data/spec/dummy/public/favicon.ico +0 -0
  55. data/spec/dummy/script/rails +6 -0
  56. data/spec/dummy/spec_link +3 -0
  57. data/spec/models/address_spec.rb +52 -0
  58. data/spec/spec_helper.rb +39 -0
  59. data/spec/support/factories.rb +13 -0
  60. metadata +339 -0
Binary file
@@ -0,0 +1,34 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 1) do
15
+
16
+ create_table "addresses", :force => true do |t|
17
+ t.string "addressable_type"
18
+ t.integer "addressable_id"
19
+ t.string "category", :limit => 64
20
+ t.string "full_name"
21
+ t.string "address1"
22
+ t.string "address2"
23
+ t.string "city"
24
+ t.string "state_code"
25
+ t.string "country_code"
26
+ t.string "postal_code"
27
+ t.datetime "updated_at"
28
+ t.datetime "created_at"
29
+ end
30
+
31
+ add_index "addresses", ["addressable_id"], :name => "index_addresses_on_addressable_id"
32
+ add_index "addresses", ["addressable_type", "addressable_id"], :name => "index_addresses_on_addressable_type_and_addressable_id"
33
+
34
+ end
Binary file
@@ -0,0 +1,103 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+ Connecting to database specified by database.yml
4
+
5
+
6
+ Started GET "/" for 127.0.0.1 at 2013-05-16 13:35:05 -0600
7
+
8
+ ActionController::RoutingError (No route matches [GET] "/"):
9
+ actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
10
+ actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
11
+ railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
12
+ railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
13
+ activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
14
+ railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
15
+ actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
16
+ rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
17
+ rack (1.4.5) lib/rack/runtime.rb:17:in `call'
18
+ activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
19
+ rack (1.4.5) lib/rack/lock.rb:15:in `call'
20
+ actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
21
+ railties (3.2.13) lib/rails/engine.rb:479:in `call'
22
+ railties (3.2.13) lib/rails/application.rb:223:in `call'
23
+ rack (1.4.5) lib/rack/content_length.rb:14:in `call'
24
+ railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
25
+ rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
26
+ /Users/matt/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
27
+ /Users/matt/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
28
+ /Users/matt/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
29
+
30
+
31
+ Rendered /Users/matt/.rvm/gems/ruby-1.9.3-p374/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (6.2ms)
32
+ Connecting to database specified by database.yml
33
+  (0.2ms) select sqlite_version(*)
34
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
35
+  (2.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
36
+  (3.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
37
+ Connecting to database specified by database.yml
38
+  (2.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
39
+ Migrating to CreateEffectiveAddresses (1)
40
+  (0.0ms) select sqlite_version(*)
41
+  (0.0ms) begin transaction
42
+  (0.7ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar(255), "addressable_id" integer, "category" varchar(64), "full_name" varchar(255), "address1" varchar(255), "address2" varchar(255), "city" varchar(255), "state_code" varchar(255), "country_code" varchar(255), "postal_code" varchar(255), "updated_at" datetime, "created_at" datetime)
43
+  (0.2ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
44
+  (0.2ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
45
+  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
46
+  (2.9ms) commit transaction
47
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
48
+ Connecting to database specified by database.yml
49
+  (0.2ms) select sqlite_version(*)
50
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
51
+  (2.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
52
+  (3.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
53
+ Connecting to database specified by database.yml
54
+  (2.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
55
+ Migrating to CreateEffectiveAddresses (1)
56
+  (0.0ms) select sqlite_version(*)
57
+  (0.0ms) begin transaction
58
+  (0.8ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar(255), "addressable_id" integer, "category" varchar(64), "full_name" varchar(255), "address1" varchar(255), "address2" varchar(255), "city" varchar(255), "state_code" varchar(255), "country_code" varchar(255), "postal_code" varchar(255), "updated_at" datetime, "created_at" datetime)
59
+  (0.2ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
60
+  (0.2ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
61
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
62
+  (2.0ms) commit transaction
63
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
64
+ Connecting to database specified by database.yml
65
+  (2.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
66
+  (0.4ms) select sqlite_version(*)
67
+  (11.6ms) DROP TABLE "addresses"
68
+  (2.6ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar(255), "addressable_id" integer, "category" varchar(64), "full_name" varchar(255), "address1" varchar(255), "address2" varchar(255), "city" varchar(255), "state_code" varchar(255), "country_code" varchar(255), "postal_code" varchar(255), "updated_at" datetime, "created_at" datetime)
69
+  (2.3ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
70
+  (2.0ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
71
+  (0.1ms) SELECT version FROM "schema_migrations"
72
+ Connecting to database specified by database.yml
73
+  (0.2ms) select sqlite_version(*)
74
+  (2.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
75
+  (2.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
76
+  (3.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
77
+ Connecting to database specified by database.yml
78
+  (3.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
79
+ Migrating to CreateEffectiveAddresses (1)
80
+  (0.0ms) select sqlite_version(*)
81
+  (0.1ms) begin transaction
82
+  (0.7ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar(255), "addressable_id" integer, "category" varchar(64), "full_name" varchar(255), "address1" varchar(255), "address2" varchar(255), "city" varchar(255), "state_code" varchar(255), "country_code" varchar(255), "postal_code" varchar(255), "updated_at" datetime, "created_at" datetime)
83
+  (0.2ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
84
+  (0.1ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
85
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('1')
86
+  (2.7ms) commit transaction
87
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
88
+ Connecting to database specified by database.yml
89
+  (2.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
90
+  (0.4ms) select sqlite_version(*)
91
+  (34.3ms) DROP TABLE "addresses"
92
+  (2.9ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar(255), "addressable_id" integer, "category" varchar(64), "full_name" varchar(255), "address1" varchar(255), "address2" varchar(255), "city" varchar(255), "state_code" varchar(255), "country_code" varchar(255), "postal_code" varchar(255), "updated_at" datetime, "created_at" datetime)
93
+  (2.4ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
94
+  (2.9ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
95
+  (0.1ms) SELECT version FROM "schema_migrations"
96
+ Connecting to database specified by database.yml
97
+  (2.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
98
+  (0.4ms) select sqlite_version(*)
99
+  (2.3ms) DROP TABLE "addresses"
100
+  (2.8ms) CREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar(255), "addressable_id" integer, "category" varchar(64), "full_name" varchar(255), "address1" varchar(255), "address2" varchar(255), "city" varchar(255), "state_code" varchar(255), "country_code" varchar(255), "postal_code" varchar(255), "updated_at" datetime, "created_at" datetime)
101
+  (2.7ms) CREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")
102
+  (2.1ms) CREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")
103
+  (0.1ms) SELECT version FROM "schema_migrations"
@@ -0,0 +1,125 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+ Connecting to database specified by database.yml
4
+ Connecting to database specified by database.yml
5
+ Connecting to database specified by database.yml
6
+ Connecting to database specified by database.yml
7
+ Connecting to database specified by database.yml
8
+ Connecting to database specified by database.yml
9
+ Connecting to database specified by database.yml
10
+ Connecting to database specified by database.yml
11
+ Connecting to database specified by database.yml
12
+ Connecting to database specified by database.yml
13
+ Connecting to database specified by database.yml
14
+ Connecting to database specified by database.yml
15
+ Connecting to database specified by database.yml
16
+ Connecting to database specified by database.yml
17
+ Connecting to database specified by database.yml
18
+ Connecting to database specified by database.yml
19
+ Connecting to database specified by database.yml
20
+ Connecting to database specified by database.yml
21
+ Connecting to database specified by database.yml
22
+ Connecting to database specified by database.yml
23
+ Connecting to database specified by database.yml
24
+ Connecting to database specified by database.yml
25
+ Connecting to database specified by database.yml
26
+ Connecting to database specified by database.yml
27
+ Connecting to database specified by database.yml
28
+ Connecting to database specified by database.yml
29
+ Connecting to database specified by database.yml
30
+ Connecting to database specified by database.yml
31
+ Connecting to database specified by database.yml
32
+ Connecting to database specified by database.yml
33
+ Connecting to database specified by database.yml
34
+ Connecting to database specified by database.yml
35
+ Connecting to database specified by database.yml
36
+ Connecting to database specified by database.yml
37
+ Connecting to database specified by database.yml
38
+ Connecting to database specified by database.yml
39
+ Connecting to database specified by database.yml
40
+ Connecting to database specified by database.yml
41
+ Connecting to database specified by database.yml
42
+ Connecting to database specified by database.yml
43
+ Connecting to database specified by database.yml
44
+ Connecting to database specified by database.yml
45
+ Connecting to database specified by database.yml
46
+ Connecting to database specified by database.yml
47
+ Connecting to database specified by database.yml
48
+ Connecting to database specified by database.yml
49
+ Connecting to database specified by database.yml
50
+ Connecting to database specified by database.yml
51
+ Connecting to database specified by database.yml
52
+ Connecting to database specified by database.yml
53
+ Connecting to database specified by database.yml
54
+ Connecting to database specified by database.yml
55
+ Connecting to database specified by database.yml
56
+ Connecting to database specified by database.yml
57
+ Connecting to database specified by database.yml
58
+ Connecting to database specified by database.yml
59
+ Connecting to database specified by database.yml
60
+ Connecting to database specified by database.yml
61
+ Connecting to database specified by database.yml
62
+ Connecting to database specified by database.yml
63
+ Connecting to database specified by database.yml
64
+ Connecting to database specified by database.yml
65
+ Connecting to database specified by database.yml
66
+ Connecting to database specified by database.yml
67
+ Connecting to database specified by database.yml
68
+ Connecting to database specified by database.yml
69
+ Connecting to database specified by database.yml
70
+ Connecting to database specified by database.yml
71
+ Connecting to database specified by database.yml
72
+ Connecting to database specified by database.yml
73
+ Connecting to database specified by database.yml
74
+ Connecting to database specified by database.yml
75
+ Connecting to database specified by database.yml
76
+ Connecting to database specified by database.yml
77
+ Connecting to database specified by database.yml
78
+ Connecting to database specified by database.yml
79
+ Connecting to database specified by database.yml
80
+ Connecting to database specified by database.yml
81
+ Connecting to database specified by database.yml
82
+ Connecting to database specified by database.yml
83
+ Connecting to database specified by database.yml
84
+ Connecting to database specified by database.yml
85
+ Connecting to database specified by database.yml
86
+ Connecting to database specified by database.yml
87
+ Connecting to database specified by database.yml
88
+ Connecting to database specified by database.yml
89
+ Connecting to database specified by database.yml
90
+ Connecting to database specified by database.yml
91
+ Connecting to database specified by database.yml
92
+ Connecting to database specified by database.yml
93
+ Connecting to database specified by database.yml
94
+ Connecting to database specified by database.yml
95
+ Connecting to database specified by database.yml
96
+ Connecting to database specified by database.yml
97
+ Connecting to database specified by database.yml
98
+ Connecting to database specified by database.yml
99
+ Connecting to database specified by database.yml
100
+ Connecting to database specified by database.yml
101
+ Connecting to database specified by database.yml
102
+ Connecting to database specified by database.yml
103
+ Connecting to database specified by database.yml
104
+ Connecting to database specified by database.yml
105
+ Connecting to database specified by database.yml
106
+ Connecting to database specified by database.yml
107
+ Connecting to database specified by database.yml
108
+ Connecting to database specified by database.yml
109
+ Connecting to database specified by database.yml
110
+ Connecting to database specified by database.yml
111
+ Connecting to database specified by database.yml
112
+ Connecting to database specified by database.yml
113
+ Connecting to database specified by database.yml
114
+ Connecting to database specified by database.yml
115
+ Connecting to database specified by database.yml
116
+ Connecting to database specified by database.yml
117
+ Connecting to database specified by database.yml
118
+ Connecting to database specified by database.yml
119
+ Connecting to database specified by database.yml
120
+ Connecting to database specified by database.yml
121
+ Connecting to database specified by database.yml
122
+ Connecting to database specified by database.yml
123
+ Connecting to database specified by database.yml
124
+ Connecting to database specified by database.yml
125
+ Connecting to database specified by database.yml
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,3 @@
1
+ You may have to link this to ../../spec
2
+
3
+ spec/dummy > ln -s ../../spec spec
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'carmen-rails'
3
+
4
+ describe Effective::Address do
5
+ let(:address) { FactoryGirl.create(:address) }
6
+
7
+ it "should be valid" do
8
+ address.valid?.should == true
9
+ end
10
+
11
+ it "should be able to clone" do
12
+ address2 = address.dup
13
+ address2.save
14
+
15
+ address.full_name.should == address2.full_name
16
+ address.address1.should == address2.address1
17
+ address.address2.should == address2.address2
18
+ address.city.should == address2.city
19
+ address.state.should == address2.state
20
+ address.country.should == address2.country
21
+ address.postal_code.should == address2.postal_code
22
+ address.category.should == address2.category
23
+
24
+ address.id.should_not == address2.id
25
+ address.created_at.should_not == address2.created_at
26
+ address.updated_at.should_not == address2.updated_at
27
+ end
28
+
29
+ it "should compare details and == to another address" do
30
+ address2 = address.dup
31
+ address.should == address2
32
+ end
33
+
34
+ it 'should return the country name when given the country code' do
35
+ address.country_code = 'CA'
36
+ address.country.should eq 'Canada'
37
+
38
+ address.country_code = 'US'
39
+ address.country.should eq 'United States'
40
+ end
41
+
42
+ it 'should return the appropriate province when country code is set' do
43
+ address.country_code = 'CA'
44
+ address.state_code = 'AB'
45
+ address.state.should eq 'Alberta'
46
+
47
+ address.country_code = 'US'
48
+ address.state_code = 'NY'
49
+ address.state.should eq 'New York'
50
+ end
51
+
52
+ end
@@ -0,0 +1,39 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+
5
+ require 'rspec/rails'
6
+ require 'rspec/autorun'
7
+ require 'factory_girl_rails'
8
+ require 'haml'
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc,
11
+ # in spec/support/ and its subdirectories.
12
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f }
13
+
14
+ Carmen.i18n_backend.load_path << (Carmen.root_path.to_s + '/locale/en/world.yml')
15
+ Carmen.i18n_backend.load_path << (Carmen.root_path.to_s + '/locale/en/world/ca.yml')
16
+ Carmen.i18n_backend.load_path << (Carmen.root_path.to_s + '/locale/en/world/us.yml')
17
+
18
+ RSpec.configure do |config|
19
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
20
+
21
+ Rails.logger.level = 4 # Output only minimal stuff to test.log
22
+
23
+ config.use_transactional_fixtures = true # Make this false to once again use DatabaseCleaner
24
+ config.infer_base_class_for_anonymous_controllers = false
25
+ config.order = 'random'
26
+ end
27
+
28
+ class ActiveRecord::Base
29
+ mattr_accessor :shared_connection
30
+ @@shared_connection = nil
31
+
32
+ def self.connection
33
+ @@shared_connection || retrieve_connection
34
+ end
35
+ end
36
+
37
+ # Forces all threads to share the same connection. This works on
38
+ # Capybara because it starts the web server in a thread.
39
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection