cukeforker 0.1.9 → 0.2.0

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: 6d03e238b71431b30c8f05c48e123ea3e85c5a63
4
- data.tar.gz: 04eae12de5cb6df297f997bcd51b3ccd574cce6f
3
+ metadata.gz: f0a71153dc8250ce79cb7ed2b93ed9bc153f1adb
4
+ data.tar.gz: a509ebde9c5946ddd5bc51e0175a9afedbadf632
5
5
  SHA512:
6
- metadata.gz: f580a26bd8a34850e9b81ba28cc3b20efbe3d37e3108f35784187ea77698418d8550ffefdf55bba0cae80bf999b862bc1e733718db9572d803eaa4768ee46233
7
- data.tar.gz: d18e7ae8b58348e2edb0447567ca99712014daa536973a3234054765b202af3e6d481b10c6117d9b44902f8c1142f41a1051f1d8ff5e558f79ccbae2a94070f4
6
+ metadata.gz: da6c6dca2c50581ba380f3be11031561e72c8c7eaf424e6ad15c2c91b2a80cf4c6ae2abdc93ae5a2432afc4dd24ccb316b2a9adc136f228c3c3a0cb4541d75c6
7
+ data.tar.gz: 3f0381d1203723e7962a0c9aa4f5e7895a8978acc3be1ed5cac55f0d0f0f97989fb7c6bf7fd296d033c58611b619d044845db08f066841ce3c57e0df6d4770c0
@@ -6,7 +6,7 @@ module CukeForker
6
6
  # where 'features' is an Array of file:line
7
7
  # and 'opts' is a Hash of options:
8
8
  #
9
- # :max => Fixnum number of workers (default: 2)
9
+ # :max => Fixnum number of workers (default: 2, pass 0 for unlimited)
10
10
  # :vnc => true/false,Class children are launched with DISPLAY set from a VNC server pool,
11
11
  # where the size of the pool is equal to :max. If passed a Class instance,
12
12
  # this will be passed as the second argument to VncTools::ServerPool.
@@ -1,3 +1,3 @@
1
1
  module CukeForker
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,6 +5,10 @@ module CukeForker
5
5
  def initialize(max)
6
6
  @max = max
7
7
 
8
+ if @max < 0
9
+ raise ArgumentError, "max workers cannot be negative, got #{@max.inspect}"
10
+ end
11
+
8
12
  @pending = []
9
13
  @running = []
10
14
  @finished = []
@@ -59,7 +63,7 @@ module CukeForker
59
63
  end
60
64
 
61
65
  def full?
62
- size == @max
66
+ @max != 0 && size == @max
63
67
  end
64
68
 
65
69
  def empty?
@@ -6,8 +6,8 @@ module CukeForker::Formatters
6
6
  it "returns scenario names and line numbers for a scenario" do
7
7
  logger = ScenarioLineLogger.new
8
8
 
9
- feature = mock("Cucumber::Ast::Feature")
10
- feature_element = mock("Cucumber::Ast::Scenario")
9
+ feature = double("Cucumber::Ast::Feature")
10
+ feature_element = double("Cucumber::Ast::Scenario")
11
11
 
12
12
  feature.should_receive(:file).twice.and_return('features/test1.feature')
13
13
  feature_element.should_receive(:source_tags).twice.and_return('')
@@ -26,9 +26,9 @@ module CukeForker::Formatters
26
26
  it "returns scenario names and line numbers for a scenario outline" do
27
27
  logger = ScenarioLineLogger.new
28
28
 
29
- feature = mock("Cucumber::Ast::Feature")
30
- location = mock("Cucumber::Ast::Location", :line => 4)
31
- feature_element = Cucumber::Ast::ScenarioOutline.new(*Array.new(11) {|a| stub(a, :each => true) })
29
+ feature = double("Cucumber::Ast::Feature")
30
+ location = double("Cucumber::Ast::Location", :line => 4)
31
+ feature_element = Cucumber::Ast::ScenarioOutline.new(*Array.new(11) {|a| double(a, :each => true) })
32
32
  feature_element.stub(:location => location)
