rspec-nc 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b33c73ab251ad2c19f0e8f3f9f4f5245da3ea966
4
+ data.tar.gz: 13a4ef2b9ebe1f1b19fc8b6ddbad0c55e7370c33
5
+ SHA512:
6
+ metadata.gz: e8ceb0cd9a370e9b7b76c8b36ef54a91ba4e31f28e102d5637eeafebf752ddf18c7a0983d6b6b465eae22cadc5cc713a40533a8c64dd59918f6c7bb3db8ba41c
7
+ data.tar.gz: 00b24a58c23e191a2fc935523c7eb3669b18b13dc46395b7702c01936a4dac0d7d99a2444ab09dd13e7d616c06c62ae6fce18721e5eae7599112712c58db975e
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  Gemfile.lock
2
2
  pkg
3
+ gemfiles/*.lock
@@ -0,0 +1,4 @@
1
+ gemfile:
2
+ - gemfiles/rspec29.gemfile
3
+ - gemfiles/rspec3.gemfile
4
+ script: 'bundle exec rake spec'
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- group :development, :test do
6
- gem 'rake'
7
- gem 'rspec'
8
- end
@@ -6,16 +6,16 @@ RSpec Notification Center
6
6
 
7
7
  rspec-nc is an RSpec formatter for Mountain Lion's Notification Center.
8
8
 
9
- ![Screenshot](http://twe4ked.github.com/rspec-nc/rspec-nc.jpg)
9
+ ![Screenshot](http://twe4ked.github.io/rspec-nc/rspec-nc.jpg)
10
10
 
11
11
  Installation
12
12
  ------------
13
13
 
14
- Installing rspec-nc is easy. Just put it in your Gemfile (`gem 'rspec-nc'`) and
15
- run your specs like this from now on:
14
+ Installing rspec-nc is easy.
15
+ Just put it in your Gemfile (`gem 'rspec-nc'`) and run your specs:
16
16
 
17
17
  ```
18
- $ rspec --format=doc --format=Nc
18
+ rspec --format=doc --format=Nc
19
19
  ```
20
20
 
21
21
  You will want to specify another formatter as rspec-nc does not provide any
@@ -34,3 +34,13 @@ Contributing
34
34
  Found an issue? Have a great idea? Want to help? Great! Create an issue issue
35
35
  for it, or even better; fork the project and fix the problem yourself. Pull
36
36
  requests are always welcome. :)
37
+
38
+ ### Running the specs
39
+
40
+ The default rake task uses [WWTD] to test multiple versions of RSpec.
41
+
42
+ ``` ruby
43
+ rake
44
+ ```
45
+
46
+ [WWTD]: https://github.com/grosser/wwtd
data/Rakefile CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'wwtd/tasks'
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
 
8
- task :default => :spec
9
+ task :default => :wwtd
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'wwtd'
5
+
6
+ gem 'terminal-notifier', '~> 1.4.2'
7
+ gem 'rspec', '~> 2.9'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'wwtd'
5
+
6
+ gem 'terminal-notifier', '~> 1.4.2'
7
+ gem 'rspec', '~> 3.0'
data/lib/nc.rb CHANGED
@@ -2,10 +2,14 @@ require 'rspec/core/formatters/base_text_formatter'
2
2
  require 'terminal-notifier'
3
3
 
4
4
  class Nc < RSpec::Core::Formatters::BaseTextFormatter
5
+ if RSpec::Core::Formatters.respond_to? :register
6
+ RSpec::Core::Formatters.register self.class, :example_failed
7
+ end
8
+
5
9
  def dump_summary(duration, example_count, failure_count, pending_count)
6
10
  body = []
7
- body << "Finished in #{format_duration duration}"
8
- body << summary_line(example_count, failure_count, pending_count)
11
+ body << "Finished in #{_format_duration duration}"
12
+ body << _summary_line(example_count, failure_count, pending_count)
9
13
 
10
14
  name = File.basename(File.expand_path '.')
11
15
 
@@ -27,4 +31,29 @@ class Nc < RSpec::Core::Formatters::BaseTextFormatter
27
31
  def say(title, body)
28
32
  TerminalNotifier.notify body, :title => title
29
33
  end
34
+
35
+ def _format_duration(duration)
36
+ if respond_to? :format_duration
37
+ format_duration duration
38
+ else
39
+ require 'rspec/core/formatters/helpers'
40
+ RSpec::Core::Formatters::Helpers.format_duration duration
41
+ end
42
+ end
43
+
44
+ def _summary_line(example_count, failure_count, pending_count)
45
+ if respond_to? :summary_line
46
+ summary_line(example_count, failure_count, pending_count)
47
+ else
48
+ RSpec::Core::Notifications::SummaryNotification.new(
49
+ nil,
50
+ SizeResponder.new(example_count),
51
+ SizeResponder.new(failure_count),
52
+ SizeResponder.new(pending_count),
53
+ nil
54
+ ).totals_line
55
+ end
56
+ end
57
+
58
+ SizeResponder = Struct.new(:size)
30
59
  end
@@ -2,7 +2,12 @@ require 'nc'
2
2
 
3
3
  class NcFail < Nc
4
4
  def say(title, body)
5
+ @failed_examples ||= []
5
6
  return if @failed_examples.size <= 0
6
7
  super
7
8
  end
9
+
10
+ def example_failed(failure)
11
+ @failed_examples << failure
12
+ end
8
13
  end
@@ -2,11 +2,12 @@ require 'nc'
2
2
 
3
3
  class NcFirstFail < Nc
4
4
  def example_failed(example)
5
+ @failed_examples ||= []
5
6
  if @failed_examples.size == 0
6
7
  name = File.basename(File.expand_path '.')
7
8
  say "\u26D4 #{name}: Failure", "#{example.metadata[:full_description]}\n#{example.exception}"
8
9
  end
9
- super
10
+ @failed_examples << example
10
11
  end
11
12
 
12
13
  def dump_summary(duration, example_count, failure_count, pending_count)
@@ -1,18 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
- gem.name = 'rspec-nc'
4
- gem.version = '0.0.6'
5
- gem.authors = ['Odin Dutton']
6
- gem.email = ['odindutton@gmail.com']
7
- gem.description = 'https://github.com/twe4ked/rspec-nc'
8
- gem.summary = "RSpec formatter for Mountain Lion's Notification Center"
9
- gem.homepage = 'https://github.com/twe4ked/rspec-nc'
3
+ gem.name = 'rspec-nc'
4
+ gem.version = '0.1.0'
5
+ gem.authors = ['Odin Dutton']
6
+ gem.email = ['odindutton@gmail.com']
7
+ gem.description = 'https://github.com/twe4ked/rspec-nc'
8
+ gem.summary = "RSpec formatter for Mountain Lion's Notification Center"
9
+ gem.homepage = 'https://github.com/twe4ked/rspec-nc'
10
+ gem.license = 'MIT'
10
11
 
11
12
  gem.add_dependency 'terminal-notifier', '~> 1.4.2'
12
- gem.add_dependency 'rspec', '~> 2.9'
13
+ gem.add_dependency 'rspec', '>= 2.9'
13
14
 
14
- gem.files = `git ls-files`.split($\)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(spec)/})
15
+ gem.add_development_dependency 'rake'
16
+ gem.add_development_dependency 'wwtd'
17
+
18
+ gem.files = `git ls-files`.split($\)
19
+ gem.test_files = gem.files.grep(%r{^(spec)/})
17
20
  gem.require_paths = ['lib']
18
21
  end
@@ -4,14 +4,14 @@ describe NcFail do
4
4
  let(:formatter) { NcFail.new(StringIO.new) }
5
5
 
6
6
  it 'returns a failing notification' do
7
- TerminalNotifier.should_receive(:notify)
7
+ expect(TerminalNotifier).to receive(:notify)
8
8
 
9
9
  formatter.instance_variable_set('@failed_examples', [1])
10
10
  formatter.say('title', 'body')
11
11
  end
12
12
 
13
13
  it 'does not return a success notification when tests are passing' do
14
- TerminalNotifier.should_not_receive(:notify)
14
+ expect(TerminalNotifier).to_not receive(:notify)
15
15
 
16
16
  formatter.say('title', 'body')
17
17
  end
@@ -10,13 +10,11 @@ describe NcFirstFail do
10
10
  let(:exception) { 'exception' }
11
11
  let(:description) { 'description' }
12
12
 
13
- before do
14
- example.should_receive(:metadata).any_number_of_times.and_return({:full_description => description})
15
- example.should_receive(:exception).any_number_of_times.and_return(exception)
16
- end
17
-
18
13
  it 'notifies the first failure only' do
19
- TerminalNotifier.should_receive(:notify).with("#{description}\n#{exception}",
14
+ allow(example).to receive(:metadata).and_return({:full_description => description})
15
+ allow(example).to receive(:exception).and_return(exception)
16
+
17
+ expect(TerminalNotifier).to receive(:notify).with("#{description}\n#{exception}",
20
18
  :title => "#{failure} #{current_dir}: Failure"
21
19
  )
22
20
 
@@ -25,7 +23,7 @@ describe NcFirstFail do
25
23
  end
26
24
 
27
25
  it "doesn't notify in the end if there has been any failures" do
28
- TerminalNotifier.should_not_receive(:notify)
26
+ expect(TerminalNotifier).to_not receive(:notify)
29
27
 
30
28
  formatter.dump_summary(0.0001, 2, 1, 0)
31
29
  end
@@ -9,7 +9,7 @@ describe Nc do
9
9
  let(:failure) { "\u26D4" }
10
10
 
11
11
  it 'returns the summary' do
12
- TerminalNotifier.should_receive(:notify).with(
12
+ expect(TerminalNotifier).to receive(:notify).with(
13
13
  "Finished in 0.0001 seconds\n3 examples, 1 failure, 1 pending",
14
14
  :title => "#{failure} #{current_dir}: 1 failed example"
15
15
  )
@@ -18,7 +18,7 @@ describe Nc do
18
18
  end
19
19
 
20
20
  it 'returns a failing notification' do
21
- TerminalNotifier.should_receive(:notify).with(
21
+ expect(TerminalNotifier).to receive(:notify).with(
22
22
  "Finished in 0.0001 seconds\n1 example, 1 failure",
23
23
  :title => "#{failure} #{current_dir}: 1 failed example"
24
24
  )
@@ -27,7 +27,7 @@ describe Nc do
27
27
  end
28
28
 
29
29
  it 'returns a success notification' do
30
- TerminalNotifier.should_receive(:notify).with(
30
+ expect(TerminalNotifier).to receive(:notify).with(
31
31
  "Finished in 0.0001 seconds\n1 example, 0 failures",
32
32
  :title => "#{success} #{current_dir}: Success"
33
33
  )
metadata CHANGED
@@ -1,48 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-nc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Odin Dutton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-27 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: terminal-notifier
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.4.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.4.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '2.9'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '2.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: wwtd
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
46
69
  description: https://github.com/twe4ked/rspec-nc
47
70
  email:
48
71
  - odindutton@gmail.com
@@ -50,11 +73,14 @@ executables: []
50
73
  extensions: []
51
74
  extra_rdoc_files: []
52
75
  files:
53
- - .gitignore
76
+ - ".gitignore"
77
+ - ".travis.yml"
54
78
  - Gemfile
55
79
  - LICENSE
56
- - README.md
80
+ - README.markdown
57
81
  - Rakefile
82
+ - gemfiles/rspec29.gemfile
83
+ - gemfiles/rspec3.gemfile
58
84
  - lib/nc.rb
59
85
  - lib/nc_fail.rb
60
86
  - lib/nc_first_fail.rb
@@ -63,34 +89,28 @@ files:
63
89
  - spec/nc_first_fail_spec.rb
64
90
  - spec/nc_spec.rb
65
91
  homepage: https://github.com/twe4ked/rspec-nc
66
- licenses: []
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
67
95
  post_install_message:
68
96
  rdoc_options: []
69
97
  require_paths:
70
98
  - lib
71
99
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
100
  requirements:
74
- - - ! '>='
101
+ - - ">="
75
102
  - !ruby/object:Gem::Version
76
103
  version: '0'
77
- segments:
78
- - 0
79
- hash: -2800251499294320553
80
104
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
105
  requirements:
83
- - - ! '>='
106
+ - - ">="
84
107
  - !ruby/object:Gem::Version
85
108
  version: '0'
86
- segments:
87
- - 0
88
- hash: -2800251499294320553
89
109
  requirements: []
90
110
  rubyforge_project:
91
- rubygems_version: 1.8.23
111
+ rubygems_version: 2.2.2
92
112
  signing_key:
93
- specification_version: 3
113
+ specification_version: 4
94
114
  summary: RSpec formatter for Mountain Lion's Notification Center
95
115
  test_files:
96
116
  - spec/nc_fail_spec.rb