genderize 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb0f9371760b224246e156a4c38f010df1e7e56a
4
- data.tar.gz: f9a43ab985038479e2b1ec4eb712db849004d845
3
+ metadata.gz: f900977dce6ce532aaaaeb0eac75f034ef6f9a6f
4
+ data.tar.gz: 4a9dfe4d19dd6a31893c72d49d3f692eaea1b5aa
5
5
  SHA512:
6
- metadata.gz: 463b88c489a86cdabf90ae3eb3f9b818e3b8177cda066ce1cf5b56f3332fec2fa5e9b41b8c7ff9e07268bf8a074be9390c7349d08bab4e8c45427a08316f5318
7
- data.tar.gz: 0bb8dcf6ba581f3436afa2b8fbed28a49018a7e242d895151e50732128e018e17f6b5e5e1a77e924477546df2ff143197140cff9ca9508a2020ac80594fdc525
6
+ metadata.gz: 8ad68c57f62525bfc471f944f8242692debe6473a82bfb15c2379cc02d9f9704d7206e126682d4c59d3c2e07fdd3da13474789f779baa76980c02455d82131f7
7
+ data.tar.gz: 7d9c2260901360ef81bd9282d0373a1bea5df76a721e1973d79216f83276fda5fb9e0a9a74202d48277479d3ab328670a3d4380e7874ba9fddb4b327893b022b
@@ -6,33 +6,27 @@ unless Rails
6
6
  end
7
7
 
8
8
  module Genderize
9
-
9
+
10
10
  def self.included(base)
11
11
  base.extend(ClassMethods)
12
12
  end
13
-
13
+
14
14
  module ClassMethods
15
15
 
16
-
16
+
17
17
  def genderize(col_name = "gender")
18
- # Reads the DB column value for gender attribute and creates a new Gender
18
+ # Reads the DB column value for gender attribute and creates a new Gender
19
19
  # object with it's value
20
20
  #
21
21
  # The object is memoized for future calls.
22
- #
22
+ #
23
23
  # Returns a Gender
24
24
  define_method col_name do
25
- if value = instance_variable_get("@#{col_name}")
26
- return value
27
- end
28
- read_value = read_attribute(col_name)
29
- if read_value.blank?
30
- return read_value
31
- else
32
- instance_variable_set("@#{col_name}", Genderize::Gender.new(read_attribute(col_name)))
33
- end
25
+ current_value = instance_variable_get("@#{col_name}")
26
+ persist_value = Genderize::Gender.new(read_attribute(col_name))
27
+ return current_value || instance_variable_set("@#{col_name}", persist_value)
34
28
  end
35
-
29
+
36
30
  # Writes to the DB column the new value for the gender attribute
37
31
  # Sets the instance varaible value too
38
32
  #
@@ -41,19 +35,19 @@ module Genderize
41
35
  # Raises ArgumentError if gender is not a single alphanumeric character "m" or "f"
42
36
  define_method "#{col_name}=" do |string|
43
37
  string = string.to_s.first
44
- unless string.to_s =~ /\A(m|f)\Z/i
45
- raise ArgumentError, "Gender must be a single alphanumeric character"
38
+ unless string.to_s =~ /\A(m|f|)\Z/i
39
+ raise ArgumentError, "Gender must be one of '', 'm', or 'f'"
46
40
  end
47
41
  write_attribute(col_name, string)
48
-
42
+
49
43
  if string.blank?
50
44
  instance_variable_set("@#{col_name}", string)
51
45
  else
52
46
  instance_variable_set("@#{col_name}", Genderize::Gender.new(read_attribute(col_name)))
53
47
  end
54
48
  end
55
-
49
+
56
50
  end
57
-
51
+
58
52
  end
59
53
  end
@@ -1,3 +1,3 @@
1
1
  module Genderize
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -47,7 +47,7 @@ module Dummy
47
47
  # This will create an empty whitelist of attributes available for mass-assignment for all models
48
48
  # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49
49
  # parameters by using an attr_accessible or attr_protected declaration.
50
- config.active_record.whitelist_attributes = true
50
+ config.active_record.whitelist_attributes = true if Rails.version < "4.0.0"
51
51
 
52
52
  # Enable the asset pipeline
53
53
  config.assets.enabled = true
@@ -19,8 +19,12 @@ Dummy::Application.configure do
19
19
  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
20
  # config.action_dispatch.rack_cache = true
21
21
 