33
33
 
34
34
  feature.should_receive(:file).and_return('features/test1.feature')
@@ -8,10 +8,10 @@ module CukeForker
8
8
  it "logs all events" do
9
9
  Time.stub(:now => Time.now)
10
10
 
11
- mock_worker = mock(Worker, :id => "1", :feature => "foo/bar", :failed? => false)
12
- mock_worker2 = mock(Worker, :id => "15", :feature => "foo/baz", :failed? => true)
11
+ mock_worker = double(Worker, :id => "1", :feature => "foo/bar", :failed? => false)
12
+ mock_worker2 = double(Worker, :id => "15", :feature => "foo/baz", :failed? => true)
13
13
 
14
- mock_display = mock(VncTools::Server)
14
+ mock_display = double(VncTools::Server)
15
15
  mock_display.stub(:display).and_return(nil, ":5", ":15")
16
16
 
17
17
  listener.on_run_starting
@@ -2,10 +2,10 @@ require File.expand_path("../../spec_helper", __FILE__)
2
2
 
3
3
  module CukeForker
4
4
  describe RecordingVncListener do
5
- let(:server) { mock(VncTools::Server, :display => ":2")}
6
- let(:vnc_listener) { mock(VncListener).as_null_object }
7
- let(:worker) { mock(Worker, :data => OpenStruct.new(:vnc => server), :out => ".", :basename => "foo", :failed? => true) }
8
- let(:recorder) { mock(VncTools::Recorder, :start => nil, :stop => nil, :output => "foo.mp4") }
5
+ let(:server) { double(VncTools::Server, :display => ":2")}
6
+ let(:vnc_listener) { double(VncListener).as_null_object }
7
+ let(:worker) { double(Worker, :data => OpenStruct.new(:vnc => server), :out => ".", :basename => "foo", :failed? => true) }
8
+ let(:recorder) { double(VncTools::Recorder, :start => nil, :stop => nil, :output => "foo.mp4") }
9
9
  let(:listener) { RecordingVncListener.new vnc_listener }
10
10
 
11
11
  it "forwards messages to the wrapped listener do" do
@@ -10,12 +10,12 @@ module CukeForker
10
10
  max = 4
11
11
  format = :json
12
12
  out = "/tmp"
13
- listeners = [mock(AbstractListener, :update => nil)]
13
+ listeners = [double(AbstractListener, :update => nil)]
14
14
  log = false
15
15
  features = %w[a b]
16
16
 
17
- mock_queue = mock(WorkerQueue)
18
- mock_workers = Array.new(2) { |n| mock("Worker-#{n}") }
17
+ mock_queue = double(WorkerQueue)
18
+ mock_workers = Array.new(2) { |n| double("Worker-#{n}") }
19
19
 
20
20
  Process.stub(:pid => 1234)
21
21
 
@@ -37,9 +37,9 @@ module CukeForker
37
37
  end
38
38
 
39
39
  it "sets up the VNC pool if :vnc => true" do
40
- mock_pool = mock(VncTools::ServerPool, :add_observer => nil)
40
+ mock_pool = double(VncTools::ServerPool, :add_observer => nil)
41
41
  VncTools::ServerPool.should_receive(:new).with(2).and_return mock_pool
42
- VncListener.should_receive(:new).with(mock_pool).and_return mock(:update => nil)
42
+ VncListener.should_receive(:new).with(mock_pool).and_return double(:update => nil)
43
43
 
44
44
  Runner.create([], :max => 2, :vnc => true)
45
45
  end
@@ -47,37 +47,37 @@ module CukeForker
47
47
  it "sets up the VNC pool with a custom server class" do
48
48
  server_class = Class.new
49
49
 
50
- mock_pool = mock(VncTools::ServerPool, :add_observer => nil)
50
+ mock_pool = double(VncTools::ServerPool, :add_observer => nil)
51
51
  VncTools::ServerPool.should_receive(:new).with(2, server_class).and_return mock_pool
