avocado_formatter 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b827b45c9318f51caebbbf9a0ff9e75e554bf21
4
- data.tar.gz: 4e59dadbc716e8552af750b1020d8b558254408e
3
+ metadata.gz: 2117bb86ee2283cbb2fa9866cb295697acfa9191
4
+ data.tar.gz: e8d3daf2085c18f6be20229b289185b8b1037962
5
5
  SHA512:
6
- metadata.gz: 43c39a7b51e1c9e00d96519d9bc7e570567140bb8fb31ce792e3aa9031060ec2e20e0c33c0eb7c9ada181dfbf0fa121b1c532903c047889b19799124ed0d633e
7
- data.tar.gz: fb9d0b8d0439109c05d58339f846ac2f6c707843799aa98d763c29b8560a991ef18a863c0410553feae6ca9d986403b43d2e02e3510d371306c1dbc3887881f7
6
+ metadata.gz: 5d82d2ca0b6c67e9229e341358656459395a7f43e6f4c6cb825fdee5ad558160996f404f45fc5af9c079a44fc8e46e7b6cd127c1dc85fdd7d72c97eefe9473cd
7
+ data.tar.gz: 564b13ea99fcf9981e9a27d098be8422bc2b1930ef35492d2a5b2ed1a65f588d4e283ccc50b8fd0236255a795055c56c1eae5d44ec134c68e79f32c183c7afbd
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.authors = ["George Karagkiaouris"]
3
+ gem.email = [""]
4
+ gem.description = %q{RSpec/Cucumber formatter that connects with Avocado}
5
+ gem.summary = %q{This gem is used to connect the tests with the Avocado application}
6
+ gem.homepage = "https://github.com/karaggerge/avocado-formatter"
7
+
8
+ gem.files = `git ls-files`.split($\)
9
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
10
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
11
+ gem.name = "avocado_formatter"
12
+ gem.require_paths = ["lib"]
13
+ gem.version = '0.0.2'
14
+ gem.license = 'MIT'
15
+ end
@@ -0,0 +1,52 @@
1
+
2
+ module AvocadoFormatter
3
+ autoload :Cucumber, 'avocado_formatter/cucumber'
4
+ autoload :RSpec, 'avocado_formatter/rspec'
5
+ autoload :RSpec3, 'avocado_formatter/rspec3'
6
+ autoload :Spec, 'avocado_formatter/spec'
7
+
8
+ def cucumber2?
9
+ defined?(::Cucumber) && ::Cucumber::VERSION >= '2.0.0'
10
+ end
11
+ module_function :cucumber2?
12
+
13
+ if cucumber2?
14
+ # Cucumber 2 detects the formatter API based on initialize arity
15
+ def initialize(runtime, path_or_io, options)
16
+ end
17
+ end
18
+
19
+ def rspec3?
20
+ defined?(::RSpec::Core) && ::RSpec::Core::Version::STRING >= '3.0.0'
21
+ end
22
+ module_function :rspec3?
23
+
24
+ if rspec3?
25
+ # This needs to be run before `.new` is called, so putting it inside the
26
+ # autoloaded rspec3 file will not work.
27
+ ::RSpec::Core::Formatters.register self,
28
+ :example_passed,
29
+ :example_pending,
30
+ :example_failed,
31
+ :example_group_started,
32
+ :example_group_finished,
33
+ :dump_summary,
34
+ :seed,
35
+ :message
36
+ end
37
+
38
+ def self.new(*args)
39
+ case args.size
40
+ when 1 then
41
+ if rspec3?
42
+ RSpec3
43
+ else
44
+ RSpec
45
+ end
46
+ when 2 then Spec
47
+ when 3 then Cucumber
48
+ else
49
+ raise ArgumentError
50
+ end.new(*args)
51
+ end
52
+ end
File without changes
File without changes
@@ -0,0 +1,78 @@
1
+ require 'socket'
2
+
3
+ module AvocadoFormatter
4
+ class RSpec3
5
+
6
+ # See avocado_formatter.rb for formatter registration.
7
+ attr_reader :output, :failed_notifications
8
+
9
+ def initialize(output)
10
+ @output = output
11
+ @group_level = 0
12
+ @index_offset = 0
13
+ @failed_notifications = []
14
+
15
+ @hostname = 'localhost'
16
+ @port = '1336'
17
+ @socket = TCPSocket.open(@hostname, @port)
18
+ end
19
+
20
+ def color
21
+ unless defined?(::RSpec::Core::Formatters::ConsoleCodes)
22
+ require 'rspec/core/formatters/console_codes'
23
+ end
24
+ ::RSpec::Core::Formatters::ConsoleCodes
25
+ end
26
+
27
+ def example_passed(notification)
28
+ @socket.puts('passed');
29
+ end
30
+
31
+ def example_pending(notification)
32
+ @socket.puts('pending');
33
+ end
34
+
35
+ def example_failed(notification)
36
+ @failed_notifications << notification
37
+ @socket.puts('failed');
38
+ end
39
+
40
+ def example_group_started(event)
41
+ if @group_level.zero?
42
+ @socket.print "#{event.group.description} "
43
+ @start_time = Time.now
44
+ end
45
+
46
+ @group_level += 1
47
+ end
48
+
49
+ def example_group_finished(event)
50
+ @group_level -= 1
51
+
52
+ if @group_level.zero?
53
+ # print_elapsed_time output, @start_time
54
+ # output.puts
55
+
56
+ failed_notifications.each_with_index do |failure, index|
57
+ @socket.puts failure.fully_formatted(@index_offset + index + 1)
58
+ end
59
+
60
+ @index_offset += failed_notifications.size
61
+ failed_notifications.clear
62
+ end
63
+ end
64
+
65
+ def dump_summary(summary)
66
+ output.puts summary.fully_formatted
67
+ end
68
+
69
+ def seed(notification)
70
+ return unless notification.seed_used?
71
+ output.puts notification.fully_formatted
72
+ end
73
+
74
+ def message(notification)
75
+ output.puts notification.message
76
+ end
77
+ end
78
+ end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avocado_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Karagkiaouris
@@ -16,7 +16,13 @@ email:
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
- files: []
19
+ files:
20
+ - avocado_formatter.gemspec
21
+ - lib/avocado_formatter.rb
22
+ - lib/avocado_formatter/cucumber.rb
23
+ - lib/avocado_formatter/rspec.rb
24
+ - lib/avocado_formatter/rspec3.rb
25
+ - lib/avocado_formatter/spec.rb
20
26
  homepage: https://github.com/karaggerge/avocado-formatter
21
27
  licenses:
22
28
  - MIT