rakeleak 0.3.0 → 0.4.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.
Files changed (32) hide show
  1. data/README.md +2 -8
  2. data/app/assets/javascripts/rakeleak/tasks.js +33 -28
  3. data/app/assets/stylesheets/rakeleak/tasks.css +32 -1
  4. data/app/controllers/rakeleak/tasks_controller.rb +1 -1
  5. data/app/views/rakeleak/tasks/_task.html.erb +24 -18
  6. data/app/views/rakeleak/tasks/index.html.erb +1 -5
  7. data/lib/rakeleak.rb +21 -3
  8. data/lib/rakeleak/version.rb +1 -1
  9. data/test/dummy/lib/tasks/env.rake +6 -0
  10. data/test/dummy/log/development.log +2477 -138846
  11. data/test/dummy/log/test.log +6 -21722
  12. data/test/dummy/tmp/cache/assets/C5E/440/sprockets%2Fba31529ca20206e11215433ee169332b +0 -0
  13. data/test/dummy/tmp/cache/assets/C9B/4A0/sprockets%2F798d65ca17a72755d92723797da97d24 +0 -0
  14. data/test/dummy/tmp/cache/assets/CE8/240/sprockets%2F777dce4d696645611f0ae85347dc00b7 +0 -0
  15. data/test/dummy/tmp/cache/assets/D02/6E0/sprockets%2F5db2ebf4409582ca15d8da402374e431 +0 -0
  16. data/test/dummy/tmp/cache/assets/D0D/370/sprockets%2Feda0592655569205d3738f32c4bdadf0 +0 -0
  17. data/test/dummy/tmp/cache/assets/D7B/DD0/sprockets%2F6f2905cdb5eed396c60140fbe94c9e66 +0 -0
  18. data/test/dummy/tmp/cache/assets/D8B/7C0/sprockets%2F5ef63b3be3860b7a1d2f1edbd1b08025 +0 -0
  19. data/test/dummy/tmp/cache/assets/D91/470/sprockets%2F80012ff0ade705b8eed3f36fa5ed5121 +0 -0
  20. data/test/dummy/tmp/cache/assets/D9C/D90/sprockets%2F383b39d58a0ed61af597d1ebdd2e01e5 +0 -0
  21. data/test/dummy/tmp/cache/assets/D9E/9F0/sprockets%2F3f8503a3d9bfee0922e881e8a32fccb2 +0 -0
  22. data/test/dummy/tmp/cache/assets/DB1/A30/sprockets%2F2cfcbef803fb9c40270c8846f6f983ef +0 -0
  23. data/test/dummy/tmp/cache/assets/DC5/D40/sprockets%2F7cf78f2e7bf164a14df03fcd0d0bd900 +0 -0
  24. data/test/dummy/tmp/cache/assets/DC8/880/sprockets%2F2ecbee3d3fdfbc150f65064a19ed9225 +0 -0
  25. data/test/dummy/tmp/cache/assets/DC9/730/sprockets%2F09cb8bd8fb2b5a925a9ef047cac34a53 +0 -0
  26. data/test/dummy/tmp/cache/assets/DD4/990/sprockets%2F2f127f8c0ebf8d16939a0efc14fe09ec +0 -0
  27. data/test/dummy/tmp/cache/assets/DDB/EA0/sprockets%2F2395acf962c33e59dc8655cafeab8e3d +0 -0
  28. data/test/dummy/tmp/cache/assets/DEB/510/sprockets%2F99aed1df3af79a258def18d7db49993c +0 -0
  29. data/test/dummy/tmp/cache/assets/E29/770/sprockets%2F3f8c60e8d26acb84da06d9aaac3cc7e5 +0 -0
  30. data/test/rakeleak_test.rb +48 -22
  31. metadata +4 -4
  32. data/test/dummy/lib/tasks/simple.rake +0 -6
@@ -10,64 +10,90 @@ class RakeleakTest < ActiveSupport::TestCase
10
10
  end
11
11
 
12
12
  test 'running existing task' do
13
- name = :simple
14
- Rake::Task.tasks << task(name) {|_| 'eval this string and stop' }
15
- assert_nothing_raised { Rakeleak.run(id: name) }
13
+ Rake::Task.tasks << task(:simple) {|_| 'eval this string and stop' }
14
+ assert_nothing_raised { Rakeleak.run(id: :simple) }
16
15
  end
17
16
 
18
17
  test 'running existing task throwing exception' do
19
- name = :exception
20
- message = 'simple exception'
21
- Rake::Task.tasks << task(name) {|_| raise message }
22
- assert_raise(RuntimeError) { Rakeleak.run(id: name) }
18
+ Rake::Task.tasks << task(:exception) {|_| raise 'simple exception' }
19
+ assert_raise(RuntimeError) { Rakeleak.run(id: :exception) }
23
20
  end
24
21
 
25
- test '::capture_stdout captures simple output by $stdout.puts' do
22
+ test '.capture_stdout captures simple output by $stdout.puts' do
26
23
  message = 'Hello, World'
27
24
  out = Rakeleak.capture_stdout { puts message }
28
25
  assert_equal "#{message}\n", out
29
26
  end
30
27
 
31
- test '::capture_stdout captures any output by $stdout.puts' do
28
+ test '.capture_stdout captures any output by $stdout.puts' do
32
29
  numbers = [1,2,3]
33
30
  out = Rakeleak.capture_stdout { numbers.each {|number| puts number } }
34
31
  assert_equal "#{numbers.join("\n")}\n", out
35
32
  end
36
33
 
37
- test '::capture_stdout captures output by p' do
34
+ test '.capture_stdout captures output by p' do
38
35
  object = OpenStruct.new
39
36
  object.x, object.y = 1, 2
40
37
  out = Rakeleak.capture_stdout { p object }
41
38
  assert_equal "#{object}\n", out
42
39
  end
43
40
 
44
- test '::capture_stdout returns nothing if there is no output to stdout' do
41
+ test '.capture_stdout returns nothing if there is no output to stdout' do
45
42
  assert_equal '', Rakeleak.capture_stdout { true }
46
43
  end
47
44
 
48
- test '::capture_stdout returns nothing if there is no block given' do
45
+ test '.capture_stdout returns nothing if there is no block given' do
49
46
  assert_equal '', Rakeleak.capture_stdout
50
47
  end
51
48
 
52
- test '::capture_stdout throws an exception from block' do
49
+ test '.capture_stdout throws an exception from block' do
53
50
  assert_raise(RuntimeError) { Rakeleak.capture_stdout { raise 'any exception' } }
54
51
  end
55
52
 
56
53
  test 'loading rake task arguments' do
57
- name = :args
58
- Rake::Task.tasks << task(name, [:arg1, :arg2])
59
- assert_equal [:foo, :bar], Rakeleak.args(id: name, arg1: :foo, arg2: :bar)
54
+ Rake::Task.tasks << task(:args, [:arg1, :arg2])
55
+ assert_equal [:foo, :bar], Rakeleak.args(id: :args, arg1: :foo, arg2: :bar)
60
56
  end
61
57
 
62
58
  test 'filtering rake task arguments if there is no any' do
63
- name = :filtered_args
64
- Rake::Task.tasks << task(name, [:arg1, :arg2])
65
- assert_equal [], Rakeleak.args(id: name, some_value: 1)
59
+ Rake::Task.tasks << task(:filtered_args, [:arg1, :arg2])
60
+ assert_equal [], Rakeleak.args(id: :filtered_args, some_value: 1)
66
61
  end
67
62
 
68
63
  test 'running task with arguments' do
69
- name = :with_args
70
- Rake::Task.tasks << task(name, [:arg1, :arg2]) {|_, args| puts "#{args[:arg1]}#{args[:arg2]}" }
71
- assert_equal "foobar\n", Rakeleak.run(id: name, arg1: 'foo', arg2: 'bar')
64
+ Rake::Task.tasks << task(:with_args, [:arg1, :arg2]) {|_, args| puts "#{args[:arg1]}#{args[:arg2]}" }
65
+ assert_equal "foobar\n", Rakeleak.run(id: :with_args, arg1: 'foo', arg2: 'bar')
66
+ end
67
+
68
+ test 'passing new environment variable' do
69
+ key = 'RAKELEAK'
70
+ Rake::Task.tasks << task(:with_new_env_var) { assert_equal 'value', ENV[key] }
71
+ Rakeleak.run(id: :with_new_env_var, env: "#{key}=value")
72
+ assert_equal false, ENV.include?(key)
73
+ end
74
+
75
+ test 'passing existing environment variable' do
76
+ key = 'RAKELEAK'
77
+ value = 'value'
78
+ ENV[key] = value
79
+ Rake::Task.tasks << task(:with_env_var) { assert_equal 'new value', ENV[key] }
80
+ Rakeleak.run(id: :with_env_var, env: "#{key}=new value")
81
+ assert_equal true, ENV.include?(key)
82
+ assert_equal value, ENV[key]
83
+ ENV.delete(key)
84
+ end
85
+
86
+ test 'passing empty environment variable' do
87
+ res = :pending
88
+ Rake::Task.tasks << task(:with_empty_env_var) { res = :done }
89
+ Rakeleak.run(id: :with_empty_env_var, env: '')
90
+ assert_equal :done, res
91
+ end
92
+
93
+ test 'passing incorrect environment variable' do
94
+ res = :pending
95
+ Rake::Task.tasks << task(:with_incorrect_env_var) { res = :done }
96
+ Rakeleak.run(id: :with_incorrect_env_var, env: 'RAKELEAK')
97
+ assert_equal :done, res
72
98
  end
73
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakeleak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-17 00:00:00.000000000 Z
12
+ date: 2013-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -121,8 +121,8 @@ files:
121
121
  - test/dummy/config/locales/en.yml
122
122
  - test/dummy/config/routes.rb
123
123
  - test/dummy/config.ru
124
+ - test/dummy/lib/tasks/env.rake
124
125
  - test/dummy/lib/tasks/error.rake
125
- - test/dummy/lib/tasks/simple.rake
126
126
  - test/dummy/lib/tasks/timerror.rake
127
127
  - test/dummy/lib/tasks/wait_3_sec.rake
128
128
  - test/dummy/lib/tasks/with_args.rake
@@ -205,8 +205,8 @@ test_files:
205
205
  - test/dummy/config/locales/en.yml
206
206
  - test/dummy/config/routes.rb
207
207
  - test/dummy/config.ru
208
+ - test/dummy/lib/tasks/env.rake
208
209
  - test/dummy/lib/tasks/error.rake
209
- - test/dummy/lib/tasks/simple.rake
210
210
  - test/dummy/lib/tasks/timerror.rake
211
211
  - test/dummy/lib/tasks/wait_3_sec.rake
212
212
  - test/dummy/lib/tasks/with_args.rake
@@ -1,6 +0,0 @@
1
- namespace :rakeleak do
2
- desc 'The simplest task ever'
3
- task :simple => :environment do
4
- puts 'Hello, World!'
5
- end
6
- end