52
- VncListener.should_receive(:new).with(mock_pool).and_return mock(:update => nil)
52
+ VncListener.should_receive(:new).with(mock_pool).and_return double(:update => nil)
53
53
 
54
54
  Runner.create([], :max => 2, :vnc => server_class)
55
55
  end
56
56
 
57
57
  it "sets up VNC recording if :record => true" do
58
- mock_pool = mock(VncTools::ServerPool, :add_observer => nil)
58
+ mock_pool = double(VncTools::ServerPool, :add_observer => nil)
59
59
  VncTools::ServerPool.should_receive(:new).with(2).and_return mock_pool
60
60
 
61
- mock_vnc_listener = mock(:update => nil)
61
+ mock_vnc_listener = double(:update => nil)
62
62
  VncListener.should_receive(:new).with(mock_pool).and_return(mock_vnc_listener)
63
- RecordingVncListener.should_receive(:new).with(mock_vnc_listener).and_return(mock(:update => nil))
63
+ RecordingVncListener.should_receive(:new).with(mock_vnc_listener).and_return(double(:update => nil))
64
64
 
65
65
  Runner.create([], :max => 2, :vnc => true, :record => true)
66
66
  end
67
67
 
68
68
  it "sets up VNC recording if :record => Hash" do
69
- mock_pool = mock(VncTools::ServerPool, :add_observer => nil)
69
+ mock_pool = double(VncTools::ServerPool, :add_observer => nil)
70
70
  VncTools::ServerPool.should_receive(:new).with(2).and_return mock_pool
71
71
 
72
- mock_vnc_listener = mock(:update => nil)
72
+ mock_vnc_listener = double(:update => nil)
73
73
  VncListener.should_receive(:new).with(mock_pool).and_return(mock_vnc_listener)
74
- RecordingVncListener.should_receive(:new).with(mock_vnc_listener, :codec => "flv").and_return(mock(:update => nil))
74
+ RecordingVncListener.should_receive(:new).with(mock_vnc_listener, :codec => "flv").and_return(double(:update => nil))
75
75
 
76
76
  Runner.create([], :max => 2, :vnc => true, :record => {:codec => "flv"})
77
77
  end
78
78
 
79
79
  it "creates and runs a new runner" do
80
- r = mock(Runner)
80
+ r = double(Runner)
81
81
  Runner.should_receive(:create).with(%w[a b], {}).and_return(r)
82
82
  r.should_receive(:run)
83
83
 
@@ -86,8 +86,8 @@ module CukeForker
86
86
  end
87
87
 
88
88
  context "running" do
89
- let(:listener) { mock(AbstractListener, :update => nil) }
90
- let(:queue) { mock(Queue, :has_failures? => false) }
89
+ let(:listener) { double(AbstractListener, :update => nil) }
90
+ let(:queue) { double(Queue, :has_failures? => false) }
91
91
  let(:runner) { Runner.new(queue) }
92
92
 
93
93
  it "processes the queue" do
@@ -28,10 +28,10 @@ module CukeForker
28
28
  | 1 |
29
29
  ")
30
30
 
31
- Cucumber::FeatureFile.stub!(:new).with("features/test1.feature").and_return(feature_1)
32
- Cucumber::FeatureFile.stub!(:new).with("features/test2.feature").and_return(feature_2)
31
+ Cucumber::FeatureFile.stub(:new).with("features/test1.feature").and_return(feature_1)
32
+ Cucumber::FeatureFile.stub(:new).with("features/test2.feature").and_return(feature_2)
33
33
 
34
- Scenarios.stub!(:feature_files).and_return(['features/test1.feature', 'features/test2.feature'])
34
+ Scenarios.stub(:feature_files).and_return(['features/test1.feature', 'features/test2.feature'])
35
35
 
36
36
  all_scenarios = Scenarios.all
37
37
 
@@ -54,9 +54,9 @@ module CukeForker
54
54
  Scenario: test scenario 2
55
55
  Given nothing else happens")
56
56
 
