acts_as_addressable 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +28 -0
- data/app/assets/javascripts/acts_as_addressable/application.js +13 -0
- data/app/assets/javascripts/acts_as_addressable/locations.js +2 -0
- data/app/assets/stylesheets/acts_as_addressable/application.css +15 -0
- data/app/assets/stylesheets/acts_as_addressable/locations.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/acts_as_addressable/application_controller.rb +4 -0
- data/app/controllers/acts_as_addressable/locations_controller.rb +62 -0
- data/app/helpers/acts_as_addressable/application_helper.rb +4 -0
- data/app/helpers/acts_as_addressable/locations_helper.rb +4 -0
- data/app/models/acts_as_addressable/location.rb +33 -0
- data/app/views/acts_as_addressable/locations/_form.html.erb +65 -0
- data/app/views/acts_as_addressable/locations/edit.html.erb +6 -0
- data/app/views/acts_as_addressable/locations/index.html.erb +47 -0
- data/app/views/acts_as_addressable/locations/new.html.erb +5 -0
- data/app/views/acts_as_addressable/locations/show.html.erb +64 -0
- data/app/views/layouts/acts_as_addressable/application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20140426032656_create_acts_as_addressable_locations.rb +23 -0
- data/lib/acts_as_addressable.rb +22 -0
- data/lib/acts_as_addressable/engine.rb +23 -0
- data/lib/acts_as_addressable/local_instance_methods.rb +11 -0
- data/lib/acts_as_addressable/version.rb +3 -0
- data/lib/tasks/acts_as_addressable_tasks.rake +4 -0
- data/spec/acts_as_addressable_spec.rb +23 -0
- data/spec/controllers/acts_as_addressable/locations_controller_spec.rb +163 -0
- data/spec/factories/acts_as_addressable_locations.rb +31 -0
- data/spec/helpers/acts_as_addressable/locations_helper_spec.rb +17 -0
- data/spec/models/acts_as_addressable/location_spec.rb +21 -0
- data/spec/routing/acts_as_addressable/locations_routing_spec.rb +38 -0
- data/spec/spec_helper.rb +54 -0
- data/spec/test_app/README.rdoc +28 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/javascripts/application.js +13 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/controllers/application_controller.rb +5 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/models/user.rb +3 -0
- data/spec/test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/config/application.rb +29 -0
- data/spec/test_app/config/boot.rb +5 -0
- data/spec/test_app/config/database.yml +25 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +37 -0
- data/spec/test_app/config/environments/production.rb +83 -0
- data/spec/test_app/config/environments/test.rb +39 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/session_store.rb +3 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +23 -0
- data/spec/test_app/config/routes.rb +4 -0
- data/spec/test_app/config/secrets.yml +22 -0
- data/spec/test_app/db/development.sqlite3 +0 -0
- data/spec/test_app/db/migrate/20140507215937_create_users.rb +9 -0
- data/spec/test_app/db/production.sqlite3 +0 -0
- data/spec/test_app/db/schema.rb +42 -0
- data/spec/test_app/db/test.sqlite3 +0 -0
- data/spec/test_app/log/development.log +197 -0
- data/spec/test_app/log/test.log +5110 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/favicon.ico +0 -0
- metadata +304 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ActsAsAddressable</title>
|
5
|
+
<%= stylesheet_link_tag "acts_as_addressable/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "acts_as_addressable/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateActsAsAddressableLocations < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :acts_as_addressable_locations do |t|
|
4
|
+
t.string :country_code
|
5
|
+
t.string :street_1
|
6
|
+
t.string :street_2
|
7
|
+
t.string :city
|
8
|
+
t.string :region
|
9
|
+
t.string :postal_code
|
10
|
+
t.decimal :latitude, precision: 9, scale: 6
|
11
|
+
t.decimal :longitude, precision: 9, scale: 6
|
12
|
+
t.references :addressable, polymorphic: true
|
13
|
+
t.boolean :mailing, default: true
|
14
|
+
t.boolean :physical, default: true
|
15
|
+
t.boolean :primary, default: true
|
16
|
+
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
|
20
|
+
add_index :acts_as_addressable_locations, [:addressable_type, :addressable_id], name: "aaa_locations_on_addressable_type_and_addressable_id"
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'acts_as_addressable/engine'
|
2
|
+
require 'acts_as_addressable/local_instance_methods'
|
3
|
+
|
4
|
+
module ActsAsAddressable
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def acts_as_addressable(options = {})
|
13
|
+
class_eval do
|
14
|
+
has_many :locations, as: :addressable, dependent: :destroy, class_name: 'ActsAsAddressable::Location'
|
15
|
+
end
|
16
|
+
|
17
|
+
include ActsAsAddressable::LocalInstanceMethods
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveRecord::Base.send :include, ActsAsAddressable
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActsAsAddressable
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace ActsAsAddressable
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec
|
7
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
8
|
+
g.assets false
|
9
|
+
g.helper false
|
10
|
+
end
|
11
|
+
|
12
|
+
# Tell Rails where to find the engine's migrations
|
13
|
+
# Thanks - http://pivotallabs.com/leave-your-migrations-in-your-rails-engines/
|
14
|
+
initializer :append_migrations do |app|
|
15
|
+
unless app.root.to_s.match root.to_s
|
16
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
17
|
+
app.config.paths["db/migrate"] << expanded_path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ActsAsAddressable
|
4
|
+
describe "acts_as_addressable" do
|
5
|
+
let(:user) { User.create!(name: "Peter Parker") }
|
6
|
+
|
7
|
+
it "responds to #locations" do
|
8
|
+
expect(user.respond_to?(:locations)).to be true
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#home_address" do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
user.locations.create! attributes_for(:primary_address)
|
15
|
+
user.locations.create! attributes_for(:secondary_address)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns the primary location" do
|
19
|
+
expect(user.home_address.street_1).to eq "1234 S. Main"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
6
|
+
#
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
9
|
+
# controller code, this generated spec may or may not pass.
|
10
|
+
#
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
14
|
+
#
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
19
|
+
# that an instance is receiving a specific message.
|
20
|
+
|
21
|
+
module ActsAsAddressable
|
22
|
+
describe LocationsController do
|
23
|
+
routes { ActsAsAddressable::Engine.routes }
|
24
|
+
|
25
|
+
# This should return the minimal set of attributes required to create a valid
|
26
|
+
# Location. As you add validations to Location, be sure to
|
27
|
+
# adjust the attributes here as well.
|
28
|
+
let(:valid_attributes) { attributes_for(:primary_address) }
|
29
|
+
|
30
|
+
# This should return the minimal set of values that should be in the session
|
31
|
+
# in order to pass any filters (e.g. authentication) defined in
|
32
|
+
# LocationsController. Be sure to keep this updated too.
|
33
|
+
let(:valid_session) { {} }
|
34
|
+
|
35
|
+
describe "GET index" do
|
36
|
+
it "assigns all locations as @locations" do
|
37
|
+
location = Location.create! valid_attributes
|
38
|
+
get :index, {}, valid_session
|
39
|
+
expect(assigns(:locations)).to eq([location])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "GET show" do
|
44
|
+
it "assigns the requested location as @location" do
|
45
|
+
location = Location.create! valid_attributes
|
46
|
+
get :show, {:id => location.to_param}, valid_session
|
47
|
+
expect(assigns(:location)).to eq(location)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "GET new" do
|
52
|
+
it "assigns a new location as @location" do
|
53
|
+
get :new, {}, valid_session
|
54
|
+
expect(assigns(:location)).to be_a_new(Location)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "GET edit" do
|
59
|
+
it "assigns the requested location as @location" do
|
60
|
+
location = Location.create! valid_attributes
|
61
|
+
get :edit, {:id => location.to_param}, valid_session
|
62
|
+
expect(assigns(:location)).to eq(location)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "POST create" do
|
67
|
+
describe "with valid params" do
|
68
|
+
it "creates a new Location" do
|
69
|
+
expect {
|
70
|
+
post :create, {:location => valid_attributes}, valid_session
|
71
|
+
}.to change(Location, :count).by(1)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "assigns a newly created location as @location" do
|
75
|
+
post :create, {:location => valid_attributes}, valid_session
|
76
|
+
expect(assigns(:location)).to be_a(Location)
|
77
|
+
expect(assigns(:location)).to be_persisted
|
78
|
+
end
|
79
|
+
|
80
|
+
it "redirects to the created location" do
|
81
|
+
post :create, {:location => valid_attributes}, valid_session
|
82
|
+
expect(response).to redirect_to(Location.last)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "with invalid params" do
|
87
|
+
it "assigns a newly created but unsaved location as @location" do
|
88
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
89
|
+
allow_any_instance_of(Location).to receive(:save).and_return(false)
|
90
|
+
post :create, {:location => { "country_code" => "invalid value" }}, valid_session
|
91
|
+
expect(assigns(:location)).to be_a_new(Location)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "re-renders the 'new' template" do
|
95
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
96
|
+
allow_any_instance_of(Location).to receive(:save).and_return(false)
|
97
|
+
post :create, {:location => { "country_code" => "invalid value" }}, valid_session
|
98
|
+
expect(response).to render_template("new")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "PUT update" do
|
104
|
+
describe "with valid params" do
|
105
|
+
it "updates the requested location" do
|
106
|
+
location = Location.create! valid_attributes
|
107
|
+
# Assuming there are no other locations in the database, this
|
108
|
+
# specifies that the Location created on the previous line
|
109
|
+
# receives the :update_attributes message with whatever params are
|
110
|
+
# submitted in the request.
|
111
|
+
expect_any_instance_of(Location).to receive(:update).with({ "country_code" => "MyString" })
|
112
|
+
put :update, {:id => location.to_param, :location => { "country_code" => "MyString" }}, valid_session
|
113
|
+
end
|
114
|
+
|
115
|
+
it "assigns the requested location as @location" do
|
116
|
+
location = Location.create! valid_attributes
|
117
|
+
put :update, {:id => location.to_param, :location => valid_attributes}, valid_session
|
118
|
+
expect(assigns(:location)).to eq(location)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "redirects to the location" do
|
122
|
+
location = Location.create! valid_attributes
|
123
|
+
put :update, {:id => location.to_param, :location => valid_attributes}, valid_session
|
124
|
+
expect(response).to redirect_to(location)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "with invalid params" do
|
129
|
+
it "assigns the location as @location" do
|
130
|
+
location = Location.create! valid_attributes
|
131
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
132
|
+
allow_any_instance_of(Location).to receive(:save).and_return(false)
|
133
|
+
put :update, {:id => location.to_param, :location => { "country_code" => "invalid value" }}, valid_session
|
134
|
+
expect(assigns(:location)).to eq(location)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "re-renders the 'edit' template" do
|
138
|
+
location = Location.create! valid_attributes
|
139
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
140
|
+
allow_any_instance_of(Location).to receive(:save).and_return(false)
|
141
|
+
put :update, {:id => location.to_param, :location => { "country_code" => "invalid value" }}, valid_session
|
142
|
+
expect(response).to render_template("edit")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "DELETE destroy" do
|
148
|
+
it "destroys the requested location" do
|
149
|
+
location = Location.create! valid_attributes
|
150
|
+
expect {
|
151
|
+
delete :destroy, {:id => location.to_param}, valid_session
|
152
|
+
}.to change(Location, :count).by(-1)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "redirects to the locations list" do
|
156
|
+
location = Location.create! valid_attributes
|
157
|
+
delete :destroy, {:id => location.to_param}, valid_session
|
158
|
+
expect(response).to redirect_to(locations_url)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :primary_address, :class => 'ActsAsAddressable::Location' do
|
5
|
+
country_code "USA"
|
6
|
+
street_1 "1234 S. Main"
|
7
|
+
street_2 ""
|
8
|
+
city "New York"
|
9
|
+
region "NY"
|
10
|
+
postal_code "55555"
|
11
|
+
latitude 1.5
|
12
|
+
longitude 1.5
|
13
|
+
mailing true
|
14
|
+
physical true
|
15
|
+
primary true
|
16
|
+
end
|
17
|
+
|
18
|
+
factory :secondary_address, :class => 'ActsAsAddressable::Location' do
|
19
|
+
country_code "USA"
|
20
|
+
street_1 "4321 S. Main"
|
21
|
+
street_2 ""
|
22
|
+
city "New York"
|
23
|
+
region "NY"
|
24
|
+
postal_code "55555"
|
25
|
+
latitude 1.5
|
26
|
+
longitude 1.5
|
27
|
+
mailing false
|
28
|
+
physical true
|
29
|
+
primary false
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the LocationsHelper. For example:
|
5
|
+
#
|
6
|
+
# describe LocationsHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
module ActsAsAddressable
|
14
|
+
describe LocationsHelper do
|
15
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ActsAsAddressable
|
4
|
+
describe Location do
|
5
|
+
let(:user) { User.create!(name: "Peter Parker") }
|
6
|
+
|
7
|
+
describe "Validations" do
|
8
|
+
it { should validate_presence_of(:city) }
|
9
|
+
it { should validate_presence_of(:postal_code) }
|
10
|
+
it { should validate_presence_of(:street_1) }
|
11
|
+
|
12
|
+
it "allows only one primary address per addressable" do
|
13
|
+
user.locations.create! attributes_for(:primary_address)
|
14
|
+
second_primary = user.locations.build attributes_for(:primary_address)
|
15
|
+
expect(second_primary).to_not be_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module ActsAsAddressable
|
4
|
+
describe LocationsController do
|
5
|
+
describe "routing" do
|
6
|
+
routes { ActsAsAddressable::Engine.routes }
|
7
|
+
|
8
|
+
it "routes to #index" do
|
9
|
+
expect(:get => "/locations").to route_to("acts_as_addressable/locations#index")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "routes to #new" do
|
13
|
+
expect(:get => "/locations/new").to route_to("acts_as_addressable/locations#new")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "routes to #show" do
|
17
|
+
expect(:get => "/locations/1").to route_to("acts_as_addressable/locations#show", id: "1")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "routes to #edit" do
|
21
|
+
expect(:get => "/locations/1/edit").to route_to("acts_as_addressable/locations#edit", id: "1")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "routes to #create" do
|
25
|
+
expect(:post => "/locations").to route_to("acts_as_addressable/locations#create")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "routes to #update" do
|
29
|
+
expect(:put => "/locations/1").to route_to("acts_as_addressable/locations#update", id: "1")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "routes to #destroy" do
|
33
|
+
expect(:delete => "/locations/1").to route_to("acts_as_addressable/locations#destroy", id: "1")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../test_app/config/environment.rb", __FILE__)
|
4
|
+
# require File.expand_path("../../spec/test_app/config/environment", __FILE__)
|
5
|
+
|
6
|
+
require 'rspec/rails'
|
7
|
+
require 'database_cleaner'
|
8
|
+
require 'factory_girl_rails'
|
9
|
+
require 'pry'
|
10
|
+
require 'shoulda-matchers'
|
11
|
+
|
12
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
13
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
14
|
+
# run as spec files by default. This means that files in spec/support that end
|
15
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
16
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
17
|
+
# end with _spec.rb. You can configure this pattern with with the --pattern
|
18
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
19
|
+
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
20
|
+
# ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
21
|
+
# Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
22
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
23
|
+
|
24
|
+
# Checks for pending migrations before tests are run.
|
25
|
+
# If you are not using ActiveRecord, you can remove this line.
|
26
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
|
30
|
+
config.include FactoryGirl::Syntax::Methods
|
31
|
+
|
32
|
+
config.before(:suite) do
|
33
|
+
DatabaseCleaner.strategy = :transaction
|
34
|
+
DatabaseCleaner.clean_with(:truncation)
|
35
|
+
end
|
36
|
+
|
37
|
+
config.before(:each) do
|
38
|
+
DatabaseCleaner.start
|
39
|
+
end
|
40
|
+
|
41
|
+
config.after(:each) do
|
42
|
+
DatabaseCleaner.clean
|
43
|
+
end
|
44
|
+
|
45
|
+
# Run specs in random order to surface order dependencies. If you find an
|
46
|
+
# order dependency and want to debug it, you can fix the order by providing
|
47
|
+
# the seed, which is printed after each run.
|
48
|
+
# --seed 1234
|
49
|
+
config.order = "random"
|
50
|
+
|
51
|
+
# Focus on individual tests
|
52
|
+
config.filter_run :focus => true
|
53
|
+
config.run_all_when_everything_filtered = true
|
54
|
+
end
|