konacha 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # 2.5.0
4
+
5
+ * Made port of the runner configurable
6
+
3
7
  # 2.4.0
4
8
 
5
9
  * Support requesting files with periods in the name
@@ -17,7 +17,7 @@ the asset pipeline and engines.}
17
17
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  gem.name = "konacha"
19
19
  gem.require_paths = ["lib"]
20
- gem.version = "2.4.0"
20
+ gem.version = "2.5.0"
21
21
  gem.license = "MIT"
22
22
 
23
23
  gem.add_dependency "railties", ">= 3.1", "< 5"
@@ -29,7 +29,7 @@ module Konacha
29
29
  yield config
30
30
  end
31
31
 
32
- delegate :port, :spec_dir, :spec_matcher, :application, :driver, :to => :config
32
+ delegate :port, :spec_dir, :spec_matcher, :application, :driver, :runner_port, :to => :config
33
33
 
34
34
  def spec_root
35
35
  File.join(Rails.root, config.spec_dir)
@@ -34,6 +34,7 @@ module Konacha
34
34
  options.driver ||= :selenium
35
35
  options.stylesheets ||= %w(application)
36
36
  options.verbose ||= false
37
+ options.runner_port ||= nil
37
38
 
38
39
  app.config.assets.paths << app.root.join(options.spec_dir).to_s
39
40
  end
@@ -16,11 +16,10 @@ module Konacha
16
16
  'suite end' => :example_group_finished,
17
17
  }
18
18
 
19
- attr_reader :start_time, :duration, :example_count, :failure_count, :pending_count
19
+ attr_reader :start_time, :duration, :examples
20
20
 
21
21
  def initialize(*formatters)
22
22
  @formatters = formatters
23
- @example_count = @failure_count = @pending_count = 0
24
23
  @duration = @start_time = nil
25
24
  @examples, @groups = {}, {}
26
25
  end
@@ -36,7 +35,7 @@ module Konacha
36
35
  process_event :start_dump
37
36
  process_event :dump_pending
38
37
  process_event :dump_failures
39
- process_event :dump_summary, @duration, @example_count, @failure_count, @pending_count
38
+ process_event :dump_summary, duration, example_count, failure_count, pending_count
40
39
  process_event :seed, seed if seed
41
40
  ensure
42
41
  process_event :close
@@ -49,7 +48,7 @@ module Konacha
49
48
  end
50
49
 
51
50
  def passed?
52
- @examples.values.all? { |example| example.passed? || example.pending? }
51
+ failure_count == 0
53
52
  end
54
53
 
55
54
  def process_mocha_event(event)
@@ -63,23 +62,26 @@ module Konacha
63
62
  end
64
63
  end
65
64
 
66
- def process_event(method, *args, &block)
67
- case method
68
- when :example_started
69
- @example_count += 1
70
- when :example_failed
71
- @failure_count += 1
72
- when :example_pending
73
- @pending_count += 1
74
- end
65
+ def example_count
66
+ examples.count
67
+ end
68
+
69
+ def failure_count
70
+ examples.values.count { |example| example.failed? }
71
+ end
72
+
73
+ def pending_count
74
+ examples.values.count { |example| example.pending? }
75
+ end
75
76
 
77
+ def process_event(method, *args, &block)
76
78
  @formatters.each do |formatter|
77
79
  formatter.send method, *args, &block
78
80
  end
79
81
  end
80
82
 
81
83
  def update_or_create_object(data, type)
82
- collection = type == 'test' ? @examples : @groups
84
+ collection = type == 'test' ? examples : @groups
83
85
  object = collection[data['fullTitle']]
84
86
  if object
85
87
  object.update_metadata(data)
@@ -3,6 +3,7 @@ require "capybara"
3
3
  module Konacha
4
4
  class Runner
5
5
  def self.start
6
+ Capybara.server_port = Konacha.runner_port
6
7
  new.run
7
8
  end
8
9
 
@@ -15,6 +15,12 @@ describe Konacha do
15
15
  subject.spec_matcher.should == /_spec\.|_test\./
16
16
  end
17
17
  end
18
+
19
+ describe ".runner_port" do
20
+ it "defaults to nil" do
21
+ subject.runner_port.should == nil
22
+ end
23
+ end
18
24
  end
19
25
 
20
26
  describe ".spec_paths" do
@@ -73,23 +73,6 @@ describe Konacha::Reporter do
73
73
  end
74
74
 
75
75
  describe "#process_event" do
76
- describe "increments counts" do
77
- it "increments example count" do
78
- subject.process_event(:example_started)
79
- subject.example_count.should == 1
80
- end
81
-
82
- it "increments pending count" do
83
- subject.process_event(:example_pending)
84
- subject.pending_count.should == 1
85
- end
86
-
87
- it "increments failed count" do
88
- subject.process_event(:example_failed)
89
- subject.failure_count.should == 1
90
- end
91
- end
92
-
93
76
  it "forwards the call on to the formatters" do
94
77
  formatter.should_receive(:example_started).with('arg!')
95
78
  subject.process_event(:example_started, 'arg!')
@@ -120,4 +103,42 @@ describe Konacha::Reporter do
120
103
  object.parent.should == suite
121
104
  end
122
105
  end
106
+
107
+ describe "#passed?" do
108
+ it 'passes if failure count is zero' do
109
+ subject.should be_passed
110
+ end
111
+
112
+ it 'does not pass if failure count is not zero' do
113
+ subject.stub(:failure_count => 1)
114
+ subject.should_not be_passed
115
+ end
116
+ end
117
+
118
+ context "counters" do
119
+ describe "#example_count" do
120
+ it "is 0 by default" do
121
+ subject.example_count.should be_zero
122
+ end
123
+
124
+ it "returns examples count" do
125
+ subject.stub(:examples => {:omg => :two, :examples => :wow})
126
+ subject.example_count.should == 2
127
+ end
128
+ end
129
+
130
+ describe "#pending_count" do
131
+ it "returns pending examples count" do
132
+ subject.stub(:examples => {:first => double(:pending? => true), :second => double(:pending? => false)})
133
+ subject.pending_count.should == 1
134
+ end
135
+ end
136
+
137
+ describe "#failure_count" do
138
+ it "returns failed examples count" do
139
+ subject.stub(:examples => {:first => double(:failed? => true), :second => double(:failed? => false)})
140
+ subject.failure_count.should == 1
141
+ end
142
+ end
143
+ end
123
144
  end
@@ -31,6 +31,14 @@ describe Konacha::Runner do
31
31
  end
32
32
  end
33
33
 
34
+ describe ".start" do
35
+ it 'sets the Capybara.server_port' do
36
+ Capybara.should_receive(:server_port=).with(Konacha.runner_port)
37
+ Konacha::Runner.any_instance.stub(:run)
38
+ Konacha::Runner.start
39
+ end
40
+ end
41
+
34
42
  shared_examples_for "Konacha::Runner" do |driver|
35
43
  before do
36
44
  Konacha.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konacha
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.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-01-27 00:00:00.000000000 Z
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -328,7 +328,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
328
328
  version: '0'
329
329
  segments:
330
330
  - 0
331
- hash: -2894895241222942879
331
+ hash: 2309042468152930805
332
332
  required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  none: false
334
334
  requirements:
@@ -337,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
337
  version: '0'
338
338
  segments:
339
339
  - 0
340
- hash: -2894895241222942879
340
+ hash: 2309042468152930805
341
341
  requirements: []
342
342
  rubyforge_project:
343
343
  rubygems_version: 1.8.24