57
- Cucumber::FeatureFile.stub!(:new).with("features/test1.feature").and_return(feature_1)
57
+ Cucumber::FeatureFile.stub(:new).with("features/test1.feature").and_return(feature_1)
58
58
 
59
- Scenarios.stub!(:feature_files).and_return(['features/test1.feature'])
59
+ Scenarios.stub(:feature_files).and_return(['features/test1.feature'])
60
60
 
61
61
  all_scenarios = Scenarios.by_args(%W[-t @find_me])
62
62
 
@@ -2,9 +2,9 @@ require File.expand_path("../../spec_helper", __FILE__)
2
2
 
3
3
  module CukeForker
4
4
  describe VncListener do
5
- let(:server) { mock(VncTools::Server, :display => ":15") }
6
- let(:pool) { mock(VncTools::ServerPool) }
7
- let(:worker) { mock(Worker, :data => OpenStruct.new) }
5
+ let(:server) { double(VncTools::Server, :display => ":15") }
6
+ let(:pool) { double(VncTools::ServerPool) }
7
+ let(:worker) { double(Worker, :data => OpenStruct.new) }
8
8
  let(:listener) { VncListener.new pool }
9
9
 
10
10
  it "fetches a display from the pool and assings it to the worker" do
@@ -2,7 +2,7 @@ require File.expand_path("../../spec_helper", __FILE__)
2
2
 
3
3
  module CukeForker
4
4
  describe WorkerQueue do
5
- let(:workers) { Array.new(5) { |n| mock("Worker-#{n}") } }
5
+ let(:workers) { Array.new(5) { |n| double("Worker-#{n}") } }
6
6
  let(:queue) { WorkerQueue.new(3) }
7
7
 
8
8
  it "adds an item to the queue" do
@@ -28,6 +28,20 @@ module CukeForker
28
28
  queue.should be_backed_up
29
29
  end
30
30
 
31
+ it "is unlimited if max workers = 0" do
32
+ unlimited_queue = WorkerQueue.new(0)
33
+
34
+ workers.each { |w| queue.add double.as_null_object }
35
+
36
+ unlimited_queue.fill
37
+ unlimited_queue.should_not be_full
38
+ unlimited_queue.should_not be_backed_up
39
+ end
40
+
41
+ it "raises if max workers is negative" do
42
+ expect { WorkerQueue.new(-1) }.to raise_error(ArgumentError)
43
+ end
44
+
31
45
  it "removes finished workers from the queue" do
32
46
  workers.each do |w|
33
47
  w.should_receive(:start)
@@ -36,9 +50,9 @@ module CukeForker
36
50
 
37
51
  queue.fill
38
52
 
39
- workers[0].stub!(:finished? => true)
40
- workers[1].stub!(:finished? => true)
41
- workers[2].stub!(:finished? => false)
53
+ workers[0].stub(:finished? => true)
54
+ workers[1].stub(:finished? => true)
55
+ workers[2].stub(:finished? => false)
42
56
 
43
57
  queue.poll
44
58
 
@@ -68,7 +68,7 @@ module CukeForker
68
68
  end
69
69
 
70
70
  it "fires an event after forking" do
71
- mock_listener = mock(AbstractListener)
71
+ mock_listener = double(AbstractListener)
72
72
  mock_listener.should_receive(:update).with(:on_worker_forked, worker)
73
73
 
74
74
  worker.add_observer mock_listener
@@ -88,12 +88,12 @@ module CukeForker
88
88
  end
89
89
 
90
90
  it "considers itself failed if the exit code was 1" do
91
- worker.stub :status => mock(:exitstatus => 1)
91
+ worker.stub :status => double(:exitstatus => 1)
92
92
  worker.should be_failed
93
93
  end
94
94
 
95
95
  it "considers itself failed if the exit code was 0" do
96
- worker.stub :status => mock(:exitstatus => 0)
96
+ worker.stub :status => double(:exitstatus => 0)
97
97
  worker.should_not be_failed
98
98
  end
99
99
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukeforker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-07 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber