gitnesse 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gitnesse/cli.rb +2 -1
- data/lib/gitnesse/cli/task/run.rb +15 -7
- data/lib/gitnesse/hooks.rb +10 -3
- data/lib/gitnesse/version.rb +1 -1
- data/lib/gitnesse/wiki/page.rb +14 -9
- data/spec/lib/config_loader_spec.rb +11 -10
- data/spec/lib/dependency_checker_spec.rb +13 -13
- data/spec/lib/dir_manager_spec.rb +4 -4
- data/spec/lib/wiki/page_spec.rb +1 -1
- data/spec/support_helper.rb +25 -9
- metadata +3 -5
- data/spec/support/cli.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be94d888608f5e3f317832d868b72a51c028c85
|
4
|
+
data.tar.gz: c7539589e565d2331879b2b16b3810159fffe797
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281e86c029b1a61720002b5ae889a2f8f6764a276ee2819084907fa12c590e18f6b786953427ef1f087c9830fd53e76a688140b64ce85fe65a19cd65766413fd
|
7
|
+
data.tar.gz: e6de2276bb6dcb372aea80fc149ad89b31717c855f4dbee81d771e4746738a50ec4125a8884dbbf537bc8d8030b9e3b578227a2e4e0a8c1e682155c456adfdd4
|
data/lib/gitnesse/cli.rb
CHANGED
@@ -11,12 +11,16 @@ Pulls changed features from remote git-based wiki, runs Cucumber, and pushes
|
|
11
11
|
annotated results to the remote git-based wiki if the "annotate_results" setting
|
12
12
|
is enabled.
|
13
13
|
|
14
|
+
Unlike other commands, all arguments passed to gitnesse run will be passed
|
15
|
+
through to Cucumber if you only want to run specific cukes.
|
16
|
+
|
14
17
|
Examples:
|
15
18
|
gitnesse run # will pull changes, run cucumber, and annotate results
|
19
|
+
gitnesse run ./features/addition.feature
|
16
20
|
EOS
|
17
21
|
end
|
18
22
|
|
19
|
-
def perform
|
23
|
+
def perform(*args)
|
20
24
|
load_and_check_config
|
21
25
|
clone_wiki
|
22
26
|
extract_features_from_wiki
|
@@ -27,7 +31,7 @@ Examples:
|
|
27
31
|
remove_existing_results_from_wiki
|
28
32
|
|
29
33
|
create_hooks
|
30
|
-
run_features
|
34
|
+
run_features(args)
|
31
35
|
remove_hooks
|
32
36
|
|
33
37
|
push_annotated_results_to_wiki
|
@@ -64,15 +68,19 @@ Examples:
|
|
64
68
|
|
65
69
|
# Public: Runs Cucumber features
|
66
70
|
#
|
71
|
+
# args - optional array of arguments to be passed to Cucumber
|
72
|
+
#
|
67
73
|
# Returns nothing
|
68
|
-
def run_features
|
69
|
-
puts " Running cucumber."
|
70
|
-
|
74
|
+
def run_features(args = [])
|
75
|
+
puts " Running cucumber.", ' -------------------', ''
|
76
|
+
args = (args.empty? ? @config.features_dir : args.join(' '))
|
77
|
+
|
71
78
|
if defined?(Bundler)
|
72
|
-
Bundler.with_clean_env { system "cucumber #{
|
79
|
+
Bundler.with_clean_env { system "bundle exec cucumber #{args}" }
|
73
80
|
else
|
74
|
-
system "cucumber #{
|
81
|
+
system "bundle exec cucumber #{args}"
|
75
82
|
end
|
83
|
+
|
76
84
|
puts ' -------------------', ''
|
77
85
|
end
|
78
86
|
|
data/lib/gitnesse/hooks.rb
CHANGED
@@ -31,10 +31,17 @@ module Gitnesse
|
|
31
31
|
Gitnesse::ConfigLoader.find_and_load
|
32
32
|
dir = Gitnesse::DirManager.project_dir
|
33
33
|
|
34
|
-
|
34
|
+
if scenario.respond_to?(:scenario_outline)
|
35
|
+
file = scenario.scenario_outline.file.gsub(/^#{@config.features_dir}\//, '')
|
36
|
+
name = "#{scenario.scenario_outline.name}"
|
37
|
+
subtitle = scenario.name.gsub(/(^\|\s+|\s+\|$)/, '').gsub(/\s+\|/, ',')
|
38
|
+
else
|
39
|
+
file = scenario.file.gsub(/^#{@config.features_dir}\//, '')
|
40
|
+
name = scenario.name
|
41
|
+
subtitle = nil
|
42
|
+
end
|
35
43
|
|
36
44
|
page = file.gsub("/", " > ")
|
37
|
-
name = scenario.name
|
38
45
|
status = scenario.status
|
39
46
|
|
40
47
|
@wiki = Gitnesse::Wiki.new(@config.repository_url, dir, clone: false)
|
@@ -42,7 +49,7 @@ module Gitnesse
|
|
42
49
|
|
43
50
|
return unless page
|
44
51
|
|
45
|
-
page.append_result name, status
|
52
|
+
page.append_result name, status, subtitle
|
46
53
|
@wiki.repo.add(page.wiki_path)
|
47
54
|
end
|
48
55
|
end
|
data/lib/gitnesse/version.rb
CHANGED
data/lib/gitnesse/wiki/page.rb
CHANGED
@@ -41,7 +41,11 @@ module Gitnesse
|
|
41
41
|
#
|
42
42
|
# Returns nothing
|
43
43
|
def remove_results
|
44
|
-
|
44
|
+
content = read
|
45
|
+
# Remove old Cucumber results, if they exist
|
46
|
+
content.gsub!(/(\s+\!\[\].*)/, '') unless content =~ /\s+- !\[\].*---/m
|
47
|
+
content.gsub!(/\s+- !\[\].*---/m, '')
|
48
|
+
write content
|
45
49
|
end
|
46
50
|
|
47
51
|
# Public: Appends the result of a Cucumber scenario to the feature's wiki
|
@@ -50,16 +54,17 @@ module Gitnesse
|
|
50
54
|
# scenario - feature scenario that was run
|
51
55
|
# status - return status of the scenario, e.g. :passed, :undefined,
|
52
56
|
# :failing
|
57
|
+
# subtitle - subtitle of scenario (used for scenario outlines)
|
53
58
|
#
|
54
59
|
# Returns nothing
|
55
|
-
def append_result(scenario, status)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
string
|
61
|
-
string << " (#{
|
62
|
-
string << "#{
|
60
|
+
def append_result(scenario, status, subtitle = nil)
|
61
|
+
image = "![](//s3.amazonaws.com/gitnesse/github/#{status.to_s}.png)"
|
62
|
+
time = Time.now.strftime("%b %d, %Y, %-l:%M %p")
|
63
|
+
identifier = Gitnesse::Config.instance.identifier
|
64
|
+
|
65
|
+
string = "\n- #{image} **#{scenario}**".chomp
|
66
|
+
string << "\n- **(#{subtitle})**" if subtitle
|
67
|
+
string << "\n- #{identifier} - #{time}\n\n---"
|
63
68
|
|
64
69
|
write(read + string)
|
65
70
|
end
|
@@ -7,8 +7,9 @@ module Gitnesse
|
|
7
7
|
describe "#find_and_load" do
|
8
8
|
context "when no config file exists" do
|
9
9
|
before do
|
10
|
-
Dir.
|
11
|
-
|
10
|
+
expect(Dir).to receive(:glob).and_return []
|
11
|
+
message = "Can't find a gitnesse.rb file with Gitnesse configuration."
|
12
|
+
expect(ConfigLoader).to receive(:raise_error).with message
|
12
13
|
end
|
13
14
|
|
14
15
|
it "raises an error" do
|
@@ -18,10 +19,10 @@ module Gitnesse
|
|
18
19
|
|
19
20
|
context "when one config file exists" do
|
20
21
|
before do
|
21
|
-
files = [Support.
|
22
|
-
Dir.
|
23
|
-
ConfigLoader.
|
24
|
-
ConfigLoader.
|
22
|
+
files = [Support.example_config_file]
|
23
|
+
expect(Dir).to receive(:glob).and_return(files)
|
24
|
+
expect(ConfigLoader).to receive(:load).and_return(true)
|
25
|
+
expect(ConfigLoader).to receive(:reject_irrelevant_files).and_return(files)
|
25
26
|
end
|
26
27
|
|
27
28
|
it "loads the config file" do
|
@@ -31,10 +32,10 @@ module Gitnesse
|
|
31
32
|
|
32
33
|
context "when multiple config files exist" do
|
33
34
|
before do
|
34
|
-
files = [Support.
|
35
|
-
Dir.
|
36
|
-
ConfigLoader.
|
37
|
-
ConfigLoader.
|
35
|
+
files = [Support.example_config_file, Support.example_config_file]
|
36
|
+
expect(Dir).to receive(:glob).and_return(files)
|
37
|
+
expect(ConfigLoader).to receive(:reject_irrelevant_files).and_return(files)
|
38
|
+
expect(ConfigLoader).to receive(:raise_error).with("Multiple configuration files found:", files)
|
38
39
|
end
|
39
40
|
|
40
41
|
it "raises an error" do
|
@@ -10,7 +10,7 @@ module Gitnesse
|
|
10
10
|
checks = %w(check_git check_cucumber check_repository_url
|
11
11
|
check_identifier check_features_dir_exists)
|
12
12
|
checks.each do |check|
|
13
|
-
checker.
|
13
|
+
expect(checker).to receive(check.to_sym).and_return(true)
|
14
14
|
end
|
15
15
|
|
16
16
|
checker.check
|
@@ -21,11 +21,11 @@ module Gitnesse
|
|
21
21
|
check_features_dir_exists)
|
22
22
|
|
23
23
|
checks.each do |check|
|
24
|
-
checker.
|
24
|
+
expect(checker).to receive(check.to_sym).and_return(true)
|
25
25
|
end
|
26
26
|
|
27
|
-
checker.
|
28
|
-
checker.
|
27
|
+
expect(checker).to receive(:system).with('git --version &> /dev/null').and_return(nil)
|
28
|
+
expect(checker).to receive(:display_errors)
|
29
29
|
|
30
30
|
checker.check
|
31
31
|
end
|
@@ -35,9 +35,9 @@ module Gitnesse
|
|
35
35
|
before do
|
36
36
|
checker.instance_variable_set(:@errors, ["this is an example error"])
|
37
37
|
|
38
|
-
checker.
|
39
|
-
checker.
|
40
|
-
checker.
|
38
|
+
expect(checker).to receive(:puts).with("Configuration errors were found!")
|
39
|
+
expect(checker).to receive(:puts).with(" - this is an example error")
|
40
|
+
expect(checker).to receive(:abort)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "prints a note saying errors were found" do
|
@@ -56,7 +56,7 @@ module Gitnesse
|
|
56
56
|
describe '#check_git' do
|
57
57
|
context 'when git is installed' do
|
58
58
|
before do
|
59
|
-
checker.
|
59
|
+
expect(checker).to receive(:system).with('git --version &> /dev/null').and_return(true)
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'returns true' do
|
@@ -66,7 +66,7 @@ module Gitnesse
|
|
66
66
|
|
67
67
|
context 'when git is not installed' do
|
68
68
|
before do
|
69
|
-
checker.
|
69
|
+
expect(checker).to receive(:system).with('git --version &> /dev/null').and_return(nil)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'adds an error' do
|
@@ -80,7 +80,7 @@ module Gitnesse
|
|
80
80
|
describe '#check_cucumber' do
|
81
81
|
context 'when cucumber is installed' do
|
82
82
|
before do
|
83
|
-
checker.
|
83
|
+
expect(checker).to receive(:system).with('cucumber --version &> /dev/null').and_return(true)
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'returns true' do
|
@@ -90,7 +90,7 @@ module Gitnesse
|
|
90
90
|
|
91
91
|
context 'when cucumber is not installed' do
|
92
92
|
before do
|
93
|
-
checker.
|
93
|
+
expect(checker).to receive(:system).with('cucumber --version &> /dev/null').and_return(nil)
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'adds an error' do
|
@@ -169,7 +169,7 @@ module Gitnesse
|
|
169
169
|
describe "#check_features_dir_exists" do
|
170
170
|
context "when features_dir exists" do
|
171
171
|
before do
|
172
|
-
File.
|
172
|
+
expect(File).to receive(:directory?).and_return(true)
|
173
173
|
end
|
174
174
|
|
175
175
|
it "returns true" do
|
@@ -179,7 +179,7 @@ module Gitnesse
|
|
179
179
|
|
180
180
|
context "when features_dir does not exist or is a file" do
|
181
181
|
before do
|
182
|
-
File.
|
182
|
+
expect(File).to receive(:directory?).and_return(false)
|
183
183
|
end
|
184
184
|
|
185
185
|
it "adds an error" do
|
@@ -6,7 +6,7 @@ module Gitnesse
|
|
6
6
|
|
7
7
|
describe ".make_project_dir" do
|
8
8
|
before do
|
9
|
-
FileUtils.
|
9
|
+
expect(FileUtils).to receive(:mkdir_p).with(path).and_return(true)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "creates a dir based on the current project name" do
|
@@ -16,7 +16,7 @@ module Gitnesse
|
|
16
16
|
|
17
17
|
describe ".remove_project_dir" do
|
18
18
|
it "removes the wiki dir for the current project" do
|
19
|
-
FileUtils.
|
19
|
+
expect(FileUtils).to receive(:rm_rf).with(path).and_return(true)
|
20
20
|
DirManager.remove_project_dir
|
21
21
|
end
|
22
22
|
end
|
@@ -24,7 +24,7 @@ module Gitnesse
|
|
24
24
|
describe ".project_dir_present?" do
|
25
25
|
context "if project dir is a directory" do
|
26
26
|
before do
|
27
|
-
File.
|
27
|
+
expect(File).to receive(:directory?).with(path).and_return(true)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns true" do
|
@@ -34,7 +34,7 @@ module Gitnesse
|
|
34
34
|
|
35
35
|
context "if project dir does not exists" do
|
36
36
|
before do
|
37
|
-
File.
|
37
|
+
expect(File).to receive(:directory?).with(path).and_return(false)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "returns false" do
|
data/spec/lib/wiki/page_spec.rb
CHANGED
@@ -19,7 +19,7 @@ module Gitnesse
|
|
19
19
|
|
20
20
|
describe "#read" do
|
21
21
|
it "reads and caches the page's contents" do
|
22
|
-
File.
|
22
|
+
expect(File).to receive(:read).with(page.wiki_path).once.and_return("test")
|
23
23
|
|
24
24
|
expect(page.read).to be_a String
|
25
25
|
expect(page.read).to eq "test"
|
data/spec/support_helper.rb
CHANGED
@@ -1,17 +1,30 @@
|
|
1
1
|
SUPPORT_FILES_DIR = File.join(File.dirname(__FILE__), "/support")
|
2
2
|
|
3
|
-
|
3
|
+
require 'fileutils'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
module CliSpecs
|
8
|
+
def gitnesse(args)
|
9
|
+
out = StringIO.new
|
10
|
+
Gitnesse::Cli.new(out).parse(args.split(/\s+/))
|
11
|
+
|
12
|
+
out.rewind
|
13
|
+
out.read
|
14
|
+
rescue SystemExit
|
15
|
+
out.rewind
|
16
|
+
out.read
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do |c|
|
21
|
+
c.include CliSpecs, type: :cli
|
22
|
+
end
|
4
23
|
|
5
24
|
class Support
|
6
25
|
class << self
|
7
|
-
def example_config_file_path
|
8
|
-
"#{SUPPORT_FILES_DIR}/example_config/gitnesse.rb"
|
9
|
-
end
|
10
|
-
|
11
26
|
def example_config_file
|
12
|
-
|
13
|
-
File.read(example_config_file_path)
|
14
|
-
end
|
27
|
+
"#{SUPPORT_FILES_DIR}/example_config/gitnesse.rb"
|
15
28
|
end
|
16
29
|
|
17
30
|
def addition_feature
|
@@ -57,8 +70,10 @@ class Support
|
|
57
70
|
```gherkin
|
58
71
|
#{division_feature}
|
59
72
|
```
|
73
|
+
- ![](//s3.amazonaws.com/gitnesse/github/passed.png) **Divide two numbers**
|
74
|
+
- - Sep 06, 2013, 10:10 AM
|
60
75
|
|
61
|
-
|
76
|
+
---
|
62
77
|
EOS
|
63
78
|
end
|
64
79
|
|
@@ -77,3 +92,4 @@ class Support
|
|
77
92
|
end
|
78
93
|
end
|
79
94
|
end
|
95
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitnesse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- www.hybridgroup.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -154,7 +154,6 @@ files:
|
|
154
154
|
- spec/lib/wiki/page_spec.rb
|
155
155
|
- spec/lib/wiki_spec.rb
|
156
156
|
- spec/spec_helper.rb
|
157
|
-
- spec/support/cli.rb
|
158
157
|
- spec/support/example_config/gitnesse.rb
|
159
158
|
- spec/support/example_features/addition.feature
|
160
159
|
- spec/support/example_features/division.feature
|
@@ -180,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
179
|
version: '0'
|
181
180
|
requirements: []
|
182
181
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.0.3
|
184
183
|
signing_key:
|
185
184
|
specification_version: 4
|
186
185
|
summary: Sync your feature stories using a Git-based wiki!
|
@@ -209,7 +208,6 @@ test_files:
|
|
209
208
|
- spec/lib/wiki/page_spec.rb
|
210
209
|
- spec/lib/wiki_spec.rb
|
211
210
|
- spec/spec_helper.rb
|
212
|
-
- spec/support/cli.rb
|
213
211
|
- spec/support/example_config/gitnesse.rb
|
214
212
|
- spec/support/example_features/addition.feature
|
215
213
|
- spec/support/example_features/division.feature
|
data/spec/support/cli.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'tempfile'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
module CliSpecs
|
6
|
-
def gitnesse(args)
|
7
|
-
out = StringIO.new
|
8
|
-
Gitnesse::Cli.new(out).parse(args.split(/\s+/))
|
9
|
-
|
10
|
-
out.rewind
|
11
|
-
out.read
|
12
|
-
rescue SystemExit
|
13
|
-
out.rewind
|
14
|
-
out.read
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
RSpec.configure do |c|
|
19
|
-
c.include CliSpecs, type: :cli
|
20
|
-
end
|