cucumber-pro 0.0.13 → 0.0.14

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: 35dcec69d5a9599d4d30a57ba1edc2d3a7a0d636
4
- data.tar.gz: b0b5af3ce80e5f81180ecf337a35ababbd919933
3
+ metadata.gz: b480901553d723dcc5d4df5f5cbf69556af33d63
4
+ data.tar.gz: b4af2756d621c2f543d15dd8b3a97e69718ae5d8
5
5
  SHA512:
6
- metadata.gz: ed859c503bdd207631bc765d19c3432694c0434bc75637428bf8f8b5baf0f7c957411f59054db35459b89108f90e7c0605b1cc4edb15938c942ab0570b2d6c93
7
- data.tar.gz: 4f5b098807e4539ba050640fbf354e28b0d1fa63f326faa1471e213e5e5668c4f9c4207f38e8e3730e7afad22137c191687cb21f94584fe44a6d91c6eb442d40
6
+ metadata.gz: db68949da991567d0d4f45e026b17c0960cd2a409f1790b8bbb26781d6ad5e105ca9b4038792410b193348d3bbfa2fdbcb1aa42f302760a02da1674bcc2dc855
7
+ data.tar.gz: 469d4188973e72533ef6eb14d812f468ac6f3e6908d8e125c34fd47e54e18defa07fa54d5032daa08c0890fec16264dfe8ce84adae304c632e2c3b3b71642c83
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,5 @@
1
+ ## Release process
2
+
3
+ * Update `HISTORY.md`
4
+ * Bump version in `lib/cucumber/pro/version` and commit.
5
+ * Release: `bundle exec rake release`
data/HISTORY.md ADDED
@@ -0,0 +1,8 @@
1
+ ## [0.0.14](https://github.com/cucumber-ltd/cucumber-pro-ruby/compare/v0.0.13...v0.0.14) (2014-09-02)
2
+
3
+ * Only publish results if we detect a CI environment.
4
+ * Assign `build_id` from common CI env vars
5
+
6
+ ## [0.0.13](https://github.com/cucumber-ltd/cucumber-pro-ruby/compare/v0.0.12...v0.0.13) (2014-07-07)
7
+
8
+ * Check `CI` as well as `CUCUMBER_PRO_TOKEN`.
data/Rakefile CHANGED
@@ -7,14 +7,13 @@ task default: [:rspec, :cucumber]
7
7
 
8
8
  # Because https://github.com/eventmachine/eventmachine/issues/34
9
9
  if ENV['TRAVIS'] && RUBY_PLATFORM =~ /java/
10
- ENV['CUCUMBER_PRO_URL']="ws://results.cucumber.pro/ws"
10
+ # Don't use TLS on JRuby
11
+ ENV['CUCUMBER_PRO_RESULTS_URL']="ws://results.cucumber.pro/ws"
11
12
  end
12
13
 
13
14
  require 'cucumber/rake/task'
14
15
  Cucumber::Rake::Task.new do |t|
15
- t.cucumber_opts = ""
16
- t.cucumber_opts = "--format Cucumber::Pro --out cucumber-pro.log"
17
- t.cucumber_opts << "--format pretty"
16
+ t.cucumber_opts = "--format pretty"
18
17
  end
19
18
 
20
19
  task :rspec do
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format Cucumber::Pro --out /dev/null
@@ -5,6 +5,7 @@ Feature: Publish results
5
5
  Given I set the environment variables to:
6
6
  | variable | value |
7
7
  | CUCUMBER_PRO_TOKEN | valid-token |
8
+ | BUILD_NUMBER | 22 |
8
9
 
9
10
  Scenario: A couple of scenarios
10
11
  Given a git repo
@@ -52,4 +53,3 @@ Feature: Publish results
52
53
  | status | path | location |
53
54
  | passed | features/test.feature | 7 |
54
55
  | failed | features/test.feature | 8 |
55
-
@@ -12,5 +12,6 @@ Feature: Security
12
12
  When I set the environment variables to:
13
13
  | variable | value |
14
14
  | CUCUMBER_PRO_TOKEN | invalid-token |
15
+ | CI | true |
15
16
  And I run `cucumber -f Cucumber::Pro -o /dev/null -f pretty`
16
17
  And the stderr should contain "Access denied"
data/lib/cucumber/pro.rb CHANGED
@@ -11,7 +11,7 @@ module Cucumber
11
11
 
12
12
  working_copy = Scm::WorkingCopy.detect
13
13
 
14
- if token
14
+ if should_publish
15
15
  working_copy.check_clean
16
16
  session = WebSocket::Session.new(url, logger, timeout: config.timeout)
17
17
  else
@@ -25,15 +25,15 @@ module Cucumber
25
25
  yield config
26
26
  end
27
27
 
28
+ def config
29
+ @config ||= Config.new
30
+ end
31
+
28
32
  private
29
33
 
30
34
  attr_reader :logger
31
35
  private :logger
32
36
 
33
- def config
34
- @config ||= Config.new
35
- end
36
-
37
37
  def url
38
38
  config.url + "?token=#{token}"
39
39
  end
@@ -45,16 +45,22 @@ module Cucumber
45
45
  def token
46
46
  config.token
47
47
  end
48
+
49
+ def should_publish
50
+ config.should_publish
51
+ end
48
52
  end
49
53
 
50
54
  class Config
51
- attr_accessor :url, :logger, :token, :timeout
55
+ attr_accessor :url, :logger, :token, :should_publish, :timeout, :build_number
52
56
  end
53
57
 
54
58
  # Default config
55
59
  configure do |config|
56
- config.url = ENV['CUCUMBER_PRO_URL'] || 'wss://results.cucumber.pro/ws'
60
+ config.url = ENV['CUCUMBER_PRO_RESULTS_URL'] || 'wss://results.cucumber.pro/ws'
57
61
  config.token = ENV['CUCUMBER_PRO_TOKEN']
62
+ config.build_number = ENV['BUILD_NUMBER'] || ENV['CIRCLE_BUILD_NUM'] || ENV['TRAVIS_JOB_NUMBER'] || ENV['bamboo.buildNumber'] || ENV['CI_BUILD_NUMBER']
63
+ config.should_publish = config.token && (config.build_number || ENV['CI'])
58
64
  config.timeout = 5
59
65
  if file = ENV['CUCUMBER_PRO_LOG_FILE']
60
66
  config.logger = Logger.new(file)
@@ -58,7 +58,7 @@ module Cucumber
58
58
  repo_url: @working_copy.repo_url,
59
59
  branch: @working_copy.branch,
60
60
  rev: @working_copy.rev,
61
- group: get_run_id,
61
+ build_id: get_build_number,
62
62
  info: Info.new.to_h
63
63
  })
64
64
  end
@@ -81,8 +81,8 @@ module Cucumber
81
81
  })
82
82
  end
83
83
 
84
- def get_run_id
85
- SecureRandom.hex
84
+ def get_build_number
85
+ Pro.config.build_number || SecureRandom.hex
86
86
  end
87
87
 
88
88
  end