22
- # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
22
+ if Rails.version >= "4.2.0"
23
+ config.serve_static_files = false
24
+ else
25
+ # Disable Rails's static asset server (Apache or nginx will already do this).
26
+ config.serve_static_assets = false
27
+ end
24
28
 
25
29
  # Compress JavaScripts and CSS.
26
30
  config.assets.js_compressor = :uglifier
@@ -8,9 +8,8 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
11
  config.static_cache_control = "public, max-age=3600"
13
-
12
+
14
13
  if Rails.version =~ /\A3/
15
14
  # Log error messages when you accidentally call methods on nil
16
15
  config.whiny_nils = true
@@ -20,6 +19,14 @@ Dummy::Application.configure do
20
19
  config.eager_load = false
21
20
  end
22
21
 
22
+ if Rails.version >= "4.2.0"
23
+ config.serve_static_files = false
24
+ else
25
+ # Disable Rails's static asset server (Apache or nginx will already do this).
26
+ config.serve_static_assets = false
27
+ end
28
+
29
+
23
30
  # Show full error reports and disable caching.
24
31
  config.consider_all_requests_local = true
25
32
  config.action_controller.perform_caching = false
@@ -13,7 +13,7 @@
13
13
 
14
14
  ActiveRecord::Schema.define(version: 20130506080641) do
15
15
 
16
- create_table "users", force: true do |t|
16
+ create_table "users", force: :cascade do |t|
17
17
  t.string "name", limit: 20, null: false
18
18
  t.string "gender", limit: 1, null: false
19
19
  t.datetime "created_at"
Binary file
@@ -1,11 +1,24 @@
1
-  (2.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
-  (3.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to CreateUsers (20130506080641)
5
-  (0.1ms) begin transaction
6
-  (0.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(20) NOT NULL, "gender" varchar(1) NOT NULL, "created_at" datetime, "updated_at" datetime) 
7
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20130506080641"]]
8
-  (3.5ms) commit transaction
1
+ DEPRECATION WARNING: config.active_record.whitelist_attributes is deprecated and have no effect. Remove its call from the configuration. (called from block in tsort_each at /Users/Gavin/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228)
2
+  (2.5ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
3
+  (0.3ms) select sqlite_version(*)
4
+  (0.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
9
5
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
6
+ Migrating to CreateUsers (20130506080641)
7
+  (0.1ms) begin transaction
8
+ DEPRECATION WARNING: `#timestamps` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /Users/Gavin/Clients/KatanaCode/genderize/spec/dummy/db/migrate/20130506080641_create_users.rb:8)
9
+  (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(20) NOT NULL, "gender" varchar(1) NOT NULL, "created_at" datetime, "updated_at" datetime)
10
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20130506080641"]]
11
+  (0.7ms) commit transaction
10
12
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
13
+ DEPRECATION WARNING: config.active_record.whitelist_attributes is deprecated and have no effect. Remove its call from the configuration. (called from block in tsort_each at /Users/Gavin/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228)
14
+  (2.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
15
+  (0.1ms) select sqlite_version(*)
16
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
11
17
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
18
+ Migrating to CreateUsers (20130506080641)
19
+  (0.1ms) begin transaction
20
+ DEPRECATION WARNING: `#timestamps` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /Users/Gavin/Clients/KatanaCode/genderize/spec/dummy/db/migrate/20130506080641_create_users.rb:8)
21
+  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(20) NOT NULL, "gender" varchar(1) NOT NULL, "created_at" datetime, "updated_at" datetime)
22
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20130506080641"]]
23
+  (0.7ms) commit transaction
24
+ ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -1,45 +1,58 @@
1
-  (54.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
-  (2.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to CreateUsers (20130506080641)
5
-  (0.1ms) begin transaction
6
-  (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(20) NOT NULL, "gender" varchar(1) NOT NULL, "created_at" datetime, "updated_at" datetime) 
7
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20130506080641"]]
8
-  (3.0ms) commit transaction
1
+  (2.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
2
+  (0.0ms) select sqlite_version(*)
3
+  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
9
4
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
10
-  (0.1ms) begin transaction
11
- SQL (87.6ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:05:57 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:05:57 UTC +00:00]]
5
+ Migrating to CreateUsers (20130506080641)
6
+  (0.0ms) begin transaction
7
+  (0.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(20) NOT NULL, "gender" varchar(1) NOT NULL, "created_at" datetime, "updated_at" datetime)
8
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20130506080641"]]
9
+  (0.5ms) commit transaction
10
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
11
+  (0.0ms) begin transaction
12
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:22:21.503307"], ["updated_at", "2016-05-27 13:22:21.503307"]]
13
+  (2.7ms) commit transaction
14
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
15
+  (0.0ms) begin transaction
16
+ SQL (0.4ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:22:53.702225"], ["updated_at", "2016-05-27 13:22:53.702225"]]
12
17
   (2.5ms) commit transaction
13
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
14
-  (0.1ms) begin transaction
15
- SQL (3.3ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:08:19 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:08:19 UTC +00:00]]
16
-  (53.4ms) commit transaction
17
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
18
-  (0.1ms) begin transaction
19
- SQL (2.3ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:08:51 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:08:51 UTC +00:00]]
20
-  (51.2ms) commit transaction
21
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
18
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
22
19
   (0.1ms) begin transaction
23
- SQL (2.4ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:09:03 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:09:03 UTC +00:00]]
20
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:28:16.419497"], ["updated_at", "2016-05-27 13:28:16.419497"]]
21
+  (2.4ms) commit transaction
22
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
23
+  (0.0ms) begin transaction
24
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:29:04.891644"], ["updated_at", "2016-05-27 13:29:04.891644"]]
25
+  (2.5ms) commit transaction
26
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
27
+  (0.0ms) begin transaction
28
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:29:41.054526"], ["updated_at", "2016-05-27 13:29:41.054526"]]
24
29
   (2.7ms) commit transaction
25
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
26
-  (0.1ms) begin transaction
27
- SQL (2.3ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:10:54 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:10:54 UTC +00:00]]
28
-  (51.3ms) commit transaction
29
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
30
-  (0.1ms) begin transaction
31
- SQL (3.2ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:11:20 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:11:20 UTC +00:00]]
30
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
31
+  (0.0ms) begin transaction
32
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:30:10.725246"], ["updated_at", "2016-05-27 13:30:10.725246"]]
33
+  (2.6ms) commit transaction
34
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
35
+  (0.0ms) begin transaction
36
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:31:19.111752"], ["updated_at", "2016-05-27 13:31:19.111752"]]
32
37
   (2.4ms) commit transaction
33
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
34
-  (0.1ms) begin transaction
35
- SQL (2.3ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:11:42 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:11:42 UTC +00:00]]
36
-  (122.6ms) commit transaction
37
- User Load (0.4ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
38
-  (0.1ms) begin transaction
39
- SQL (2.4ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:12:53 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:12:53 UTC +00:00]]
38
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
39
+  (0.0ms) begin transaction
40
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:31:42.590594"], ["updated_at", "2016-05-27 13:31:42.590594"]]
41
+  (2.6ms) commit transaction
42
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
43
+  (0.0ms) begin transaction
44
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:31:58.855684"], ["updated_at", "2016-05-27 13:31:58.855684"]]
45
+  (2.2ms) commit transaction
46
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
47
+  (0.0ms) begin transaction
48
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:32:11.842003"], ["updated_at", "2016-05-27 13:32:11.842003"]]
49
+  (2.4ms) commit transaction
50
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
51
+  (0.0ms) begin transaction
52
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:32:49.476375"], ["updated_at", "2016-05-27 13:32:49.476375"]]
53
+  (2.6ms) commit transaction
54
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
55
+  (0.0ms) begin transaction
56
+ SQL (0.3ms) INSERT INTO "users" ("name", "gender", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "f"], ["gender", "f"], ["created_at", "2016-05-27 13:33:00.356946"], ["updated_at", "2016-05-27 13:33:00.356946"]]
40
57
   (2.5ms) commit transaction
41
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
42
-  (0.1ms) begin transaction
43
- SQL (2.3ms) INSERT INTO "users" ("created_at", "gender", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 30 Jun 2014 22:13:48 UTC +00:00], ["gender", "f"], ["name", "f"], ["updated_at", Mon, 30 Jun 2014 22:13:48 UTC +00:00]]
44
-  (54.8ms) commit transaction
45
- User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
58
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
@@ -1,57 +1,63 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe User do
4
-
3
+ describe User, type: :model do
4
+
5
5
  describe "gender" do
6
-
6
+
7
7
  let(:user) { User.new(gender: "f") }
8
-
8
+
9
9
  it "should return a Gender object" do
10
- user.gender.should be_an_instance_of(Gender)
10
+ expect(user.gender).to be_an_instance_of(Genderize::Gender)
11
11
  end
