cukeforker 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ pkg/*
4
4
  Gemfile.lock
5
5
  \#*
6
6
  .\#*
7
+ .idea
data/Rakefile CHANGED
@@ -3,3 +3,5 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require "rspec/core/rake_task"
5
5
  RSpec::Core::RakeTask.new
6
+
7
+ task :default => :spec
data/cukeforker.gemspec CHANGED
@@ -16,8 +16,9 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "cucumber"
18
18
  s.add_dependency "vnctools"
19
- s.add_development_dependency "rspec"
19
+ s.add_development_dependency "rspec", "~> 2.5"
20
20
  s.add_development_dependency "simplecov"
21
+ s.add_development_dependency "rake", "~> 0.9.2"
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/lib/cukeforker.rb CHANGED
@@ -20,3 +20,7 @@ require 'cukeforker/logging_listener'
20
20
  require 'cukeforker/worker'
21
21
  require 'cukeforker/worker_queue'
22
22
  require 'cukeforker/runner'
23
+ require 'cukeforker/scenarios'
24
+
25
+ require 'cukeforker/formatters/scenario_line_logger'
26
+ require 'cukeforker/formatters/junit_scenario_formatter'
@@ -0,0 +1,40 @@
1
+ require 'cucumber/formatter/junit'
2
+ require 'cucumber/formatter/ordered_xml_markup'
3
+ module CukeForker
4
+ module Formatters
5
+ class JunitScenarioFormatter < Cucumber::Formatter::Junit
6
+ def feature_result_filename(feature_file)
7
+ File.join(@reportdir, "TEST-#{basename(feature_file)}.xml")
8
+ end
9
+
10
+ def after_feature(feature)
11
+ # do nothing
12
+ end
13
+
14
+ def feature_element_line_number(feature_element)
15
+ if feature_element.respond_to? :line
16
+ feature_element.line
17
+ else
18
+ feature_element.instance_variable_get(:@line)
19
+ end
20
+ end
21
+
22
+ def after_feature_element(feature_element)
23
+ @testsuite = Cucumber::Formatter::OrderedXmlMarkup.new( :indent => 2 )
24
+ @testsuite.instruct!
25
+ @testsuite.testsuite(
26
+ :failures => @failures,
27
+ :errors => @errors,
28
+ :skipped => @skipped,
29
+ :tests => @tests,
30
+ :time => "%.6f" % @time,
31
+ :name => @feature_name ) do
32
+ @testsuite << @builder.target!
33
+ end
34
+
35
+ line_number = feature_element_line_number(feature_element)
36
+ write_file(feature_result_filename(feature_element.feature.file+"-#{line_number}"), @testsuite.target!)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
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.eval feature_element.source_tag_names
14
+ if feature_element.respond_to? :line
15
+ @scenarios << "#{feature_element.feature.file}:#{feature_element.line}"
16
+ else
17
+ @scenarios << "#{feature_element.feature.file}:#{feature_element.instance_variable_get(:@line)}"
18
+ end
19
+ end
20
+ end
21
+
22
+ def method_missing(*args)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -59,6 +59,8 @@ module CukeForker
59
59
  else
60
60
  listeners << RecordingVncListener.new(listener)
61
61
  end
62
+ else
63
+ listeners << listener
62
64
  end
63
65
  end
64
66
 
@@ -0,0 +1,43 @@
1
+ require 'cucumber/runtime/features_loader'
2
+
3
+ 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
+ class Scenarios
17
+ def self.by_args(args)
18
+ options = Cucumber::Cli::Options.new(STDOUT, STDERR, :default_profile => 'default')
19
+ tagged(options.parse!(args)[:tag_expressions])
20
+ end
21
+
22
+ def self.all
23
+ any_tag = []
24
+ tagged any_tag
25
+ end
26
+
27
+ 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)
34
+ end
35
+
36
+ scenario_line_logger.scenarios
37
+ end
38
+
39
+ def self.feature_files
40
+ Dir.glob('**/**.feature')
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module CukeForker
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,47 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ module CukeForker::Formatters
4
+ describe ScenarioLineLogger do
5
+ it "returns scenario names and line numbers for a scenario" do
6
+ logger = ScenarioLineLogger.new
7
+
8
+ feature = mock("Cucumber::Ast::Feature")
9
+ feature_element = mock("Cucumber::Ast::Scenario")
10
+
11
+ feature.should_receive(:file).twice.and_return('features/test1.feature')
12
+ feature_element.should_receive(:source_tag_names).twice.and_return('')
13
+ feature_element.should_receive(:feature).twice.and_return(feature)
14
+ feature_element.should_receive(:line).and_return(3)
15
+ feature_element.should_receive(:line).and_return(6)
16
+
17
+ logger.visit_feature_element(feature_element)
18
+ logger.visit_feature_element(feature_element)
19
+
20
+ logger.scenarios.length.should == 2
21
+ logger.scenarios[0].should == "features/test1.feature:3"
22
+ logger.scenarios[1].should == "features/test1.feature:6"
23
+ end
24
+
25
+ it "returns scenario names and line numbers for a scenario outline" do
26
+ logger = ScenarioLineLogger.new
27
+
28
+ class FakeScenarioOutline
29
+ def initialize
30
+ @line = 4
31
+ end
32
+ end
33
+
34
+ feature = mock("Cucumber::Ast::Feature")
35
+ feature_element = FakeScenarioOutline.new
36
+
37
+ feature.should_receive(:file).and_return('features/test1.feature')
38
+ feature_element.should_receive(:source_tag_names).and_return('')
39
+ feature_element.should_receive(:feature).and_return(feature)
40
+
41
+ logger.visit_feature_element(feature_element)
42
+
43
+ logger.scenarios.length.should == 1
44
+ logger.scenarios[0].should == "features/test1.feature:4"
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,67 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ module CukeForker
4
+ describe Scenarios do
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")
8
+
9
+ feature_1.instance_variable_set(:@source,
10
+ "Feature: test 1
11
+ Scenario: test scenario 1
12
+ Given nothing happens
13
+
14
+ Scenario: test scenario 2
15
+ Given nothing else happens")
16
+
17
+
18
+ feature_2.instance_variable_set(:@source,
19
+ "Feature: test 2
20
+
21
+ Scenario: test scenario 3
22
+ Given nothing happens
23
+
24
+ Scenario Outline: test scenario 4
25
+ 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
+
34
+ Scenarios.stub!(:feature_files).and_return(['features/test1.feature', 'features/test2.feature'])
35
+
36
+ all_scenarios = Scenarios.all
37
+
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"
43
+ end
44
+
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
51
+ Scenario: test scenario 1
52
+ Given nothing happens
53
+
54
+ Scenario: test scenario 2
55
+ Given nothing else happens")
56
+
57
+ Cucumber::FeatureFile.stub!(:new).with("features/test1.feature").and_return(feature_1)
58
+
59
+ Scenarios.stub!(:feature_files).and_return(['features/test1.feature'])
60
+
61
+ all_scenarios = Scenarios.by_args(%W[-t @find_me])
62
+
63
+ all_scenarios.length.should == 1
64
+ all_scenarios[0].should == "features/test1.feature:3"
65
+ end
66
+ end
67
+ end
@@ -1,6 +1,7 @@
1
1
  require File.expand_path("../../spec_helper", __FILE__)
2
2
 
3
3
  module CukeForker
4
+
4
5
  describe Worker do
5
6
  let(:worker) { Worker.new("some/feature", :json, "some/path", %w[--extra args]) }
6
7
 
@@ -8,6 +9,22 @@ module CukeForker
8
9
  FileUtils.stub :mkdir_p
9
10
  }
10
11
 
12
+ context "running a scenario on specific line" do
13
+ let(:worker) { Worker.new("some/feature:51", :json, "some/path", %w[--extra args]) }
14
+
15
+ it "has an output file that includes the line number in its name" do
16
+ worker.output.should == "some/path/some_feature_51.json"
17
+ end
18
+
19
+ it "has a stdout file that includes the line number in its name" do
20
+ worker.stdout.should == "some/path/some_feature_51.stdout"
21
+ end
22
+
23
+ it "has a stderr file that includes the line number in its name" do
24
+ worker.stderr.should == "some/path/some_feature_51.stderr"
25
+ end
26
+ end
27
+
11
28
  it "creates an argument string based on the given parameters" do
12
29
  worker.args.should == %w{--format json --out some/path/some_feature.json --extra args some/feature }
13
30
  end
@@ -98,6 +115,5 @@ module CukeForker
98
115
  Process.stub(:waitpid2).and_raise(Errno::ESRCH)
99
116
  worker.should be_finished
100
117
  end
101
-
102
118
  end # Worker
103
119
  end # CukeForker
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukeforker
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease:
5
- version: 0.1.3
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 4
10
+ version: 0.1.4
6
11
  platform: ruby
7
12
  authors:
8
13
  - Jari Bakken
@@ -10,8 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-02-14 00:00:00 +01:00
14
- default_executable:
18
+ date: 2011-09-22 00:00:00 Z
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
17
21
  name: cucumber
@@ -21,6 +25,9 @@ dependencies:
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
24
31
  version: "0"
25
32
  type: :runtime
26
33
  version_requirements: *id001
@@ -32,6 +39,9 @@ dependencies:
32
39
  requirements:
33
40
  - - ">="
34
41
  - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
35
45
  version: "0"
36
46
  type: :runtime
37
47
  version_requirements: *id002
@@ -41,9 +51,13 @@ dependencies:
41
51
  requirement: &id003 !ruby/object:Gem::Requirement
42
52
  none: false
43
53
  requirements:
44
- - - ">="
54
+ - - ~>
45
55
  - !ruby/object:Gem::Version
46
- version: "0"
56
+ hash: 9
57
+ segments:
58
+ - 2
59
+ - 5
60
+ version: "2.5"
47
61
  type: :development
48
62
  version_requirements: *id003
49
63
  - !ruby/object:Gem::Dependency
@@ -54,9 +68,28 @@ dependencies:
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
57
74
  version: "0"
58
75
  type: :development
59
76
  version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: rake
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ hash: 63
86
+ segments:
87
+ - 0
88
+ - 9
89
+ - 2
90
+ version: 0.9.2
91
+ type: :development
92
+ version_requirements: *id005
60
93
  description: Library to maintain a forking queue of Cucumber processes, with optional VNC displays.
61
94
  email:
62
95
  - jari.bakken@gmail.com
@@ -77,21 +110,25 @@ files:
77
110
  - cukeforker.gemspec
78
111
  - lib/cukeforker.rb
79
112
  - lib/cukeforker/abstract_listener.rb
113
+ - lib/cukeforker/formatters/junit_scenario_formatter.rb
114
+ - lib/cukeforker/formatters/scenario_line_logger.rb
80
115
  - lib/cukeforker/logging_listener.rb
81
116
  - lib/cukeforker/recording_vnc_listener.rb
82
117
  - lib/cukeforker/runner.rb
118
+ - lib/cukeforker/scenarios.rb
83
119
  - lib/cukeforker/version.rb
84
120
  - lib/cukeforker/vnc_listener.rb
85
121
  - lib/cukeforker/worker.rb
86
122
  - lib/cukeforker/worker_queue.rb
123
+ - spec/cukeforker/formatters/scenario_line_logger_spec.rb
87
124
  - spec/cukeforker/logging_listener_spec.rb
88
125
  - spec/cukeforker/recording_vnc_listener_spec.rb
89
126
  - spec/cukeforker/runner_spec.rb
127
+ - spec/cukeforker/scenarios_spec.rb
90
128
  - spec/cukeforker/vnc_listener_spec.rb
91
129
  - spec/cukeforker/worker_queue_spec.rb
92
130
  - spec/cukeforker/worker_spec.rb
93
131
  - spec/spec_helper.rb
94
- has_rdoc: true
95
132
  homepage: ""
96
133
  licenses: []
97
134
 
@@ -105,24 +142,32 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
142
  requirements:
106
143
  - - ">="
107
144
  - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
108
148
  version: "0"
109
149
  required_rubygems_version: !ruby/object:Gem::Requirement
110
150
  none: false
111
151
  requirements:
112
152
  - - ">="
113
153
  - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
114
157
  version: "0"
115
158
  requirements: []
116
159
 
117
160
  rubyforge_project: cukeforker
118
- rubygems_version: 1.5.2
161
+ rubygems_version: 1.8.10
119
162
  signing_key:
120
163
  specification_version: 3
121
164
  summary: Library to maintain a forking queue of Cucumber processes
122
165
  test_files:
166
+ - spec/cukeforker/formatters/scenario_line_logger_spec.rb
123
167
  - spec/cukeforker/logging_listener_spec.rb
124
168
  - spec/cukeforker/recording_vnc_listener_spec.rb
125
169
  - spec/cukeforker/runner_spec.rb
170
+ - spec/cukeforker/scenarios_spec.rb
126
171
  - spec/cukeforker/vnc_listener_spec.rb
127
172
  - spec/cukeforker/worker_queue_spec.rb
128
173
  - spec/cukeforker/worker_spec.rb