@@ -9,7 +9,7 @@ module Cucumber
9
9
  {
10
10
  os: "#{RbConfig::CONFIG['host_os']} (#{RbConfig::CONFIG['host_cpu']})",
11
11
  platform_version: "#{RbConfig::CONFIG['ruby_install_name']} #{RbConfig::CONFIG['ruby_version']}",
12
- tool_version: "cucumber-ruby #{Cucumber::VERSION}}",
12
+ tool_version: "cucumber-ruby #{Cucumber::VERSION}",
13
13
  os_user: Etc.getlogin,
14
14
  client_version: "cucumber-pro-ruby #{File.read(File.dirname(__FILE__) + '/version').strip}",
15
15
  cmd: ([$PROGRAM_NAME] + ARGV).join(' ')
@@ -36,11 +36,16 @@ module Cucumber
36
36
  cmd('git config --get remote.origin.url').last
37
37
  end
38
38
 
39
+ # tries to return the name of the origin branch that points to the current HEAD
39
40
  def branch
40
- branch = cmd("git branch --contains #{rev}").
41
- reject { |b| /^\* \(detached from \w+\)/.match b }.
42
- first.
43
- gsub(/^\* /, '')
41
+ if remote_refs.empty?
42
+ # just use local branch name
43
+ return cmd("git name-rev --name-only HEAD")[0]
44
+ end
45
+ if remote_refs.length > 1
46
+ fail "Multiple remote branches point to this commit: #{remote_refs.join(',')}"
47
+ end
48
+ remote_refs.first.gsub(/refs\/remotes\/\w+\//, '')
44
49
  end
45
50
 
46
51
  def rev
@@ -54,6 +59,16 @@ module Cucumber
54
59
 
55
60
  private
56
61
 
62
+ def remote_refs
63
+ @remote_refs ||= refs.
64
+ select { |ref| ref =~ /refs\/remotes/ }.
65
+ reject { |ref| ref =~ /refs\/remotes\/\w+\/HEAD/ }
66
+ end
67
+
68
+ def refs
69
+ @refs ||= cmd("git show-ref | grep #{rev}").map { |output| output.split[1] }
70
+ end
71
+
57
72
  def cmd(cmd)
58
73
  Dir.chdir(@path) { `#{cmd}` }.lines.map &:strip
59
74
  end
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
@@ -10,27 +10,47 @@ module Cucumber
10
10
  clean_current_dir
11
11
  in_current_dir do
12
12
  run_simple "git init"
13
- run_simple "git config user.email \"test@test.com\""
14
- run_simple "git config user.name \"Test user\""
13
+ git_config
15
14
  end
16
15
  end
17
16
 
18
17
  it "figures out the name of the branch, even on CI" do
18
+ create_origin_repo
19
+ clone_origin_repo
20
+ commit_and_push
21
+ # check out the remote branch
22
+ run_simple "git checkout remotes/origin/master"
23
+ # delete master branch
24
+ run_simple "git branch -D master"
25
+ working_copy = WorkingCopy.detect(current_dir)
26
+ expect( working_copy.branch ).to eq "master"
27
+ end
28
+
29
+ it "figures out the name of the branch, even when the local branch has a different name" do
30
+ create_origin_repo
31
+ clone_origin_repo
32
+ commit_and_push
33
+ # check out the remote branch with a different name
34
+ run_simple "git checkout -b foo --track origin/master"
35
+ working_copy = WorkingCopy.detect(current_dir)
36
+ expect( working_copy.branch ).to eq "master"
37
+ end
38
+
39
+ it "figures out the name of the branch when that's what's checked out" do
19
40
  in_current_dir do
20
41
  run_simple "git commit --allow-empty -m 'Initial commit'"
21
- run_simple "git rev-parse HEAD"
22
- rev = all_stdout.split("\n").last
23
- run_simple "git checkout #{rev}"
24
42
  working_copy = WorkingCopy.detect(current_dir)
25
43
  expect( working_copy.branch ).to eq "master"
26
44
  end
27
45
  end
28
46
 
29
- it "figures out the name of the branch when that's what's checked out" do
47
+ it "figures out the name of the branch when it has a name that looks like a remote branch" do
30
48
  in_current_dir do
31
49
  run_simple "git commit --allow-empty -m 'Initial commit'"
50
+ run_simple "git checkout -b remotes/foo/bar"
51
+ run_simple "git commit --allow-empty -m 'Another commit'"
32
52
  working_copy = WorkingCopy.detect(current_dir)
33
- expect( working_copy.branch ).to eq "master"
53
+ expect( working_copy.branch ).to eq "remotes/foo/bar"
34
54
  end
35
55
  end
36
56
 
@@ -43,17 +63,68 @@ module Cucumber
43
63
  end
44
64
  end
45
65
 
46
- xit "detects unpushed changes" do
47
- # This one is a little trickier to test. I think we may have to fetch commits
48
- # from a repo first.
49
- in_current_dir do
50
- write_file "README.md", "# README"
51
- run_simple "git add README.md"
52
- run_simple "git commit -am 'I committed but that is not good enough'"
53
- working_copy = WorkingCopy.detect(current_dir)
54
- expect { working_copy.check_clean }.to raise_error(DirtyWorkingCopy, /Your current branch has commits that haven't been pushed to origin/)
55
- end
66
+ it "detects unpushed changes to an existing file" do
67
+ create_origin_repo
68
+ clone_origin_repo
69
+ commit_and_push "foo"
70
+ write_file "foo", "contents"
71
+ run_simple "git add ."
72
+ run_simple "git commit -m 'foo'"
73
+ working_copy = WorkingCopy.detect(current_dir)
74
+ expect { working_copy.check_clean }.to raise_error(DirtyWorkingCopy, /Your current branch has commits that haven't been pushed to origin/)
75
+ end
76
+
77
+ it "detects unpushed changes to a new file" do
78
+ create_origin_repo
79
+ clone_origin_repo
80
+ commit_and_push "foo"
81
+ run_simple "touch bar"
82
+ run_simple "git add ."
83
+ run_simple "git commit -m 'bar'"
84
+ working_copy = WorkingCopy.detect(current_dir)
85
+ expect { working_copy.check_clean }.to raise_error(DirtyWorkingCopy, /Your current branch has commits that haven't been pushed to origin/)
56
86
  end
87
+
88
+ it "detects a dirty working directory" do
89
+ create_origin_repo
90
+ clone_origin_repo
91
+ commit_and_push "foo"
92
+ write_file "foo", "contents"
93
+ working_copy = WorkingCopy.detect(current_dir)
94
+ expect { working_copy.check_clean }.to raise_error(DirtyWorkingCopy, /Please commit and push your changes before running with the Cucumber Pro formatter/)
95
+ end
96
+
97
+ def create_origin_repo
98
+ create_dir "origin"
99
+ cd "origin"
100
+ run_simple "git init --bare"
101
+ git_config
102
+ cd ".."
103
+ end
104
+
105
+ def clone_origin_repo
106
+ run_simple "git clone ./origin local"
107
+ cd "local"
108
+ git_config
109
+ end
110
+
111
+ def commit_and_push(filename = 'foo')
112
+ run_simple "touch #{filename}"
113
+ run_simple "git add ."
114
+ run_simple "git commit -m '#{commit_message}'"
115
+ run_simple "git push origin master"
116
+ end
117
+
118
+ def commit_message
119
+ @commit_number ||= 0
120
+ "Commit message #{@commit_number += 1}"
121
+ end
122
+
123
+ def git_config
124
+ run_simple "git config user.email \"test@test.com\""
125
+ run_simple "git config user.name \"Test user\""
126
+ end
127
+
57
128
  end
58
129
  end
59
130
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wynne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.7'
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
26
  version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.5
34
34
  type: :development
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: 1.3.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.9.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.14.1
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: 2.14.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cucumber
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: aruba
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: puma
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rack
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: anticipate
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Client library for publishing results to the Cucumber Pro service
@@ -142,14 +142,17 @@ executables: []
142
142
  extensions: []
143
143
  extra_rdoc_files: []
144
144
  files:
145
- - ".rspec"
146
- - ".travis.yml"
145
+ - .rspec
146
+ - .travis.yml
147
+ - CONTRIBUTING.md
147
148
  - Gemfile
149
+ - HISTORY.md
148
150
  - LICENSE
149
151
  - README.md
150
152
  - Rakefile
151
153
  - TODO.md
152
154
  - cucumber-pro.gemspec
155
+ - cucumber.yml
153
156
  - features/publish_results.feature
154
157
  - features/security.feature
155
158
  - features/step_definitions/steps.rb
@@ -173,17 +176,17 @@ licenses:
173
176
  metadata: {}
174
177
  post_install_message:
175
178
  rdoc_options:
176
- - "--charset=UTF-8"
179
+ - --charset=UTF-8
177
180
  require_paths:
178
181
  - lib
179
182
  required_ruby_version: !ruby/object:Gem::Requirement
180
183
  requirements:
181
- - - ">="
184
+ - - '>='
182
185
  - !ruby/object:Gem::Version
183
186
  version: 1.9.3
184
187
  required_rubygems_version: !ruby/object:Gem::Requirement
185
188
  requirements:
186
- - - ">="
189
+ - - '>='
187
190
  - !ruby/object:Gem::Version
188
191
  version: '0'
189
192
  requirements: []
@@ -191,7 +194,7 @@ rubyforge_project:
191
194
  rubygems_version: 2.0.14
192
195
  signing_key:
193
196
  specification_version: 4
194
- summary: cucumber-pro-0.0.13
197
+ summary: cucumber-pro-0.0.14
195
198
  test_files:
196
199
  - features/publish_results.feature
197
200
  - features/security.feature
@@ -203,4 +206,3 @@ test_files:
203
206
  - spec/cucumber/pro/info_spec.rb
204
207
  - spec/cucumber/pro/scm/git_working_copy_spec.rb
205
208
  - spec/cucumber/pro/web_socket/worker_spec.rb
206
- has_rdoc: