guts 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,90 @@
1
+ require "test_helper"
2
+
3
+ module Guts
4
+ class UsersTaskTest < ActiveSupport::TestCase
5
+ setup do
6
+ Rake::Task.define_task :environment
7
+ Guts::Engine.load_tasks
8
+ end
9
+
10
+ teardown do
11
+ Rake::Task.clear
12
+ end
13
+
14
+ test "user should be created" do
15
+ out, err = capture_io do
16
+ Rake::Task["guts:user:create"].invoke("Tom Jones", "tom.jones@gmail.com", "password", true)
17
+ end
18
+
19
+ assert_equal "[Guts] User created", out.chomp
20
+ end
21
+
22
+ test "user should not be created when missing information" do
23
+ exception = assert_raises StandardError do
24
+ capture_io do
25
+ Rake::Task["guts:user:create"].invoke("Tom Jones", "tom.jones@gmail.com")
26
+ end
27
+ end
28
+
29
+ assert_match "[Guts] Please enter name, email, and a password", exception.message
30
+ end
31
+
32
+ test "user should be deleted" do
33
+ out, err = capture_io do
34
+ Rake::Task["guts:user:create"].invoke("Tom Joneser", "tom.joneser@gmail.com", "password", true)
35
+ Rake::Task["guts:user:delete"].invoke("tom.joneser@gmail.com")
36
+ end
37
+
38
+ assert_match /User destroyed/, out.chomp
39
+ end
40
+
41
+ test "user should not be deleted if missing information" do
42
+ exception = assert_raises ArgumentError do
43
+ capture_io do
44
+ Rake::Task["guts:user:delete"].invoke
45
+ end
46
+ end
47
+
48
+ assert_equal "[Guts] Please enter an email", exception.message
49
+ end
50
+
51
+ test "user should not be deleted if they dont exist" do
52
+ exception = assert_raises StandardError do
53
+ capture_io do
54
+ Rake::Task["guts:user:delete"].invoke("timmy.kimble@gmail.com")
55
+ end
56
+ end
57
+
58
+ assert_equal "[Guts] User not found", exception.message
59
+ end
60
+
61
+ test "should set new password for user" do
62
+ out, err = capture_io do
63
+ Rake::Task["guts:user:create"].invoke("Tom Jonesed", "tom.jonesed@gmail.com", "password", true)
64
+ Rake::Task["guts:user:new_password"].invoke("tom.jonesed@gmail.com", "password_2")
65
+ end
66
+
67
+ assert_match /New password/, out.chomp
68
+ end
69
+
70
+ test "should not set new password for user if they dont exist" do
71
+ exception = assert_raises StandardError do
72
+ capture_io do
73
+ Rake::Task["guts:user:new_password"].invoke("timmy.kimble@gmail.com", "password_2")
74
+ end
75
+ end
76
+
77
+ assert_equal "[Guts] User not found", exception.message
78
+ end
79
+
80
+ test "should not set password for user if missing information" do
81
+ exception = assert_raises ArgumentError do
82
+ capture_io do
83
+ Rake::Task["guts:user:new_password"].invoke
84
+ end
85
+ end
86
+
87
+ assert_equal "[Guts] Please enter a password and an email", exception.message
88
+ end
89
+ end
90
+ end
@@ -5,6 +5,8 @@ unless ENV["NO_COVERAGE"]
5
5
  SimpleCov.start "rails" do
6
6
  add_group "Concerns", "/app/concerns"
7
7
  add_filter "lib/guts/version.rb" # No need to test version file... doesnt work.
8
+ add_filter "lib/tasks/guts_tasks.rake" # Inconsistant coverage reports, not sure why
9
+ add_filter "lib/tasks/guts_users.rake" # Inconsistant coverage reports, not sure why
8
10
  end
9
11
  end
10
12
 
@@ -23,6 +25,9 @@ require "webmock/minitest"
23
25
  # to be shown.
24
26
  Minitest.backtrace_filter = Minitest::BacktraceFilter.new
25
27
 
28
+ # For rake tests
29
+ require "rake"
30
+
26
31
  # Load support files
27
32
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
28
33
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -484,8 +484,10 @@ files:
484
484
  - test/dummy/config/locales/en.yml
485
485
  - test/dummy/config/routes.rb
486
486
  - test/dummy/config/secrets.yml
487
+ - test/dummy/db/development.sqlite3
487
488
  - test/dummy/db/schema.rb
488
489
  - test/dummy/db/test.sqlite3
490
+ - test/dummy/log/development.log
489
491
  - test/dummy/log/test.log
490
492
  - test/dummy/public/404.html
491
493
  - test/dummy/public/422.html
@@ -667,6 +669,7 @@ files:
667
669
  - test/models/guts/type_test.rb
668
670
  - test/models/guts/user_test.rb
669
671
  - test/support/guts/login_support.rb
672
+ - test/tasks/guts/users_task_test.rb
670
673
  - test/test_helper.rb
671
674
  homepage: http://tylerking.me/
672
675
  licenses:
@@ -737,8 +740,10 @@ test_files:
737
740
  - test/dummy/config/routes.rb
738
741
  - test/dummy/config/secrets.yml
739
742
  - test/dummy/config.ru
743
+ - test/dummy/db/development.sqlite3
740
744
  - test/dummy/db/schema.rb
741
745
  - test/dummy/db/test.sqlite3
746
+ - test/dummy/log/development.log
742
747
  - test/dummy/log/test.log
743
748
  - test/dummy/public/404.html
744
749
  - test/dummy/public/422.html
@@ -922,5 +927,6 @@ test_files:
922
927
  - test/models/guts/type_test.rb
923
928
  - test/models/guts/user_test.rb
924
929
  - test/support/guts/login_support.rb
930
+ - test/tasks/guts/users_task_test.rb
925
931
  - test/test_helper.rb
926
932
  has_rdoc: