test_notifier 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "http://gems.simplesideias.com.br"
1
+ source :rubygems
2
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,22 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_notifier (1.0.0)
4
+ test_notifier (1.0.1)
5
5
  notifier
6
6
 
7
7
  GEM
8
- remote: http://gems.simplesideias.com.br/
8
+ remote: http://rubygems.org/
9
9
  specs:
10
- mocha (0.9.12)
11
- notifier (0.1.4)
12
- rake (0.9.2)
13
- test-unit (2.2.0)
10
+ diff-lcs (1.1.3)
11
+ notifier (0.2.1)
12
+ rake (0.9.2.2)
13
+ rspec (2.11.0)
14
+ rspec-core (~> 2.11.0)
15
+ rspec-expectations (~> 2.11.0)
16
+ rspec-mocks (~> 2.11.0)
17
+ rspec-core (2.11.1)
18
+ rspec-expectations (2.11.3)
19
+ diff-lcs (~> 1.1.3)
20
+ rspec-mocks (2.11.2)
14
21
 
15
22
  PLATFORMS
16
23
  ruby
17
24
 
18
25
  DEPENDENCIES
19
- mocha
20
26
  rake
21
- test-unit
27
+ rspec
22
28
  test_notifier!
data/Rakefile CHANGED
@@ -1,10 +1,5 @@
1
1
  require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require "rake/testtask"
5
- Rake::TestTask.new do |t|
6
- t.libs += %w[test lib]
7
- t.ruby_opts = %w[-rubygems]
8
- t.test_files = FileList["test/**/*_test.rb"]
9
- t.verbose = true
10
- end
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new
@@ -8,7 +8,7 @@ MiniTest::Unit.after_tests do
8
8
  :count => runner.test_count,
9
9
  :assertions => runner.assertion_count,
10
10
  :failures => runner.failures,
11
- :errors => runner.skips
11
+ :errors => runner.errors
12
12
  })
13
13
 
14
14
  TestNotifier.notify(:status => stats.status, :message => stats.message)
@@ -2,7 +2,7 @@ module TestNotifier
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 0
5
+ PATCH = 1
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/lib/test_notifier.rb CHANGED
@@ -48,6 +48,6 @@ module TestNotifier
48
48
  notifier
49
49
  end
50
50
 
51
- autoload :Runner, "test_notifier/runner"
52
- autoload :Stats, "test_notifier/stats"
51
+ require "test_notifier/runner"
52
+ require "test_notifier/stats"
53
53
  end
