cukeforker 0.2.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 78d586215f5f03a4e562c4b6f2242b5c2344472a
4
- data.tar.gz: d069baca9ebfa3407a0c1cae3e228a88187c9f6d
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmRjOTMxNjRlOWViNTk4NWViN2RhZmQwNTljZDI3ZmVjMjg3MzNlYg==
5
+ data.tar.gz: !binary |-
6
+ MTg0NTZlNjM1NGNkMWExNmI3YTI1MjYwMzMxMjBiOWU2ZmVkMTQ5MQ==
5
7
  SHA512:
6
- metadata.gz: f8e4e3e6120d1480015688cde65aaae0f4e25fb737f71cb0a9fab615095d88ef45b33d5dcb450727d60f3b57413755a80a29600fd687986c4a58a489416b3710
7
- data.tar.gz: 0aa754f8b2c5cd510f4e72520df6bd1a6e8d2557887989159aef49becda1f4eb0cc97ff24ef1000f45e639574c150a4a6048109b8cf2fbaabedb3ea59b70c0d6
8
+ metadata.gz: !binary |-
9
+ YTU3YzlkYTZhZjAyZjBjN2EyMzQ0ZTc3NjhlZjJkYmQ4ZDM1NTA2ZjRhZjVk
10
+ OGNmOTMwMTM1YjMwMTZhNGZhNDM0NmY3ZGI4YWVmYjNiOThiMzc0OWQ3NTkw
11
+ NzA4Mjg3NjE3ZjA3NmI2N2MzYjVmZjAzZTE1ODNhN2Y3NDQ4ZjA=
12
+ data.tar.gz: !binary |-
13
+ NDZkYzVmMjIzYWI5N2IzMzkwMDY0YTY0NjVhNzg4Y2U5NzlkNjcxMDgyYjgx
14
+ YzMyYzQxZDg3OTRjNzUwMzg0OGUzMTBlNzQ4ZGM2YzQzNWNlNWE1N2Q2Yjhk
15
+ ODgzN2E4OTk1MGYxNzE0MmE3NzI3ODYzMmFlZjU0Y2IwZDJkNjE=
@@ -2,4 +2,7 @@ rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
4
  - 2.1.0
5
- - 2.2.0
5
+ - 2.2.0
6
+
7
+ before_install:
8
+ - gem update bundler
@@ -14,11 +14,12 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "cukeforker"
16
16
 
17
- s.add_dependency "cucumber", ">= 1.1.5"
17
+ s.add_dependency "cucumber", ">= 2.0.0"
18
18
  s.add_dependency "vnctools", ">= 0.0.5"
19
19
  s.add_development_dependency "rspec", "~> 2.5"
20
20
  s.add_development_dependency "coveralls"
21
21
  s.add_development_dependency "rake", "~> 0.9.2"
22
+ s.add_development_dependency "pry"
22
23
 
23
24
  s.files = `git ls-files`.split("\n")
24
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -21,6 +21,7 @@ require 'cukeforker/worker'
21
21
  require 'cukeforker/worker_queue'
22
22
  require 'cukeforker/runner'
23
23
  require 'cukeforker/scenarios'
24
+ require 'cukeforker/normalised_encoding_file'
25
+ require 'cukeforker/scenario_list'
24
26
 
25
- require 'cukeforker/formatters/scenario_line_logger'
26
27
  require 'cukeforker/formatters/junit_scenario_formatter'
@@ -1,5 +1,5 @@
1
1
  require 'cucumber/formatter/junit'
2
- require 'cucumber/formatter/ordered_xml_markup'
2
+
3
3
  module CukeForker
4
4
  module Formatters
5
5
  class JunitScenarioFormatter < Cucumber::Formatter::Junit
@@ -19,8 +19,8 @@ module CukeForker
19
19
  end
20
20
  end
21
21
 
22
- def after_feature_element(feature_element)
23
- @testsuite = Cucumber::Formatter::OrderedXmlMarkup.new( :indent => 2 )
22
+ def end_feature(feature_element)
23
+ @testsuite = Builder::XmlMarkup.new(:indent => 2)
24
24
  @testsuite.instruct!
25
25
  @testsuite.testsuite(
26
26
  :failures => @failures,
@@ -0,0 +1,38 @@
1
+ module CukeForker
2
+ class NormalisedEncodingFile
3
+ COMMENT_OR_EMPTY_LINE_PATTERN = /^\s*#|^\s*$/ #:nodoc:
4
+ ENCODING_PATTERN = /^\s*#\s*encoding\s*:\s*([^\s]+)/ #:nodoc:
5
+
6
+ def self.read(path)
7
+ new(path).read
8
+ end
9
+
10
+ def initialize(path)
11
+ begin
12
+ @file = File.new(path)
13
+ set_encoding
14
+ rescue Errno::EACCES => e
15
+ raise FileNotFoundException.new(e, File.expand_path(path))
16
+ rescue Errno::ENOENT => e
17
+ raise FeatureFolderNotFoundException.new(e, path)
18
+ end
19
+ end
20
+
21
+ def read
22
+ @file.read.encode("UTF-8")
23
+ end
24
+
25
+ private
26
+
27
+ def set_encoding
28
+ @file.each do |line|
29
+ if ENCODING_PATTERN =~ line
30
+ @file.set_encoding $1
31
+ break
32
+ end
33
+ break unless COMMENT_OR_EMPTY_LINE_PATTERN =~ line
34
+ end
35
+ @file.rewind
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ class ScenarioList
2
+ attr_accessor :scenarios
3
+
4
+ def scenarios
5
+ @scenarios
6
+ end
7
+
8
+ def before_test_step(test_step)
9
+ end
10
+
11
+ def after_test_step(test_step, result)
12
+ end
13
+
14
+ def before_test_case(test_case)
15
+ end
16
+
17
+ def after_test_case(test_case, result)
18
+ @scenarios ||= []
19
+ @scenarios << [test_case.feature.file, test_case.location.line].join(':')
20
+ end
21
+
22
+ def done
23
+ end
24
+ end
@@ -1,19 +1,10 @@
1
- require 'cucumber/runtime/features_loader'
1
+ require 'cucumber/core'
2
+ require 'cucumber/core/filter'
2
3
 
3
4
  module CukeForker
4
-
5
- #
6
- # CukeForker::Scenarios.by_args(args)
7
- #
8
- # where 'args' is a String of cucumber options
9
- #
10
- # For example:
11
- # CukeForker::Scenarios.by_args(%W[-p my_profile -t @edition])
12
- # will return an array of scenarios and their line numbers that match
13
- # the tags specified in the cucumber profile 'my_profile' AND have the '@edition' tag
14
- #
15
-
16
5
  class Scenarios
6
+ include Cucumber::Core
7
+
17
8
  def self.by_args(args)
18
9
  options = Cucumber::Cli::Options.new(STDOUT, STDERR, :default_profile => 'default')
19
10
  tagged(options.parse!(args)[:tag_expressions])
@@ -25,15 +16,13 @@ module CukeForker
25
16
  end
26
17
 
27
18
  def self.tagged(tags)
28
- tag_expression = Gherkin::TagExpression.new(tags)
29
- scenario_line_logger = CukeForker::Formatters::ScenarioLineLogger.new(tag_expression)
30
- loader = Cucumber::Runtime::FeaturesLoader.new(feature_files, [], tag_expression)
31
-
32
- loader.features.each do |feature|
33
- feature.accept(scenario_line_logger)
19
+ scenario_list = ScenarioList.new
20
+ feature_files.each do |feature|
21
+ source = CukeForker::NormalisedEncodingFile.read(feature)
22
+ file = Cucumber::Core::Gherkin::Document.new(feature, source)
23
+ self.new.execute([file], scenario_list, [Cucumber::Core::Test::TagFilter.new(tags)])
34
24
  end
35
-
36
- scenario_line_logger.scenarios
25
+ scenario_list.scenarios
37
26
  end
38
27
 
39
28
  def self.feature_files
@@ -1,3 +1,3 @@
1
1
  module CukeForker
2
- VERSION = "0.2.5"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -48,8 +48,5 @@ I, [#{timestamp}] INFO -- : [ run ] finished, passed
48
48
  I, [#{timestamp}] INFO -- : [ display :15 ] stopping
49
49
  OUTPUT
50
50
  end
51
-
52
-
53
-
54
51
  end # Worker
55
52
  end # CukeForker
@@ -135,7 +135,7 @@ module CukeForker
135
135
  queue.should_receive(:process).with 0.2 # poll interval
136
136
  queue.should_receive(:wait_until_finished)
137
137
 
138
- expect(runner.run).to be_true
138
+ expect(runner.run).to be_truthy
139
139
  end
140
140
 
141
141
  it 'returns false when there are test failures' do
@@ -143,7 +143,7 @@ module CukeForker
143
143
  queue.should_receive(:process).with 0.2 # poll interval
144
144
  queue.should_receive(:wait_until_finished)
145
145
 
146
- expect(runner.run).to be_false
146
+ expect(runner.run).to be_falsey
147
147
  end
148
148
  end
149
149
  end # Runner
@@ -3,65 +3,105 @@ require File.expand_path("../../spec_helper", __FILE__)
3
3
  module CukeForker
4
4
  describe Scenarios do
5
5
  it "returns all scenarios and their line numbers" do
6
- feature_1 = Cucumber::FeatureFile.new("features/test1.feature")
7
- feature_2 = Cucumber::FeatureFile.new("features/test2.feature")
6
+ Scenarios.stub(:feature_files).and_return(['features/test1.feature', 'features/test2.feature'])
7
+ allow(CukeForker::NormalisedEncodingFile).to receive(:read).with(/features\/test\d\.feature/).and_return(<<-GHERKIN)
8
+ Feature: Test Feature
9
+
10
+ Scenario: Test Scenario 1
11
+ Given I do fake precondition
12
+ When I do fake action
13
+ Then I get fake assertions
14
+
15
+ Scenario: Test Scenario 2
16
+ Given I do fake precondition
17
+ When I do fake action
18
+ Then I get fake assertions
19
+ GHERKIN
8
20
 
9
- feature_1.instance_variable_set(:@source,
10
- "Feature: test 1
21
+ all_scenarios = Scenarios.all
22
+
23
+ all_scenarios.length.should == 4
24
+ all_scenarios[0].should == "features/test1.feature:3"
25
+ all_scenarios[1].should == "features/test1.feature:8"
26
+ all_scenarios[2].should == "features/test2.feature:3"
27
+ all_scenarios[3].should == "features/test2.feature:8"
28
+ end
29
+
30
+ it "returns all scenarios and their line numbers by tags" do
31
+ Scenarios.stub(:feature_files).and_return(['features/test1.feature'])
32
+ allow(CukeForker::NormalisedEncodingFile).to receive(:read).with('features/test1.feature').and_return(<<-GHERKIN)
33
+ Feature: test 1
34
+ @find_me
11
35
  Scenario: test scenario 1
12
36
  Given nothing happens
13
37
 
14
38
  Scenario: test scenario 2
15
- Given nothing else happens")
16
-
39
+ Given nothing else happens
40
+ GHERKIN
17
41
 
18
- feature_2.instance_variable_set(:@source,
19
- "Feature: test 2
42
+ all_scenarios = Scenarios.by_args(%W[-t @find_me])
20
43
 
21
- Scenario: test scenario 3
22
- Given nothing happens
44
+ all_scenarios.length.should == 1
45
+ all_scenarios[0].should == "features/test1.feature:3"
46
+ end
23
47
 
24
- Scenario Outline: test scenario 4
48
+ it "returns all scenarios and their line numbers by multiple include tags" do
49
+ Scenarios.stub(:feature_files).and_return(['features/test1.feature'])
50
+ allow(CukeForker::NormalisedEncodingFile).to receive(:read).with('features/test1.feature').and_return(<<-GHERKIN)
51
+ Feature: test 1
52
+ @find_me
53
+ Scenario: test scenario 1
25
54
  Given nothing happens
26
- Examples:
27
- | nothing |
28
- | 1 |
29
- ")
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)
33
55
 
34
- Scenarios.stub(:feature_files).and_return(['features/test1.feature', 'features/test2.feature'])
56
+ @me_too
57
+ Scenario: test scenario 2
58
+ Given nothing else happens
59
+ GHERKIN
35
60
 
36
- all_scenarios = Scenarios.all
61
+ all_scenarios = Scenarios.by_args(%W[-t @find_me,@me_too])
37
62
 
38
- all_scenarios.length.should == 4
39
- all_scenarios[0].should == "features/test1.feature:2"
40
- all_scenarios[1].should == "features/test1.feature:5"
41
- all_scenarios[2].should == "features/test2.feature:3"
42
- all_scenarios[3].should == "features/test2.feature:6"
63
+ all_scenarios.length.should == 2
64
+ all_scenarios[0].should == "features/test1.feature:3"
65
+ all_scenarios[1].should == "features/test1.feature:7"
43
66
  end
44
67
 
45
- it "returns all scenarios and their line numbers" do
46
- feature_1 = Cucumber::FeatureFile.new("features/test1.feature")
47
-
48
- feature_1.instance_variable_set(:@source,
49
- "Feature: test 1
50
- @find_me
68
+ it "returns all scenarios and their line numbers by multiple and tags" do
69
+ Scenarios.stub(:feature_files).and_return(['features/test1.feature'])
70
+ allow(CukeForker::NormalisedEncodingFile).to receive(:read).with('features/test1.feature').and_return(<<-GHERKIN)
71
+ Feature: test 1
72
+ @find_me @me_too
51
73
  Scenario: test scenario 1
52
74
  Given nothing happens
53
75
 
76
+ @me_too
54
77
  Scenario: test scenario 2
55
- Given nothing else happens")
78
+ Given nothing else happens
79
+ GHERKIN
80
+
81
+ all_scenarios = Scenarios.by_args(%W[-t @find_me -t @me_too])
56
82
 
57
- Cucumber::FeatureFile.stub(:new).with("features/test1.feature").and_return(feature_1)
83
+ all_scenarios.length.should == 1
84
+ all_scenarios[0].should == "features/test1.feature:3"
85
+ end
58
86
 
87
+ it "returns all scenarios and their line numbers by exclusion tag" do
59
88
  Scenarios.stub(:feature_files).and_return(['features/test1.feature'])
89
+ allow(CukeForker::NormalisedEncodingFile).to receive(:read).with('features/test1.feature').and_return(<<-GHERKIN)
90
+ Feature: test 1
91
+ @find_me
92
+ Scenario: test scenario 1
93
+ Given nothing happens
60
94
 
61
- all_scenarios = Scenarios.by_args(%W[-t @find_me])
95
+ @me_too
96
+ Scenario: test scenario 2
97
+ Given nothing else happens
98
+ GHERKIN
99
+
100
+ all_scenarios = Scenarios.by_args(%W[-t ~@find_me])
62
101
 
63
102
  all_scenarios.length.should == 1
64
- all_scenarios[0].should == "features/test1.feature:3"
103
+ all_scenarios[0].should == "features/test1.feature:7"
65
104
  end
66
105
  end
67
106
  end
107
+
@@ -2,10 +2,10 @@ require File.expand_path("../../spec_helper", __FILE__)
2
2
 
3
3
  module CukeForker
4
4
  describe VncListener do
5
- let(:server) { double(VncTools::Server, :display => ":15") }
6
- let(:pool) { double(VncTools::ServerPool) }
7
- let(:worker) { double(Worker, :data => OpenStruct.new) }
8
- let(:listener) { VncListener.new pool }
5
+ let(:server) { double(VncTools::Server, :display => ":15") }
6
+ let(:pool) { double(VncTools::ServerPool) }
7
+ let(:worker) { double(Worker, :data => OpenStruct.new) }
8
+ let(:listener) { VncListener.new pool }
9
9
 
10
10
  it "fetches a display from the pool and assings it to the worker" do
11
11
  pool.should_receive(:get).and_return(server)
@@ -34,6 +34,5 @@ module CukeForker
34
34
 
35
35
  listener.on_worker_forked worker
36
36
  end
37
-
38
37
  end # VncListenerServer
39
38
  end # CukeForker
@@ -183,11 +183,10 @@ module CukeForker
183
183
 
184
184
  queue.should_not be_backed_up
185
185
  queue.should be_empty
186
- queue.instance_variable_get(:@finished).should == [ workers[0], workers[3] ]
186
+ queue.instance_variable_get(:@finished).should == [workers[0], workers[3]]
187
187
 
188
188
  queue.should have_failures
189
189
  end
190
190
  end
191
-
192
- end # WorkerQueue
191
+ end # WorkerQueue
193
192
  end # CukeForker
@@ -26,15 +26,15 @@ module CukeForker
26
26
  end
27
27
 
28
28
  context "running a scenario with multiple report formats" do
29
- formats = [ :json, :junit ]
30
- path = "some/path"
29
+ formats = [:json, :junit]
30
+ path = "some/path"
31
31
  let(:worker) { Worker.new("some/feature:51", formats, path) }
32
32
 
33
33
  it "has an output file for each format specified" do
34
34
  expected_args = formats.flat_map do |f|
35
35
  %W[--format #{f} --out #{path}/some_feature_51.#{f}]
36
36
  end
37
- worker.args.each_cons(expected_args.size).include?(expected_args).should be_true
37
+ worker.args.each_cons(expected_args.size).include?(expected_args).should be_truthy
38
38
  end
39
39
  end
40
40
 
@@ -60,7 +60,7 @@ module CukeForker
60
60
 
61
61
  it "runs a passing cuke and exits with 0" do
62
62
  Process.should_receive(:fork).and_yield.and_return(1234)
63
- Process.should_receive(:setpgid).with(0,0)
63
+ Process.should_receive(:setpgid).with(0, 0)
64
64
 
65
65
  $stdout.should_receive(:reopen).with("some/path/some_feature.stdout")
66
66
  $stderr.should_receive(:reopen).with("some/path/some_feature.stderr")
@@ -73,7 +73,7 @@ module CukeForker
73
73
 
74
74
  it "runs a failing cuke and exits with 1" do
75
75
  Process.should_receive(:fork).and_yield.and_return(1234)
76
- Process.should_receive(:setpgid).with(0,0)
76
+ Process.should_receive(:setpgid).with(0, 0)
77
77
 
78
78
  $stdout.should_receive(:reopen).with("some/path/some_feature.stdout")
79
79
  $stderr.should_receive(:reopen).with("some/path/some_feature.stderr")
@@ -3,3 +3,5 @@ Coveralls.wear!
3
3
 
4
4
  $LOAD_PATH.unshift File.expand_path("../lib")
5
5
  require 'cukeforker'
6
+ require 'pry'
7
+
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukeforker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 1.0.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: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.5
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.5
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: vnctools
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.0.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.5
41
41
  - !ruby/object:Gem::Dependency
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Library to maintain a forking queue of Cucumber processes, with optional
84
98
  VNC displays.
85
99
  email:
@@ -101,17 +115,17 @@ files:
101
115
  - lib/cukeforker.rb
102
116
  - lib/cukeforker/abstract_listener.rb
103
117
  - lib/cukeforker/formatters/junit_scenario_formatter.rb
104
- - lib/cukeforker/formatters/scenario_line_logger.rb
105
118
  - lib/cukeforker/logging_listener.rb
119
+ - lib/cukeforker/normalised_encoding_file.rb
106
120
  - lib/cukeforker/rake_task.rb
107
121
  - lib/cukeforker/recording_vnc_listener.rb
108
122
  - lib/cukeforker/runner.rb
123
+ - lib/cukeforker/scenario_list.rb
109
124
  - lib/cukeforker/scenarios.rb
110
125
  - lib/cukeforker/version.rb
111
126
  - lib/cukeforker/vnc_listener.rb
112
127
  - lib/cukeforker/worker.rb
113
128
  - lib/cukeforker/worker_queue.rb
114
- - spec/cukeforker/formatters/scenario_line_logger_spec.rb
115
129
  - spec/cukeforker/logging_listener_spec.rb
116
130
  - spec/cukeforker/rake_task_spec.rb
117
131
  - spec/cukeforker/recording_vnc_listener_spec.rb
@@ -130,22 +144,21 @@ require_paths:
130
144
  - lib
131
145
  required_ruby_version: !ruby/object:Gem::Requirement
132
146
  requirements:
133
- - - '>='
147
+ - - ! '>='
134
148
  - !ruby/object:Gem::Version
135
149
  version: '0'
136
150
  required_rubygems_version: !ruby/object:Gem::Requirement
137
151
  requirements:
138
- - - '>='
152
+ - - ! '>='
139
153
  - !ruby/object:Gem::Version
140
154
  version: '0'
141
155
  requirements: []
142
156
  rubyforge_project: cukeforker
143
- rubygems_version: 2.0.14
157
+ rubygems_version: 2.4.6
144
158
  signing_key:
145
159
  specification_version: 4
146
160
  summary: Library to maintain a forking queue of Cucumber processes
147
161
  test_files:
148
- - spec/cukeforker/formatters/scenario_line_logger_spec.rb
149
162
  - spec/cukeforker/logging_listener_spec.rb
150
163
  - spec/cukeforker/rake_task_spec.rb
151
164
  - spec/cukeforker/recording_vnc_listener_spec.rb
@@ -1,28 +0,0 @@
1
- require 'gherkin/tag_expression'
2
- module CukeForker
3
- module Formatters
4
- class ScenarioLineLogger
5
- attr_reader :scenarios
6
-
7
- def initialize(tag_expression = Gherkin::TagExpression.new([]))
8
- @scenarios = []
9
- @tag_expression = tag_expression
10
- end
11
-
12
- def visit_feature_element(feature_element)
13
- if @tag_expression.evaluate(feature_element.source_tags)
14
- line_number = if feature_element.respond_to?(:line)
15
- feature_element.line
16
- else
17
- feature_element.location.line
18
- end
19
-
20
- @scenarios << [feature_element.feature.file, line_number].join(':')
21
- end
22
- end
23
-
24
- def method_missing(*args)
25
- end
26
- end
27
- end
28
- end
@@ -1,44 +0,0 @@
1
- require File.expand_path("../../../spec_helper", __FILE__)
2
- require 'cucumber/ast/scenario_outline'
3
-
4
- module CukeForker::Formatters
5
- describe ScenarioLineLogger do
6
- it "returns scenario names and line numbers for a scenario" do
7
- logger = ScenarioLineLogger.new
8
-
9
- feature = double("Cucumber::Ast::Feature")
10
- feature_element = double("Cucumber::Ast::Scenario")
11
-
12
- feature.should_receive(:file).twice.and_return('features/test1.feature')
13
- feature_element.should_receive(:source_tags).twice.and_return('')
14
- feature_element.should_receive(:feature).twice.and_return(feature)
15
- feature_element.should_receive(:line).and_return(3)
16
- feature_element.should_receive(:line).and_return(6)
17
-
18
- logger.visit_feature_element(feature_element)
19
- logger.visit_feature_element(feature_element)
20
-
21
- logger.scenarios.length.should == 2
22
- logger.scenarios[0].should == "features/test1.feature:3"
23
- logger.scenarios[1].should == "features/test1.feature:6"
24
- end
25
-
26
- it "returns scenario names and line numbers for a scenario outline" do
27
- logger = ScenarioLineLogger.new
28
-
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
- feature_element.stub(:location => location)
33
-
34
- feature.should_receive(:file).and_return('features/test1.feature')
35
- feature_element.should_receive(:source_tags).and_return('')
36
- feature_element.should_receive(:feature).and_return(feature)
37
-
38
- logger.visit_feature_element(feature_element)
39
-
40
- logger.scenarios.length.should == 1
41
- logger.scenarios[0].should == "features/test1.feature:4"
42
- end
43
- end
44
- end