datum 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,8 @@ module Datum
11
11
  end
12
12
 
13
13
  def migrate
14
- ActiveRecord::Base.establish_connection(Rails.env)
14
+ # Not 100% sure why other methods of connecting are failing...
15
+ # Rake::Task['db:create'].invoke()
15
16
  ActiveRecord::Migrator.migrate "#{@@local_path}/migrate"
16
17
  end
17
18
 
@@ -2,6 +2,18 @@
2
2
  module Datum
3
3
  class EnableTask
4
4
 
5
+ def disable_user_questions
6
+ @@ask_user = false
7
+ end
8
+
9
+ def disable_verification
10
+ @@use_verification = false
11
+ end
12
+
13
+ def datum_directories
14
+ return @@directories
15
+ end
16
+
5
17
  def rock
6
18
  puts "\n Enabling Datum Data-Driven Testing Tools."
7
19
  create_directories
@@ -9,13 +21,18 @@ module Datum
9
21
  update_yml if @@update_yml
10
22
  update_app if @@update_app
11
23
 
12
- (Datum::VerificationTask.new).verify
24
+ if @@use_verification
25
+ verifier = Datum::VerificationTask.new
26
+ verifier.disable_user_questions if !@@ask_user
27
+ verifier.rock
28
+ end
13
29
 
14
30
  puts " Datum enabled.\n "
15
31
  end
16
32
 
17
33
  private
18
- @@application_path = @@info = nil
34
+ @@use_verification = @@ask_user = true
35
+ @@directories = @@application_path = @@info = nil
19
36
  @@update_app = @@update_yml = false
20
37
  @@datum_drop_path = "test/lib/datum"
21
38
  @@datum_model_path = 'config.autoload_paths += %W(#{Rails.root}/' +
@@ -26,9 +43,13 @@ module Datum
26
43
  #"config.autoload_paths.*#{encoded_path}\/models"
27
44
 
28
45
  def create_directories
29
- ["#{@@datum_drop_path}/fixtures", "#{@@datum_drop_path}/locals",
30
- "#{@@datum_drop_path}/migrate", "#{@@datum_drop_path}/models"].each {
31
- |path| FileUtils.mkdir_p(path) if !File::directory?(path)}
46
+ @@directories = ["#{@@datum_drop_path}/fixtures",
47
+ "#{@@datum_drop_path}/locals", "#{@@datum_drop_path}/migrate",
48
+ "#{@@datum_drop_path}/models"]
49
+
50
+ @@directories.each {
51
+ |path| FileUtils.mkdir_p(path) if !File::directory?(path)
52
+ }
32
53
 
33
54
  puts " Datum directories created."
34
55
  end
@@ -46,12 +67,15 @@ module Datum
46
67
  puts " Files that may need updates: "
47
68
  puts " database.yml" if @@update_yml
48
69
  puts " application.rb" if @@update_app
49
- puts "\n>>>>>>>>>>>>>>>> Attempt updates for you? y/n"
50
- continue = STDIN.gets.chomp
51
- unless continue == 'y' || continue == 'yes'
52
- puts "\n Files must be updated manually to fully enable Datum"
53
- puts " Run rake task 'datum:db:verify' after manual update.\n "
54
- exit!
70
+
71
+ if @@ask_user
72
+ puts "\n>>>>>>>>>>>>>>>> Attempt updates for you? y/n"
73
+ continue = STDIN.gets.chomp
74
+ unless continue == 'y' || continue == 'yes'
75
+ puts "\n Files must be updated manually to fully enable Datum"
76
+ puts " Run rake task 'datum:db:verify' after manual update.\n "
77
+ exit!
78
+ end
55
79
  end
56
80
  end
57
81
 
@@ -4,16 +4,23 @@ module Datum
4
4
  # intended to be used as part of enable to report datum readiness
5
5
  class VerificationTask
6
6
 
7
- def verify
7
+
8
+ def disable_user_questions
9
+ @@ask_user = false
10
+ end
11
+
12
+ def rock
8
13
 
9
14
  puts "\n### !!!Datum Verification !!!"
10
15
  puts "### !!!This command DROPS the Datum Database!!!"
11
- puts "\n>>>>>>>>>>>>>>>> Proceed with Datum Verification? y/n"
12
- continue = STDIN.gets.chomp
13
-
14
- unless continue == 'y' || continue == 'yes'
15
- puts "\n ... Canceling Datum Verification\n "
16
- exit!
16
+
17
+ if @@ask_user
18
+ puts "\n>>>>>>>>>>>>>>>> Proceed with Datum Verification? y/n"
19
+ continue = STDIN.gets.chomp
20
+ unless continue == 'y' || continue == 'yes'
21
+ puts "\n ... Canceling Datum Verification\n "
22
+ exit!
23
+ end
17
24
  end
18
25
 
19
26
  database_ready = false
@@ -101,6 +108,7 @@ module Datum
101
108
  end
102
109
 
103
110
  private
111
+ @@ask_user = true
104
112
  @@local_path = "#{Rails.root}/test/lib/datum"
105
113
  @@gem_path = File.expand_path(File.dirname(__FILE__))
106
114
  @@migration_file = "20120726105125_create_datum_versions.rb"
data/lib/datum/version.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Datum
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
4
4
 
5
- ## Added datum:db:verify to simplify pre-release holes in config
5
+ ## Added datum:db:verify to simplify detecting pre-release holes in config
6
+ ## Added tests to formally sign-off datum releases
data/lib/tasks/datum.rake CHANGED
@@ -5,32 +5,32 @@ require "datum/db_tasks"
5
5
  namespace :datum do
6
6
 
7
7
  desc "Enable datum functionality"
8
- task :enable do
8
+ task :enable => :environment do
9
9
  (Datum::EnableTask.new).rock
10
10
  end
11
11
 
12
12
  namespace :db do
13
13
 
14
14
  desc "Create datum database"
15
- task :create do invoke "create" end
15
+ task :create => :environment do invoke "create" end
16
16
 
17
17
  desc "Migrate datum database"
18
- task :migrate do invoke "migrate" end
18
+ task :migrate => :environment do invoke "migrate" end
19
19
 
20
20
  desc "Drop datum database"
21
- task :drop do invoke "drop" end
21
+ task :drop => :environment do invoke "drop" end
22
22
 
23
23
  desc "Dump data as fixtures from datum database"
24
- task :dump do invoke "dump" end
24
+ task :dump => :environment do invoke "dump" end
25
25
 
26
26
  desc "Loads fixtures specific to datum database"
27
- task :load do invoke "load" end
27
+ task :load => :environment do invoke "load" end
28
28
 
29
29
  #desc "Quick verification of basic datum functionality"
30
30
  #task :verify do invoke "verify" end
31
31
 
32
32
  desc "Enables datum execution without database dependency"
33
- task :localize, :table do |t, args|
33
+ task :localize, [:table] => [:environment] do |t, args|
34
34
  (Datum::DbTasks.new).localize args
35
35
  end
36
36
 
data/test/datum_test.rb CHANGED
@@ -3,13 +3,13 @@ require 'rake'
3
3
 
4
4
  class DatumTest < ActiveSupport::TestCase
5
5
 
6
- test "db_migrate should migrate" do
7
-
8
- # Rake.application.rake_require "tasks/datum"
9
- # DatumTasks.migrate
10
- # assert_equal 0, 1, "Nope"
11
-
12
- end
6
+ #test "db_migrate should migrate" do
7
+ # puts "this is the second test...."
8
+ # Rake.application.rake_require "tasks/datum"
9
+ # DatumTasks.migrate
10
+ # assert_equal 0, 1, "Nope"
11
+ # puts "... Path: #{Rails.env}"
12
+ #end
13
13
 
14
14
  # test "truth" do
15
15
  # assert_kind_of Module, Datum
@@ -11,7 +11,7 @@ module Dummy
11
11
  # Added as part of datum install, enables access to datum specific models
12
12
  config.autoload_paths += %W(#{Rails.root}/test/lib/datum/models)
13
13
 
14
-
14
+
15
15
  # Settings in config/environments/* take precedence over those specified here.
16
16
  # Application configuration should go into files in config/initializers
17
17
  # -- all .rb files in that directory are automatically loaded.
@@ -0,0 +1,57 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+ require "datum"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Custom directories with classes and modules you want to be autoloadable.
16
+ # config.autoload_paths += %W(#{config.root}/extras)
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named.
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running.
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # Configure the default encoding used in templates for Ruby 1.9.
34
+ config.encoding = "utf-8"
35
+
36
+ # Configure sensitive parameters which will be filtered from the log file.
37
+ config.filter_parameters += [:password]
38
+
39
+ # Use SQL instead of Active Record's schema dumper when creating the database.
40
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
41
+ # like if you have constraints or database-specific column types
42
+ # config.active_record.schema_format = :sql
43
+
44
+ # Enforce whitelist mode for mass assignment.
45
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
46
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
47
+ # parameters by using an attr_accessible or attr_protected declaration.
48
+ # config.active_record.whitelist_attributes = true
49
+
50
+ # Enable the asset pipeline
51
+ config.assets.enabled = true
52
+
53
+ # Version of your assets, change this if you want to expire all your assets
54
+ config.assets.version = '1.0'
55
+ end
56
+ end
57
+
@@ -0,0 +1,42 @@
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MYSQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11
+ development:
12
+ adapter: mysql2
13
+ encoding: utf8
14
+ reconnect: false
15
+ database: datum_dummy_development
16
+ pool: 5
17
+ username: root
18
+ password:
19
+ socket: /tmp/mysql.sock
20
+
21
+ # Warning: The database defined as "test" will be erased and
22
+ # re-generated from your development database when you run "rake".
23
+ # Do not set this db to the same as development or production.
24
+ test:
25
+ adapter: mysql2
26
+ encoding: utf8
27
+ reconnect: false
28
+ database: datum_dummy_test
29
+ pool: 5
30
+ username: root
31
+ password:
32
+ socket: /tmp/mysql.sock
33
+
34
+ production:
35
+ adapter: mysql2
36
+ encoding: utf8
37
+ reconnect: false
38
+ database: datum_dummy_production
39
+ pool: 5
40
+ username: root
41
+ password:
42
+ socket: /tmp/mysql.sock
@@ -0,0 +1,70 @@
1
+ require 'test_helper'
2
+ require "datum/enable_task"
3
+
4
+ class EnableTaskTest < ActiveSupport::TestCase
5
+
6
+ def setup
7
+ @enableTask = Datum::EnableTask.new
8
+ @enableTask.disable_user_questions
9
+ @enableTask.disable_verification
10
+ end
11
+
12
+ def call_enable
13
+ assert_nothing_raised do
14
+ @enableTask.rock
15
+ end
16
+ end
17
+
18
+ test "enable should create directories" do
19
+ call_enable
20
+ dirs = @enableTask.datum_directories
21
+ assert_not_nil dirs, "Enable Task directories should not be nil"
22
+
23
+ dirs.each { |directory|
24
+ assert File.directory?(directory),
25
+ "Enable Task did not create directory: #{directory}"
26
+ }
27
+ end
28
+
29
+ test "post call to need_yml should return false" do
30
+ call_enable
31
+ assert false == @enableTask.send(:need_yml?),
32
+ "need_yml? did not detect new yml section"
33
+ end
34
+
35
+ test "post call to need_app should return false" do
36
+ call_enable
37
+ assert false == @enableTask.send(:need_app?),
38
+ "need_app? did not detect new config add-in"
39
+ end
40
+
41
+ test "clean database.yml should yield true need_yml" do
42
+
43
+ clean_yml = "#{Rails.env}/dummy/test/lib/datum/utils/database.yml"
44
+ config_dir = "#{Rails.env}/dummy/config/database.yml"
45
+
46
+ FileUtils.cp(clean_yml, config_dir)
47
+
48
+ assert true == @enableTask.send(:need_yml?),
49
+ "need_yml? should have returned true with a clean yml"
50
+
51
+ test_post_call_to_need_yml_should_return_false
52
+ end
53
+
54
+ test "clean application.rb should yield true need_app" do
55
+
56
+ clean_app = "#{Rails.env}/dummy/test/lib/datum/utils/application.rb"
57
+ config_app = "#{Rails.env}/dummy/config/application.rb"
58
+
59
+ FileUtils.cp(clean_app, config_app)
60
+
61
+ assert true == @enableTask.send(:need_app?),
62
+ "need_app? should have returned true with a clean application.rb"
63
+
64
+ test_post_call_to_need_app_should_return_false
65
+
66
+ end
67
+
68
+
69
+
70
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-27 00:00:00.000000000 Z
13
+ date: 2012-08-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &70155510735080 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,7 +22,12 @@ dependencies:
22
22
  version: 3.2.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70155510735080
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 3.2.1
26
31
  description: Flexible data-driven test solution for Rails
27
32
  email:
28
33
  - datum@tyemill.com
@@ -75,8 +80,6 @@ files:
75
80
  - test/dummy/config/routes.rb
76
81
  - test/dummy/config.ru
77
82
  - test/dummy/db/schema.rb
78
- - test/dummy/log/development.log
79
- - test/dummy/log/test.log
80
83
  - test/dummy/public/404.html
81
84
  - test/dummy/public/422.html
82
85
  - test/dummy/public/500.html
@@ -84,8 +87,10 @@ files:
84
87
  - test/dummy/Rakefile
85
88
  - test/dummy/README.rdoc
86
89
  - test/dummy/script/rails
90
+ - test/dummy/test/lib/datum/utils/application.rb
91
+ - test/dummy/test/lib/datum/utils/database.yml
87
92
  - test/dummy/test/test_helper.rb
88
- - test/dummy/test/unit/simple_model_test.rb
93
+ - test/dummy/test/unit/enable_task_test.rb
89
94
  - test/test_helper.rb
90
95
  homepage: https://github.com/tyemill/datum
91
96
  licenses: []
@@ -101,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
106
  version: '0'
102
107
  segments:
103
108
  - 0
104
- hash: 2549513625839685057
109
+ hash: -1610739616957127343
105
110
  required_rubygems_version: !ruby/object:Gem::Requirement
106
111
  none: false
107
112
  requirements:
@@ -110,10 +115,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
115
  version: '0'
111
116
  segments:
112
117
  - 0
113
- hash: 2549513625839685057
118
+ hash: -1610739616957127343
114
119
  requirements: []
115
120
  rubyforge_project:
116
- rubygems_version: 1.8.15
121
+ rubygems_version: 1.8.24
117
122
  signing_key:
118
123
  specification_version: 3
119
124
  summary: Flexible data-driven test solution for Rails
@@ -143,8 +148,6 @@ test_files:
143
148
  - test/dummy/config/routes.rb
144
149
  - test/dummy/config.ru
145
150
  - test/dummy/db/schema.rb
146
- - test/dummy/log/development.log
147
- - test/dummy/log/test.log
148
151
  - test/dummy/public/404.html
149
152
  - test/dummy/public/422.html
150
153
  - test/dummy/public/500.html
@@ -152,6 +155,8 @@ test_files:
152
155
  - test/dummy/Rakefile
153
156
  - test/dummy/README.rdoc
154
157
  - test/dummy/script/rails
158
+ - test/dummy/test/lib/datum/utils/application.rb
159
+ - test/dummy/test/lib/datum/utils/database.yml
155
160
  - test/dummy/test/test_helper.rb
156
- - test/dummy/test/unit/simple_model_test.rb
161
+ - test/dummy/test/unit/enable_task_test.rb
157
162
  - test/test_helper.rb
@@ -1,17 +0,0 @@
1
- Connecting to database specified by database.yml
2
- Connecting to database specified by database.yml
3
-  (87.1ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
4
-  (188.3ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
5
-  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
6
-  (1.9ms) DROP DATABASE IF EXISTS `datum_dummy_test`
7
-  (0.2ms) CREATE DATABASE `datum_dummy_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
8
- Connecting to database specified by database.yml
9
-  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
10
- Connecting to database specified by database.yml
11
-  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
12
-  (0.4ms) DROP DATABASE IF EXISTS `datum_dummy_test`
13
-  (0.2ms) CREATE DATABASE `datum_dummy_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
14
-  (19.0ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
15
-  (14.4ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
16
-  (0.2ms) SELECT version FROM `schema_migrations`
17
-  (0.5ms) INSERT INTO `schema_migrations` (version) VALUES ('0')
@@ -1,25 +0,0 @@
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
-  (0.2ms) BEGIN
5
-  (0.0ms) ROLLBACK
6
- Connecting to database specified by database.yml
7
-  (0.1ms) BEGIN
8
-  (0.1ms) ROLLBACK
9
-  (0.1ms) BEGIN
10
-  (0.0ms) ROLLBACK
11
- Connecting to database specified by database.yml
12
-  (0.1ms) BEGIN
13
-  (0.2ms) ROLLBACK
14
- Connecting to database specified by database.yml
15
-  (0.0ms) BEGIN
16
-  (0.0ms) ROLLBACK
17
- Connecting to database specified by database.yml
18
-  (0.1ms) BEGIN
19
-  (0.1ms) ROLLBACK
20
- Connecting to database specified by database.yml
21
-  (0.1ms) BEGIN
22
-  (0.1ms) ROLLBACK
23
- Connecting to database specified by database.yml
24
-  (0.0ms) BEGIN
25
-  (0.1ms) ROLLBACK
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SimpleModelTest
4
- test "should pass" do
5
-
6
- end
7
- end