guard-ocunit 0.1.1 → 0.1.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: bb27a20f78e03695a7558322e272770c678afcf0
4
- data.tar.gz: c214709b2ec4a90a684bbf5262c501194a4212f4
3
+ metadata.gz: b9e3e4a66b277e0f15f809a0b545d34fdda13f57
4
+ data.tar.gz: 787243eec56230d7b9375f828bfe29583dacb774
5
5
  SHA512:
6
- metadata.gz: ae983796219f21c93ab91528f9aba439f5fcf7afdf2a0f2224a1292124511338b01fbf4bdae0935e382fa7367e3d89ffba0f578b18f5b260db9f04723beb4874
7
- data.tar.gz: bc01562eba557ff9f443e5a69b0aa408ed12ea069377e862bb94e2cfec5bfc9984f578d97fd00ec7b1d3252ea21ad9a19b100114e3df517f565ca6b956cc37ee
6
+ metadata.gz: 28d7add451ce1979eb0473c9d1c4ae90da4cffce046c987747f5f202b26af89930477a50d2072e6c7eea2cfb9d3e0b4f706feb66462692bc56e5dd8939fcf5c3
7
+ data.tar.gz: 45e13926518e42ece3652047ec416ec7fd8025e69d1ebfc722e2ecbf07ad13907574eef8cc8324e83b093dd17c2eab5e57c034218b9cb16971d8015b9db89dff
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Guard::OCUnit [![Build Status](https://secure.travis-ci.org/ap4y/guard-ocunit.png?branch=master)](http://travis-ci.org/ap4y/guard-ocunit)
2
2
 
3
- OCUnit guard allows to automatically launch `OCUnit` tests when files source files are modified.
3
+ OCUnit guard allows to automatically launch tests when files are modified.
4
4
 
5
5
  * Compatible with XCode 4.x
6
6
  * Tested with XCode 4.5.
@@ -9,32 +9,18 @@ OCUnit guard allows to automatically launch `OCUnit` tests when files source fil
9
9
 
10
10
  Please be sure to have [Guard](https://github.com/guard/guard) and [ios-sim](https://github.com/phonegap/ios-sim) installed before continue. `guard-ocunit` uses `ios-sim` for running `application` tests from command line, for more info refer to the [SO](http://stackoverflow.com/questions/12557935/xcode-4-5-command-line-unit-testing) question.
11
11
 
12
- * Install the gem:
12
+ Install the gem:
13
13
 
14
14
  ```
15
15
  $ gem install guard-ocunit
16
16
  ```
17
17
 
18
- * Add guard definition to your Guardfile by running this command:
18
+ Add guard definition to your Guardfile by running this command:
19
19
 
20
20
  ```
21
21
  $ guard init ocunit
22
22
  ```
23
23
 
24
- * Change `Run Script` phase for test target to:
25
-
26
- ```bash
27
- if [ "$RUN_UNIT_TEST_WITH_IOS_SIM" = "YES" ]; then
28
- test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
29
- ios-sim launch "$(dirname "$TEST_HOST")" --setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle="$test_bundle_path" --setenv XCInjectBundleInto="$TEST_HOST" --args -SenTest All "$test_bundle_path"
30
- echo "Finished running tests with ios-sim"
31
- else
32
- "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
33
- fi
34
- ```
35
-
36
- * Enable `Run` in the `Build` section of your test bundle’s scheme. (See http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html).
37
-
38
24
  ## Usage
39
25
 
40
26
  Please read [Guard usage doc](https://github.com/guard/guard#readme)
@@ -2,12 +2,14 @@ require 'guard/ocunit'
2
2
  require 'colored'
3
3
 
4
4
  class Guard::OCUnit::Formatter < Array
5
- attr_reader :passed, :failed, :start_time
5
+ attr_reader :passed, :failed, :start_time, :error_messages
6
6
 
7
7
  def initialize(io, verbose)
8
8
  @io, @verbose = io, verbose
9
9
  @failed, @passed = 0, 0
10
10
  @start_time = Time.now
11
+ @error_messages = []
12
+ @current_failure = ''
11
13
  end
12
14
 
13
15
  def <<(line)
@@ -15,19 +17,28 @@ class Guard::OCUnit::Formatter < Array
15
17
  @io << case line
16
18
  when /passed/
17
19
  @passed += 1
18
- @verbose ? line.green : ''
20
+ (@verbose ? line : '.' ).green
19
21
  when /failed/
22
+ format_current_messages
20
23
  @failed += 1
21
- line.red
24
+ (@verbose ? line : 'F' ).red
22
25
  when /(error|otest)/
23
- line.split(':')[3..-1].join(' ').yellow
26
+ @current_failure << line
27
+ @verbose ? line.yellow : ''
28
+ when /(started|Executed|finished)/
29
+ @verbose ? line : ''
30
+ when /^#{Date.today}/
31
+ @verbose ? line.yellow : ''
24
32
  else
33
+ @current_failure << line unless line.strip.empty?
25
34
  @verbose ? line : ''
26
35
  end
27
36
  self
28
37
  end
29
38
 
30
39
  def dump_summary(with_notification=true)
40
+ dump_error_messages
41
+
31
42
  end_time = Time.now
32
43
  duration = end_time - @start_time
33
44
  message = guard_message(@passed + @failed, @failed, 0, duration)
@@ -36,6 +47,13 @@ class Guard::OCUnit::Formatter < Array
36
47
  notify(message, image) if with_notification
37
48
  end
38
49
 
50
+ def dump_error_messages
51
+ return if @error_messages.empty?
52
+
53
+ puts "\n\nFailures:\n"
54
+ puts @error_messages.join + "\n"
55
+ end
56
+
39
57
  def guard_message(example_count, failure_count, pending_count, duration)
40
58
  message = "#{example_count} examples, #{failure_count} failures"
41
59
  if pending_count > 0
@@ -67,4 +85,50 @@ class Guard::OCUnit::Formatter < Array
67
85
  Guard::Notifier.notify(message, :title => "OCUnit results", :image => image,
68
86
  :priority => priority(image))
69
87
  end
88
+
89
+ private
90
+
91
+ def format_current_messages
92
+ format_failure(@current_failure) unless @current_failure.empty?
93
+ @current_failure = ''
94
+ end
95
+
96
+ def format_failure(messages)
97
+ location = 0
98
+ header_added = false
99
+ formatted_message = ''
100
+
101
+ while ( match = messages.match(/\n#{Dir.pwd}/, location) )
102
+ match_location = match.begin(0)
103
+
104
+ message = messages.slice(location, match_location - location)
105
+ unless header_added
106
+ formatted_message << failure_case(message)
107
+ header_added = true
108
+ end
109
+ formatted_message << failure_reason(message)
110
+
111
+ location = match_location + 1
112
+ end
113
+ message = messages.slice(location, messages.length - location)
114
+ formatted_message << failure_case(message) unless header_added
115
+ formatted_message << failure_reason(message)
116
+
117
+ @error_messages << formatted_message
118
+ end
119
+
120
+ def failure_case(failure)
121
+ components = failure.split(':')
122
+ case_name = "\n#{@error_messages.size + 1}."
123
+ case_name << components[3]
124
+ end
125
+
126
+ def failure_reason(failure)
127
+ components = failure.split(':')
128
+ failure_reason = "\n "
129
+ failure_reason << components[4..-1].join.rstrip.red
130
+ failure_reason << "\n "
131
+ failure_reason << "#{components[0].gsub(Dir.pwd, '.')}:#{components[1]}".green
132
+ failure_reason << "\n"
133
+ end
70
134
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module OCUnitVersion
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-ocunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Evstifeev