@@ -0,0 +1,13 @@
1
+ require "test_notifier"
2
+
3
+ module SpecHelpers
4
+ def unsupport_all_notifiers
5
+ Notifier.notifiers.each do |notifier|
6
+ notifier.stub :supported? => false unless notifier == Notifier::Placebo
7
+ end
8
+ end
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ config.include SpecHelpers
13
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe TestNotifier::Stats, "MiniTest" do
4
+ subject(:stats) { TestNotifier::Stats.new(:minitest) }
5
+
6
+ it "returns success message" do
7
+ stats.options = { :count => 10, :assertions => 20 }
8
+ expect(stats.message).to eql("10 tests, 20 assertions")
9
+ end
10
+
11
+ it "message with failing examples" do
12
+ stats.options = { :count => 10, :assertions => 20, :failures => 5 }
13
+ expect(stats.message).to eql("10 tests, 20 assertions, 5 failed")
14
+ end
15
+
16
+ it "message with error examples" do
17
+ stats.options = { :count => 10, :assertions => 20, :errors => 5 }
18
+ expect(stats.message).to eql("10 tests, 20 assertions, 5 errors")
19
+ end
20
+
21
+ it "message with all types" do
22
+ stats.options = { :count => 6, :failures => 2, :errors => 3, :assertions => 20 }
23
+ expect(stats.message).to eql("6 tests, 20 assertions, 2 failed, 3 errors")
24
+ end
25
+ end
26
+
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe TestNotifier::Stats, "RSpec 1" do
4
+ subject(:stats) { TestNotifier::Stats.new(:spec) }
5
+
6
+ it "returns success message" do
7
+ stats.options = { :count => 10 }
8
+ expect(stats.message).to eql("10 examples")
9
+ end
10
+
11
+ it "returns message with failing examples" do
12
+ stats.options = { :count => 10, :failures => 5 }
13
+ expect(stats.message).to eql("10 examples, 5 failed")
14
+ end
15
+
16
+ it "returns message with pending examples" do
17
+ stats.options = { :count => 10, :pending => 5 }
18
+ expect(stats.message).to eql("10 examples, 5 pending")
19
+ end
20
+
21
+ it "returns message with all types" do
22
+ stats.options = { :count => 6, :failures => 2, :pending => 3 }
23
+ expect(stats.message).to eql("6 examples, 2 failed, 3 pending")
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe TestNotifier::Stats, "RSpec" do
4
+ subject(:stats) { TestNotifier::Stats.new(:rspec) }
5
+
6
+ it "returns success message" do
7
+ stats.options = { :count => 10 }
8
+ expect(stats.message).to eql("10 examples")
9
+ end
10
+
11
+ it "returns message with failing examples" do
12
+ stats.options = { :count => 10, :failures => 5 }
13
+ expect(stats.message).to eql("10 examples, 5 failed")
14
+ end
15
+
16
+ it "returns message with pending examples" do
17
+ stats.options = { :count => 10, :pending => 5 }
18
+ expect(stats.message).to eql("10 examples, 5 pending")
19
+ end
20
+
21
+ it "returns message with error examples" do
22
+ stats.options = { :count => 10, :failures => 5, :errors => 5 }
23
+ expect(stats.message).to eql("10 examples, 5 failed, 5 errors")
24
+ end
25
+
26
+ it "returns message with all types" do
27
+ stats.options = { :count => 6, :failures => 3, :errors => 2, :pending => 3 }
28
+ expect(stats.message).to eql("6 examples, 3 failed, 3 pending, 2 errors")
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe TestNotifier::Stats, "TestUnit" do
4
+ subject(:stats) { TestNotifier::Stats.new(:test_unit) }
5
+
6
+ it "returns success message" do
7
+ stats.options = { :count => 10, :assertions => 20 }
8
+ expect(stats.message).to eql("10 tests, 20 assertions")
9
+ end
10
+
11
+ it "returns message with failing examples" do
12
+ stats.options = { :count => 10, :assertions => 20, :failures => 5 }
13
+ expect(stats.message).to eql("10 tests, 20 assertions, 5 failed")
14
+ end
15
+
16
+ it "message with error examples" do
17
+ stats.options = { :count => 10, :assertions => 20, :errors => 5 }
18
+ expect(stats.message).to eql("10 tests, 20 assertions, 5 errors")
19
+ end
20
+
21
+ it "message with all types" do
22
+ stats.options = { :count => 6, :failures => 2, :errors => 3, :assertions => 20 }
23
+ expect(stats.message).to eql("6 tests, 20 assertions, 2 failed, 3 errors")
24
+ end
25
+ end
@@ -0,0 +1,54 @@
1
+ require "spec_helper"
2
+
3
+ describe TestNotifier do
4
+ before { unsupport_all_notifiers }
5
+
6
+ it "uses default notifier" do
7
+ Notifier::Growl.stub :supported? => true
8
+ Notifier::Snarl.stub :supported? => true
9
+ TestNotifier.default_notifier = :snarl
10
+
11
+ expect(TestNotifier.notifier).to eql(Notifier::Snarl)
12
+ end
13
+
14
+ it "outputs error message to $stderr when there's no supported notifier" do
15
+ STDERR
16
+ .should_receive(:<<)
17
+ .with(TestNotifier::NO_NOTIFIERS_MESSAGE)
18
+
19
+ Notifier::Placebo.should_receive(:notify)
20
+
21
+ TestNotifier.notify :status => :fail, :message => "You have failed!"
22
+ end
23
+
24
+ it "outputs error message won't display when silence_no_notifier_warning is true" do
25
+ TestNotifier.silence_no_notifier_warning = true
26
+
27
+ STDERR.should_not_receive(:<<)
28
+ Notifier::Placebo.should_receive(:notify)
29
+
30
+ TestNotifier.notify :status => :fail, :message => "You have failed!"
31
+ end
32
+
33
+ it "outputs error message won't display when silence_no_notifier_warning is true" do
34
+ TestNotifier.silence_no_notifier_warning = true
35
+
36
+ STDERR.should_not_receive(:<<)
37
+ Notifier::Placebo.should_receive(:notify)
38
+
39
+ TestNotifier.notify :status => :fail, :message => "You have failed!"
40
+ end
41
+
42
+ it "sends notification to supported notifier" do
43
+ Notifier::Snarl.stub :supported? => true
44
+ Notifier::Snarl.should_receive(:notify).with({
45
+ :status => :fail,
46
+ :message => "You have failed!",
47
+ :title => TestNotifier::TITLES[:fail],
48
+ :image => TestNotifier::IMAGES[:fail],
49
+ :color => TestNotifier::COLORS[:fail]
50
+ })
51
+
52
+ TestNotifier.notify :status => :fail, :message => "You have failed!"
53
+ end
54
+ end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.description = <<-DESC
14
14
  Display system notifications (dbus, growl and snarl) after
15
15
  running tests. It works on Mac OS X, Linux and Windows. Powerful when used
16
- with Autotest ZenTest gem for Rails apps.
16
+ with Autotest ZenTest gem and alike for Rails apps.
17
17
  DESC
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
@@ -22,7 +22,6 @@ DESC
22
22
  s.require_paths = ["lib"]
23
23
 
24
24
  s.add_dependency "notifier"
25
- s.add_development_dependency "test-unit"
26
- s.add_development_dependency "mocha"
25
+ s.add_development_dependency "rspec"
27
26
  s.add_development_dependency "rake"
28
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-14 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifier
16
- requirement: &70363782479620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70363782479620
25
- - !ruby/object:Gem::Dependency
26
- name: test-unit
27
- requirement: &70363782478180 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
28
25
  none: false
29
26
  requirements:
30
27
  - - ! '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70363782478180
36
30
  - !ruby/object:Gem::Dependency
37
- name: mocha
38
- requirement: &70363782476880 !ruby/object:Gem::Requirement
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
34
  requirements:
41
35
  - - ! '>='
@@ -43,10 +37,15 @@ dependencies:
43
37
  version: '0'
44
38
  type: :development
45
39
  prerelease: false
46
- version_requirements: *70363782476880
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
47
46
  - !ruby/object:Gem::Dependency
48
47
  name: rake
49
- requirement: &70363782475800 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
50
49
  none: false
51
50
  requirements:
52
51
  - - ! '>='
@@ -54,12 +53,17 @@ dependencies:
54
53
  version: '0'
55
54
  type: :development
56
55
  prerelease: false
57
- version_requirements: *70363782475800
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
58
62
  description: ! 'Display system notifications (dbus, growl and snarl) after
59
63
 
60
64
  running tests. It works on Mac OS X, Linux and Windows. Powerful when used
61
65
 
62
- with Autotest ZenTest gem for Rails apps.
66
+ with Autotest ZenTest gem and alike for Rails apps.
63
67
 
64
68
  '
65
69
  email:
@@ -69,6 +73,7 @@ extensions: []
69
73
  extra_rdoc_files: []
70
74
  files:
71
75
  - .gitignore
76
+ - .rspec
72
77
  - Gemfile
73
78
  - Gemfile.lock
74
79
  - README.rdoc
@@ -86,9 +91,12 @@ files:
86
91
  - resources/fail.png
87
92
  - resources/register-growl.scpt
88
93
  - resources/success.png
89
- - test/stats_test.rb
90
- - test/test_helper.rb
91
- - test/test_notifier_test.rb
94
+ - spec/spec_helper.rb
95
+ - spec/stats/minitest_spec.rb
96
+ - spec/stats/rspec1_spec.rb
97
+ - spec/stats/rspec_spec.rb
98
+ - spec/stats/test_unit_spec.rb
99
+ - spec/test_notifier_spec.rb
92
100
  - test_notifier.gemspec
93
101
  homepage: http://rubygems.org/gems/test_notifier
94
102
  licenses: []
@@ -102,25 +110,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
110
  - - ! '>='
103
111
  - !ruby/object:Gem::Version
104
112
  version: '0'
105
- segments:
106
- - 0
107
- hash: 3482717960648985937
108
113
  required_rubygems_version: !ruby/object:Gem::Requirement
109
114
  none: false
110
115
  requirements:
111
116
  - - ! '>='
112
117
  - !ruby/object:Gem::Version
113
118
  version: '0'
114
- segments:
115
- - 0
116
- hash: 3482717960648985937
117
119
  requirements: []
118
120
  rubyforge_project:
119
- rubygems_version: 1.8.10
121
+ rubygems_version: 1.8.23
120
122
  signing_key:
121
123
  specification_version: 3
122
124
  summary: Display system notifications (dbus, growl and snarl) after running tests.
123
- test_files:
124
- - test/stats_test.rb
125
- - test/test_helper.rb
126
- - test/test_notifier_test.rb
125
+ test_files: []
data/test/stats_test.rb DELETED
@@ -1,110 +0,0 @@
1
- require "test_helper"
2
-
3
- class TestNotifier::Stats::RSpecTest < Test::Unit::TestCase
4
- def setup
5
- @stats = TestNotifier::Stats.new(:rspec)
6
- end
7
-
8
- test "success message" do
9
- @stats.options = { :count => 10 }
10
- assert_equal "10 examples", @stats.message
11
- end
12
-
13
- test "message with failing examples" do
14
- @stats.options = { :count => 10, :failures => 5 }
15
- assert_equal "10 examples, 5 failed", @stats.message
16
- end
17
-
18
- test "message with pending examples" do
19
- @stats.options = { :count => 10, :pending => 5 }
20
- assert_equal "10 examples, 5 pending", @stats.message
21
- end
22
-
23
- test "message with error examples" do
24
- @stats.options = { :count => 10, :failures => 5, :errors => 5 }
25
- assert_equal "10 examples, 5 failed, 5 errors", @stats.message
26
- end
27
-
28
- test "message with all types" do
29
- @stats.options = { :count => 6, :failures => 3, :errors => 2, :pending => 3 }
30
- assert_equal "6 examples, 3 failed, 3 pending, 2 errors", @stats.message
31
- end
32
- end
33
-
34
- class TestNotifier::Stats::SpecTest < Test::Unit::TestCase
35
- def setup
36
- @stats = TestNotifier::Stats.new(:spec)
37
- end
38
-
39
- test "success message" do
40
- @stats.options = { :count => 10 }
41
- assert_equal "10 examples", @stats.message
42
- end
43
-
44
- test "message with failing examples" do
45
- @stats.options = { :count => 10, :failures => 5 }
46
- assert_equal "10 examples, 5 failed", @stats.message
47
- end
48
-
49
- test "message with pending examples" do
50
- @stats.options = { :count => 10, :pending => 5 }
51
- assert_equal "10 examples, 5 pending", @stats.message
52
- end
53
-
54
- test "message with all types" do
55
- @stats.options = { :count => 6, :failures => 2, :pending => 3 }
56
- assert_equal "6 examples, 2 failed, 3 pending", @stats.message
57
- end
58
- end
59
-
60
- class TestNotifier::Stats::TestUnitTest < Test::Unit::TestCase
61
- def setup
62
- @stats = TestNotifier::Stats.new(:test_unit)
63
- end
64
-
65
- test "success message" do
66
- @stats.options = { :count => 10, :assertions => 20 }
67
- assert_equal "10 tests, 20 assertions", @stats.message
68
- end
69
-
70
- test "message with failing examples" do
71
- @stats.options = { :count => 10, :assertions => 20, :failures => 5 }
72
- assert_equal "10 tests, 20 assertions, 5 failed", @stats.message
73
- end
74
-
75
- test "message with error examples" do
76
- @stats.options = { :count => 10, :assertions => 20, :errors => 5 }
77
- assert_equal "10 tests, 20 assertions, 5 errors", @stats.message
78
- end
79
-
80
- test "message with all types" do
81
- @stats.options = { :count => 6, :failures => 2, :errors => 3, :assertions => 20 }
82
- assert_equal "6 tests, 20 assertions, 2 failed, 3 errors", @stats.message
83
- end
84
- end
85
-
86
- class TestNotifier::Stats::MiniTestTest < Test::Unit::TestCase
87
- def setup
88
- @stats = TestNotifier::Stats.new(:minitest)
89
- end
90
-
91
- test "success message" do
92
- @stats.options = { :count => 10, :assertions => 20 }
93
- assert_equal "10 tests, 20 assertions", @stats.message
94
- end
95
-
96
- test "message with failing examples" do
97
- @stats.options = { :count => 10, :assertions => 20, :failures => 5 }
98
- assert_equal "10 tests, 20 assertions, 5 failed", @stats.message
99
- end
100
-
101
- test "message with error examples" do
102
- @stats.options = { :count => 10, :assertions => 20, :errors => 5 }
103
- assert_equal "10 tests, 20 assertions, 5 errors", @stats.message
104
- end
105
-
106
- test "message with all types" do
107
- @stats.options = { :count => 6, :failures => 2, :errors => 3, :assertions => 20 }
108
- assert_equal "6 tests, 20 assertions, 2 failed, 3 errors", @stats.message
109
- end
110
- end
data/test/test_helper.rb DELETED
@@ -1,14 +0,0 @@
1
- gem "test-unit"
2
- require "test/unit"
3
- require "mocha"
4
-
5
- require "test_notifier"
6
-
7
- class Test::Unit::TestCase
8
- private
9
- def unsupport_all_notifiers
10
- Notifier.notifiers.each do |notifier|
11
- notifier.stubs(:supported?).returns(false) unless notifier == Notifier::Placebo
12
- end
13
- end
14
- end
@@ -1,43 +0,0 @@
1
- require "test_helper"
2
-
3
- class TestNotifierTest < Test::Unit::TestCase
4
- def setup
5
- unsupport_all_notifiers
6
- end
7
-
8
- test "use default notifier" do
9
- Notifier::Growl.stubs(:supported?).returns(true)
10
- Notifier::Snarl.stubs(:supported?).returns(true)
11
- TestNotifier.default_notifier = :snarl
12
-
13
- assert_equal Notifier::Snarl, TestNotifier.notifier
14
- end
15
-
16
- test "output error message to $stderr when there's no supported notifier" do
17
- STDERR.expects(:<<).with(TestNotifier::NO_NOTIFIERS_MESSAGE).once
18
- Notifier::Placebo.expects(:supported?).returns(true)
19
- Notifier::Placebo.expects(:notify).once
20
- TestNotifier.notify :status => :fail, :message => "You have failed!"
21
- end
22
-
23
- test "output error message won't display when silence_no_notifier_warning is true" do
24
- TestNotifier.silence_no_notifier_warning = true
25
- STDERR.expects(:<<).with(TestNotifier::NO_NOTIFIERS_MESSAGE).never
26
- Notifier::Placebo.expects(:supported?).returns(true)
27
- Notifier::Placebo.expects(:notify).once
28
- TestNotifier.notify :status => :fail, :message => "You have failed!"
29
- end
30
-
31
- test "send notification to supported notifier" do
32
- Notifier::Snarl.expects(:supported?).returns(true)
33
- Notifier::Snarl.expects(:notify).with({
34
- :status => :fail,
35
- :message => "You have failed!",
36
- :title => TestNotifier::TITLES[:fail],
37
- :image => TestNotifier::IMAGES[:fail],
38
- :color => TestNotifier::COLORS[:fail]
39
- })
40
-
41
- TestNotifier.notify :status => :fail, :message => "You have failed!"
42
- end
43
- end