12
-
12
+
13
13
  it "should be female?" do
14
- user.gender.should be_female
14
+ expect(user.gender).to be_female
15
15
  end
16
-
16
+
17
17
  it "should be male when changed" do
18
18
  user.gender = "m"
19
- user.gender.should be_male
19
+ expect(user.gender).to be_male
20
20
  end
21
-
21
+
22
+ it "should be blank when changed" do
23
+ user.gender = ""
24
+ expect(user.gender).to be_empty
25
+ end
26
+
22
27
  end
23
-
28
+
24
29
  describe "full gender names" do
25
-
30
+
26
31
  it 'should set the gender as the abbreviation' do
27
- User.new(gender: "female").gender.should be_female
28
- User.new(gender: "male").gender.should be_male
32
+ expect(User.new(gender: "female").gender).to be_female
33
+ expect(User.new(gender: "male").gender).to be_male
34
+ expect(User.new(gender: "").gender).to be_blank
29
35
  end
30
-
36
+
31
37
  end
32
38
  # Since the db column name can be changed, we're using the "name" column to
33
39
  # test this behaviour
34
40
  describe "name" do
35
-
41
+
36
42
  let(:user) { User.new(name: "f", gender: "f") }
37
-
43
+
38
44
  it "should return a Gender object" do
39
- user.name.should be_an_instance_of Gender
45
+ expect(user.name).to be_an_instance_of Genderize::Gender
40
46
  end
41
-
47
+
42
48
  it "should change the name column" do
43
49
  user.save!
44
50
  user = User.last
45
- user.name.should == "f"
46
- user.name.should be_female
51
+ expect(user.name).to eq("f")
52
+ expect(user.name).to be_female
47
53
  end
48
-
54
+
49
55
  it "should not change the gender column" do
50
56
  user.name = "m"
51
- user.name.should be_male
52
- user.gender.should_not be_male
57
+ expect(user.name).to be_male
58
+ expect(user.gender).not_to be_male
53
59
  end
54
-
60
+
55
61
  end
56
-
62
+
57
63
  end
@@ -1,232 +1,232 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Genderize::Gender do
4
-
4
+
5
5
  let(:female) { Gender.new("f") }
6
- let(:male) { Gender.new("M") }
7
- let(:blank) { Gender.new('') }
8
-
6
+ let(:male) { Gender.new("M") }
7
+ let(:blank) { Gender.new('') }
8
+
9
9
  context "when full gender name is used" do
10
-
10
+
11
11
  it "should find the correct abbreviation" do
12
- Gender.new("female").abbr.should eql('f')
13
- Gender.new("male").abbr.should eql('m')
12
+ expect(Gender.new("female").abbr).to eql('f')
13
+ expect(Gender.new("male").abbr).to eql('m')
14
14
  end
15
-
15
+
16
16
  end
17
-
18
-
17
+
18
+
19
19
  describe :name do
20
-
20
+
21
21
  context "when male" do
22
-
22
+
23
23
  it "should be 'male'" do
24
- male.name.should eql("male")
24
+ expect(male.name).to eql("male")
25
25
  end
26
-
26
+
27
27
  end
28
28
 
29
29
  context "when female" do
30
-
30
+
31
31
  it "should be 'female'" do
32
- female.name.should eql("female")
32
+ expect(female.name).to eql("female")
33
33
  end
34
-
34
+
35
35
  end
36
-
36
+
37
37
  context "when blank" do
38
-
38
+
39
39
  it "should be nil" do
40
- blank.name.should be_nil
40
+ expect(blank.name).to be_nil
41
41
  end
42
-
42
+
43
43
  end
44
-
45
-
44
+
45
+
46
46
  end
47
-
48
- describe :abbr do
49
-
47
+
48
+ describe :abbr do
49
+
50
50
  context "when male" do
51
-
51
+
52
52
  it "should be 'm'" do
53
- male.abbr.should eql("m")
53
+ expect(male.abbr).to eql("m")
54
54
  end
55
-
55
+
56
56
  end
57
57
 
58
58
  context "when female" do
59
-
59
+
60
60
  it "should be 'f'" do
61
- female.abbr.should eql("f")
61
+ expect(female.abbr).to eql("f")
62
62
  end
63
-
63
+
64
64
  end
65
-
65
+
66
66
  context "when blank" do
67
-
67
+
68
68
  it "should be nil" do
69
- blank.abbr.should be_nil
69
+ expect(blank.abbr).to be_nil
70
70
  end
71
-
71
+
72
72
  end
73
-
74
-
73
+
74
+
75
75
  end
76
-
76
+
77
77
  describe :subject do
78
-
78
+
79
79
  context "when male" do
80
-
80
+
81
81
  it "should be 'he'" do
82
- male.subject.should eql("he")
82
+ expect(male.subject).to eql("he")
83
83
  end
84
-
84
+
85
85
  end
86
86
 
87
87
  context "when female" do
88
-
88
+
89
89
  it "should be 'she'" do
90
- female.subject.should eql("she")
90
+ expect(female.subject).to eql("she")
91
91
  end
92
-
92
+
93
93
  end
94
-
94
+
95
95
  context "when blank" do
96
-
96
+
97
97
  it "should be nil" do
98
- blank.subject.should be_nil
98
+ expect(blank.subject).to be_nil
99
99
  end
100
-
100
+
101
101
  end
102
-
102
+
103
103
  end
104
-
104
+
105
105
  describe :object do
106
106
 
107
107
  context "when male" do
108
-
108
+
109
109
  it "should be 'him'" do
110
- male.object.should eql("him")
110
+ expect(male.object).to eql("him")
111
111
  end
112
-
112
+
113
113
  end
114
114
 
115
115
  context "when female" do
116
-
116
+
117
117
  it "should be 'her'" do
118
- female.object.should eql("her")
118
+ expect(female.object).to eql("her")
119
119
  end
120
-
120
+
121
121
  end
122
122
 
123
123
  context "when blank" do
124
-
124
+
125
125
  it "should be nil" do
126
- blank.object.should be_nil
126
+ expect(blank.object).to be_nil
127
127
  end
128
-
128
+
129
129
  end
130
130
 
131
-
131
+
132
132
  end
133
-
133
+
134
134
  describe :possessive do
135
-
135
+
136
136
  context "when male" do
137
-
137
+
138
138
  it "should be 'his'" do
139
- male.possessive.should eql("his")
139
+ expect(male.possessive).to eql("his")
140
140
  end
141
-
141
+
142
142
  end
143
143
 
144
144
  context "when female" do
145
-
145
+
146
146
  it "should be 'her'" do
147
- female.possessive.should eql("her")
147
+ expect(female.possessive).to eql("her")
148
148
  end
149
-
149
+
150
150
  end
151
-
151
+
152
152
  context "when blank" do
153
-
153
+
154
154
  it "should be nil" do
155
- blank.possessive.should be_nil
155
+ expect(blank.possessive).to be_nil
156
156
  end
157
-
157
+
158
158
  end
159
-
160
-
161
-
159
+
160
+
161
+
162
162
  end
163
-
163
+
164
164
  describe :casual do
165
-
165
+
166
166
  context "when male" do
167
-
167
+
168
168
  it "should be 'guy'" do
169
- male.casual.should eql("guy")
169
+ expect(male.casual).to eql("guy")
170
170
  end
171
-
171
+
172
172
  end
173
173
 
174
174
  context "when female" do
175
-
175
+
176
176
  it "should be 'girl'" do
177
- female.casual.should eql("girl")
177
+ expect(female.casual).to eql("girl")
178
178
  end
179
-
179
+
180
180
  end
181
-
181
+
182
182
  context "when blank" do
183
-
183
+
184
184
  it "should be nil" do
185
- blank.casual.should be_nil
185
+ expect(blank.casual).to be_nil
186
186
  end
187
-
187
+
188
188
  end
189
-
190
-
189
+
190
+
191
191
  end
192
-
192
+
193
193
  describe :to_s do
194
-
194
+
195
195
  it "should equal the abbr value" do
196
- male.to_s.should eql(male.abbr)
197
- female.to_s.should eql(female.abbr)
196
+ expect(male.to_s).to eql(male.abbr)
197
+ expect(female.to_s).to eql(female.abbr)
198
198
  end
199
-
199
+
200
200
  it "returns a string" do
201
- male.to_s.should be_an_instance_of(String)
202
- female.to_s.should be_an_instance_of(String)
201
+ expect(male.to_s).to be_an_instance_of(String)
202
+ expect(female.to_s).to be_an_instance_of(String)
203
203
  end
204
-
204
+
205
205
  end
206
-
206
+
207
207
  describe :capital_abbr do
208
-
208
+
209
209
  it "should equal the abbr value capitalized" do
210
- male.capital_abbr.should eql(male.abbr.capitalize)
211
- female.capital_abbr.should eql(female.abbr.capitalize)
210
+ expect(male.capital_abbr).to eql(male.abbr.capitalize)
211
+ expect(female.capital_abbr).to eql(female.abbr.capitalize)
212
212
  end
213
-
213
+
214
214
  end
215
-
215
+
216
216
  describe :== do
217
-
217
+
218
218
  it "should return true if passed abbr value" do
219
- (male == "m").should be_true
220
- (female == "f").should be_true
221
- (blank == nil).should be_true
219
+ expect(male == "m").to be_truthy
220
+ expect(female == "f").to be_truthy
221
+ expect(blank == nil).to be_truthy
222
222
  end
223
223
 
224
224
  it "should return false if not passed abbr value" do
225
- (male == "f").should be_false
226
- (female == 1).should be_false
227
- (blank == "$").should be_false
225
+ expect(male == "f").to be_falsey
226
+ expect(female == 1).to be_falsey
227
+ expect(blank == "$").to be_falsey
228
228
  end
229
-
229
+
230
230
  end
231
-
231
+
232
232
  end
@@ -5,9 +5,10 @@ require File.expand_path("../dummy/config/environment", __FILE__)
5
5
  require 'rspec/rails'
6
6
  require "support/deferred_garbage_collection"
7
7
 
8
- include Genderize
8
+ require "genderize"
9
+ include Genderize # make the Gender class available in specs
9
10
 
10
11
  RSpec.configure do |config|
11
12
  config.before(:all) { DeferredGarbageCollection.start }
12
- config.after(:all) { DeferredGarbageCollection.reconsider }
13
+ config.after(:all) { DeferredGarbageCollection.reconsider }
13
14
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genderize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodacious
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.13
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.13
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: A helpful class for gender-specific models in Ruby applications. Genderize
@@ -61,19 +61,21 @@ executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
+ - MIT-LICENSE
65
+ - README.md
66
+ - Rakefile
64
67
  - config/locales/genderize.en.yml
65
68
  - config/locales/genderize.es.yml
66
69
  - config/routes.rb
70
+ - lib/genderize.rb
67
71
  - lib/genderize/engine.rb
68
72
  - lib/genderize/gender.rb
69
73
  - lib/genderize/version.rb
70
- - lib/genderize.rb
71
- - lib/generators/genderize/install/install_generator.rb
72
74
  - lib/generators/genderize/install/USAGE
75
+ - lib/generators/genderize/install/install_generator.rb
73
76
  - lib/tasks/genderize_tasks.rake
74
- - MIT-LICENSE
75
- - Rakefile
76
- - README.md
77
+ - spec/dummy/README.rdoc
78
+ - spec/dummy/Rakefile
77
79
  - spec/dummy/app/helpers/users_helper.rb
78
80
  - spec/dummy/app/models/user.rb
79
81
  - spec/dummy/app/views/users/_form.html.erb
@@ -81,6 +83,7 @@ files:
81
83
  - spec/dummy/app/views/users/index.html.erb
82
84
  - spec/dummy/app/views/users/new.html.erb
83
85
  - spec/dummy/app/views/users/show.html.erb
86
+ - spec/dummy/config.ru
84
87
  - spec/dummy/config/application.rb
85
88
  - spec/dummy/config/boot.rb
86
89
  - spec/dummy/config/database.yml
@@ -96,15 +99,12 @@ files:
96
99
  - spec/dummy/config/initializers/wrap_parameters.rb
97
100
  - spec/dummy/config/locales/en.yml
98
101
  - spec/dummy/config/routes.rb
99
- - spec/dummy/config.ru
100
102
  - spec/dummy/db/development.sqlite3
101
103
  - spec/dummy/db/migrate/20130506080641_create_users.rb
102
104
  - spec/dummy/db/schema.rb
103
105
  - spec/dummy/db/test.sqlite3
104
106
  - spec/dummy/log/development.log
105
107
  - spec/dummy/log/test.log
106
- - spec/dummy/Rakefile
107
- - spec/dummy/README.rdoc
108
108
  - spec/dummy/script/rails
109
109
  - spec/dummy/spec/models/user_spec.rb
110
110
  - spec/genderize_spec.rb
@@ -121,17 +121,17 @@ require_paths:
121
121
  - lib
122
122
  required_ruby_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.1.11
134
+ rubygems_version: 2.6.3
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: A helpful class for gender-specific models in Ruby applications