gitnesse 0.12.6 → 1.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +6 -0
- data/Rakefile +6 -11
- data/bin/.keep +0 -0
- data/bin/gitnesse +2 -32
- data/config/gitnesse.rb.example +2 -4
- data/gitnesse.gemspec +22 -21
- data/lib/gitnesse/cli/helpers/config_helpers.rb +13 -0
- data/lib/gitnesse/cli/helpers/feature_helpers.rb +26 -0
- data/lib/gitnesse/cli/helpers/wiki_helpers.rb +53 -0
- data/lib/gitnesse/cli/task/help.rb +42 -0
- data/lib/gitnesse/cli/task/info.rb +29 -0
- data/lib/gitnesse/cli/task/pull.rb +26 -0
- data/lib/gitnesse/cli/task/push.rb +101 -0
- data/lib/gitnesse/cli/task/run.rb +85 -0
- data/lib/gitnesse/cli/task.rb +67 -0
- data/lib/gitnesse/cli.rb +55 -0
- data/lib/gitnesse/config.rb +68 -0
- data/lib/gitnesse/config_loader.rb +36 -0
- data/lib/gitnesse/dependency_checker.rb +86 -0
- data/lib/gitnesse/dir_manager.rb +37 -0
- data/lib/gitnesse/feature.rb +63 -0
- data/lib/gitnesse/feature_extractor.rb +29 -0
- data/lib/gitnesse/feature_transform.rb +30 -0
- data/lib/gitnesse/hooks/gitnesse.rb +5 -0
- data/lib/gitnesse/hooks.rb +30 -33
- data/lib/gitnesse/railtie.rb +3 -1
- data/lib/gitnesse/rake/tasks.rake +11 -0
- data/lib/gitnesse/tasks.rb +7 -4
- data/lib/gitnesse/version.rb +1 -1
- data/lib/gitnesse/wiki/page.rb +103 -0
- data/lib/gitnesse/wiki.rb +80 -143
- data/lib/gitnesse.rb +10 -102
- data/spec/lib/cli/task/help_spec.rb +34 -0
- data/spec/lib/cli/task/info_spec.rb +22 -0
- data/spec/lib/cli/task/pull_spec.rb +24 -0
- data/spec/lib/cli/task/push_spec.rb +24 -0
- data/spec/lib/cli_spec.rb +13 -0
- data/spec/lib/config_loader_spec.rb +46 -0
- data/spec/lib/config_spec.rb +61 -0
- data/spec/lib/dependency_checker_spec.rb +193 -0
- data/spec/lib/dir_manager_spec.rb +46 -0
- data/spec/lib/feature_extractor_spec.rb +30 -0
- data/spec/lib/feature_spec.rb +53 -0
- data/spec/lib/feature_transform_spec.rb +25 -0
- data/spec/lib/hooks_spec.rb +40 -0
- data/spec/lib/version_spec.rb +9 -0
- data/spec/lib/wiki/page_spec.rb +68 -0
- data/spec/lib/wiki_spec.rb +34 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/cli.rb +20 -0
- data/spec/support/example_config/gitnesse.rb +4 -0
- data/{test/test_helper.rb → spec/support/example_features/addition.feature} +0 -16
- data/spec/support/example_features/division.feature +10 -0
- data/spec/support/example_wiki_pages/developer_can_sync_features_to_code.md +29 -0
- data/spec/support_helper.rb +79 -0
- metadata +103 -109
- data/README.md +0 -85
- data/features/step_definitions/gitnesse_steps.rb +0 -54
- data/features/support/env.rb +0 -65
- data/features/sync_wiki_features_to_code.feature +0 -29
- data/lib/gitnesse/configuration.rb +0 -54
- data/lib/gitnesse/dependencies.rb +0 -39
- data/lib/gitnesse/features.rb +0 -38
- data/lib/gitnesse/git_config.rb +0 -39
- data/lib/gitnesse/support/hook.rb +0 -11
- data/lib/gitnesse/tasks.rake +0 -34
- data/test/lib/gitnesse/build_page_content_test.rb +0 -89
- data/test/lib/gitnesse/commit_info_test.rb +0 -16
- data/test/lib/gitnesse/configuration_defaults_test.rb +0 -11
- data/test/lib/gitnesse/configuration_to_hash_test.rb +0 -25
- data/test/lib/gitnesse/custom_branch_test.rb +0 -24
- data/test/lib/gitnesse/dependencies_check_test.rb +0 -73
- data/test/lib/gitnesse/extract_features_test.rb +0 -44
- data/test/lib/gitnesse/gather_test.rb +0 -30
- data/test/lib/gitnesse/load_feature_files_into_wiki_test.rb +0 -34
- data/test/lib/gitnesse/read_git_config_test.rb +0 -33
- data/test/lib/gitnesse/strip_results_test.rb +0 -52
- data/test/lib/gitnesse/version_test.rb +0 -7
- data/test/lib/gitnesse/wiki_append_results_test.rb +0 -50
- data/test/lib/gitnesse/write_file_test.rb +0 -18
- data/test/wiki_test_helper.rb +0 -11
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe DependencyChecker do
|
5
|
+
let(:checker) { DependencyChecker.new }
|
6
|
+
let(:config) { Config.instance }
|
7
|
+
|
8
|
+
describe "#check" do
|
9
|
+
it "calls other dependency checks" do
|
10
|
+
checks = %w(check_git check_cucumber check_repository_url
|
11
|
+
check_identifier check_features_dir_exists)
|
12
|
+
checks.each do |check|
|
13
|
+
checker.should_receive(check.to_sym).and_return(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
checker.check
|
17
|
+
end
|
18
|
+
|
19
|
+
it "calls display_errors if there are any errors" do
|
20
|
+
checks = %w(check_cucumber check_repository_url check_identifier
|
21
|
+
check_features_dir_exists)
|
22
|
+
|
23
|
+
checks.each do |check|
|
24
|
+
checker.should_receive(check.to_sym).and_return(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
checker.should_receive(:system).with('git --version &> /dev/null').and_return(nil)
|
28
|
+
checker.should_receive(:display_errors)
|
29
|
+
|
30
|
+
checker.check
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#display_errors" do
|
35
|
+
before do
|
36
|
+
checker.instance_variable_set(:@errors, ["this is an example error"])
|
37
|
+
|
38
|
+
checker.should_receive(:puts).with("Configuration errors were found!")
|
39
|
+
checker.should_receive(:puts).with(" - this is an example error")
|
40
|
+
checker.should_receive(:exit)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "prints a note saying errors were found" do
|
44
|
+
checker.display_errors
|
45
|
+
end
|
46
|
+
|
47
|
+
it "displays every error in @errors" do
|
48
|
+
checker.display_errors
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should exit" do
|
52
|
+
checker.display_errors
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#check_git' do
|
57
|
+
context 'when git is installed' do
|
58
|
+
before do
|
59
|
+
checker.should_receive(:system).with('git --version &> /dev/null').and_return(true)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns true' do
|
63
|
+
expect(checker.check_git).to be_true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when git is not installed' do
|
68
|
+
before do
|
69
|
+
checker.should_receive(:system).with('git --version &> /dev/null').and_return(nil)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'adds an error' do
|
73
|
+
expect {
|
74
|
+
checker.check_git
|
75
|
+
}.to change{checker.errors.length}.from(0).to(1)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#check_cucumber' do
|
81
|
+
context 'when cucumber is installed' do
|
82
|
+
before do
|
83
|
+
checker.should_receive(:system).with('cucumber --version &> /dev/null').and_return(true)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'returns true' do
|
87
|
+
expect(checker.check_cucumber).to be_true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when cucumber is not installed' do
|
92
|
+
before do
|
93
|
+
checker.should_receive(:system).with('cucumber --version &> /dev/null').and_return(nil)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'adds an error' do
|
97
|
+
expect {
|
98
|
+
checker.check_cucumber
|
99
|
+
}.to change{checker.errors.length}.from(0).to(1)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#check_repository_url" do
|
105
|
+
context "when repository_url is set" do
|
106
|
+
before do
|
107
|
+
config.repository_url = "git@github.com:hybridgroup/gitnesse.wiki.git"
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns true" do
|
111
|
+
expect(checker.check_repository_url).to be_true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when repository_url is not set" do
|
116
|
+
before do
|
117
|
+
config.repository_url = nil
|
118
|
+
end
|
119
|
+
|
120
|
+
it "adds an error" do
|
121
|
+
expect {
|
122
|
+
checker.check_repository_url
|
123
|
+
}.to change{checker.errors.length}.from(0).to(1)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
describe "#check_identifier" do
|
130
|
+
context "when annotate_results is true" do
|
131
|
+
before do
|
132
|
+
config.annotate_results = true
|
133
|
+
end
|
134
|
+
|
135
|
+
context "when identifier is set" do
|
136
|
+
before do
|
137
|
+
config.identifier = "Uncle Bob's Macbook Pro"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "returns true" do
|
141
|
+
expect(checker.check_identifier).to be_true
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "when identifier is not set" do
|
146
|
+
before do
|
147
|
+
config.identifier = nil
|
148
|
+
end
|
149
|
+
|
150
|
+
it "adds an error" do
|
151
|
+
expect {
|
152
|
+
checker.check_identifier
|
153
|
+
}.to change{checker.errors.length}.from(0).to(1)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "when annotate_results is false" do
|
159
|
+
before do
|
160
|
+
config.annotate_results = false
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns true" do
|
164
|
+
expect(checker.check_identifier).to be_true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "#check_features_dir_exists" do
|
170
|
+
context "when features_dir exists" do
|
171
|
+
before do
|
172
|
+
File.should_receive(:directory?).and_return(true)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "returns true" do
|
176
|
+
expect(checker.check_features_dir_exists).to be_true
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
context "when features_dir does not exist or is a file" do
|
181
|
+
before do
|
182
|
+
File.should_receive(:directory?).and_return(false)
|
183
|
+
end
|
184
|
+
|
185
|
+
it "adds an error" do
|
186
|
+
expect {
|
187
|
+
checker.check_features_dir_exists
|
188
|
+
}.to change{checker.errors.length}.from(0).to(1)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe DirManager do
|
5
|
+
let(:path) { "#{Dir.home}/.gitnesse/gitnesse" }
|
6
|
+
|
7
|
+
describe ".make_project_dir" do
|
8
|
+
before do
|
9
|
+
FileUtils.should_receive(:mkdir_p).with(path).and_return(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "creates a dir based on the current project name" do
|
13
|
+
expect(DirManager.make_project_dir).to eq path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".remove_project_dir" do
|
18
|
+
it "removes the wiki dir for the current project" do
|
19
|
+
FileUtils.should_receive(:rm_rf).with(path).and_return(true)
|
20
|
+
DirManager.remove_project_dir
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".project_dir_present?" do
|
25
|
+
context "if project dir is a directory" do
|
26
|
+
before do
|
27
|
+
File.should_receive(:directory?).with(path).and_return(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns true" do
|
31
|
+
expect(DirManager.project_dir_present?).to be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "if project dir does not exists" do
|
36
|
+
before do
|
37
|
+
File.should_receive(:directory?).with(path).and_return(false)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns false" do
|
41
|
+
expect(DirManager.project_dir_present?).to be_false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe FeatureExtractor do
|
5
|
+
let(:example_page) { Support.example_wiki_page }
|
6
|
+
let(:expected_features) { Support.example_features }
|
7
|
+
|
8
|
+
describe ".extract!" do
|
9
|
+
it "extracts Cucumber features from Markdown wiki pages as an array" do
|
10
|
+
extracted_page = FeatureExtractor.extract!(example_page)
|
11
|
+
expect(extracted_page).to eq expected_features
|
12
|
+
expect(extracted_page).to be_an Array
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns an empty array if no examples were found" do
|
16
|
+
expect(FeatureExtractor.extract!("")).to eq []
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".contains_features?" do
|
21
|
+
it "returns true if the page contains features" do
|
22
|
+
expect(FeatureExtractor.contains_features?(example_page)).to be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns false if no features were found" do
|
26
|
+
expect(FeatureExtractor.contains_features?("")).to be_false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe Feature do
|
5
|
+
let(:feature) { Feature.new "thing.feature" }
|
6
|
+
let(:nested_feature) { Feature.new "nested_features/thing.feature" }
|
7
|
+
|
8
|
+
it "accepts a filename as an argument" do
|
9
|
+
expect(feature.filename).to eq "thing.feature"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can generate a wiki filename" do
|
13
|
+
expect(feature.wiki_filename).to eq "features > thing.feature.md"
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#wiki_filename" do
|
17
|
+
it "generates wiki filenames for nested features" do
|
18
|
+
expect(nested_feature.wiki_filename).to eq "features > nested_features > thing.feature.md"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#read" do
|
23
|
+
before do
|
24
|
+
expect(File).to receive(:read).once.with("features/thing.feature").and_return('')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "reads and caches the content of the file" do
|
28
|
+
expect(feature.read).to be_a String
|
29
|
+
expect(feature.read).to eq ''
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#write" do
|
34
|
+
before do
|
35
|
+
@stringio = StringIO.new
|
36
|
+
expect(File).to receive(:open).with("features/thing.feature", "w").and_yield(@stringio)
|
37
|
+
allow(File).to receive(:read).with("features/thing.feature").and_return(@stringio.string)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "writes content to the file" do
|
41
|
+
feature.write('testing')
|
42
|
+
expect(feature.read).to eq "testing"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#index_page" do
|
47
|
+
it "generates the path to the index page the feature will appear on" do
|
48
|
+
expect(feature.index_page).to eq "features.md"
|
49
|
+
expect(nested_feature.index_page).to eq "features > nested_features.md"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe FeatureTransform do
|
5
|
+
describe ".convert" do
|
6
|
+
context "when a feature is passed" do
|
7
|
+
it "converts a Cucumber feature to a Markdown wiki page" do
|
8
|
+
wiki_page = FeatureTransform.convert(Support.addition_feature)
|
9
|
+
expect(wiki_page).to eq Support.wiki_addition_feature
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when a non-feature string is passed" do
|
14
|
+
it "returns a 'undefined feature' page" do
|
15
|
+
result = <<-EOS.chomp
|
16
|
+
# Undefined Feature
|
17
|
+
|
18
|
+
This feature hasn't been added yet.
|
19
|
+
EOS
|
20
|
+
expect(FeatureTransform.convert('')).to eq result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe Hooks do
|
5
|
+
let(:hook) { File.expand_path("#{File.dirname(__FILE__)}/../../lib/gitnesse/hooks/gitnesse.rb") }
|
6
|
+
let(:path) { Hooks::PATH }
|
7
|
+
let(:dir) { Hooks::DIR }
|
8
|
+
|
9
|
+
it "sets DIR to the 'support' cucumber dir" do
|
10
|
+
expect(dir).to match "features/support"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "sets PATH to the filename for the Cucumber hook" do
|
14
|
+
expect(path).to match "features/support/gitnesse.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".create!" do
|
18
|
+
before do
|
19
|
+
expect(FileUtils).to receive(:cp).with(hook, path)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "copies the hooks to the support dir" do
|
23
|
+
Hooks.create!
|
24
|
+
end
|
25
|
+
|
26
|
+
it "creates the support dir if it doesn't exist" do
|
27
|
+
expect(File).to receive(:directory?).with(dir).and_return(false)
|
28
|
+
expect(FileUtils).to receive(:mkdir_p).with(dir).and_return(nil)
|
29
|
+
Hooks.create!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".destroy!" do
|
34
|
+
it "removes the Gitnesse hooks from the Cucumber support dir" do
|
35
|
+
expect(FileUtils).to receive(:rm).with(path, force: true).and_return(nil)
|
36
|
+
Hooks.destroy!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module Gitnesse
|
5
|
+
describe Wiki::Page do
|
6
|
+
let(:page) { Wiki::Page.new("~/.gitnesse/gitnesse/features > new_features > new_feature.feature.md") }
|
7
|
+
|
8
|
+
it "converts the filename to a local path" do
|
9
|
+
expect(page.relative_path).to eq "./features/new_features"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "extracts the feature filename" do
|
13
|
+
expect(page.filename).to eq "new_feature.feature"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "constructs the full local file path" do
|
17
|
+
expect(page.path).to eq "./features/new_features/new_feature.feature"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#read" do
|
21
|
+
it "reads and caches the page's contents" do
|
22
|
+
File.should_receive(:read).with(page.wiki_path).once.and_return("test")
|
23
|
+
|
24
|
+
expect(page.read).to be_a String
|
25
|
+
expect(page.read).to eq "test"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#write" do
|
30
|
+
before do
|
31
|
+
@stringio = StringIO.new
|
32
|
+
expect(File).to receive(:open).with(page.wiki_path, 'w+').and_yield(@stringio)
|
33
|
+
allow(File).to receive(:read).with(page.wiki_path).and_return(@stringio.string)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "writes content to the file" do
|
37
|
+
page.write('testing')
|
38
|
+
expect(page.read).to eq "testing"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#remove_results" do
|
43
|
+
before do
|
44
|
+
@stringio = StringIO.new(Support.wiki_feature_with_annotations)
|
45
|
+
expect(File).to receive(:read).with(page.wiki_path).and_return(@stringio.string)
|
46
|
+
allow(File).to receive(:open).with(page.wiki_path, 'w+').and_yield(@stringio)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "removes all existing scenario results from the wiki page" do
|
50
|
+
expect(page.remove_results).to eq Support.wiki_feature_without_annotations
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#append_result" do
|
55
|
+
before do
|
56
|
+
@stringio = StringIO.new(Support.wiki_feature_without_annotations)
|
57
|
+
allow(File).to receive(:read).with(page.wiki_path).and_return(@stringio.string)
|
58
|
+
allow(File).to receive(:open).with(page.wiki_path, 'w+').and_yield(@stringio)
|
59
|
+
allow(Time).to receive(:now).and_return(Time.parse("Sep 06 2013 10:10"))
|
60
|
+
end
|
61
|
+
|
62
|
+
it "appends scenario results to the wiki page" do
|
63
|
+
page.append_result('Divide two numbers', :passed)
|
64
|
+
expect(page.read).to eq Support.wiki_feature_with_annotations
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe Wiki do
|
5
|
+
describe "#remove_features" do
|
6
|
+
before do
|
7
|
+
Wiki.any_instance.stub(:clone_or_update_repo).and_return(true)
|
8
|
+
|
9
|
+
@repo = double('repo', status: [])
|
10
|
+
expect(Git).to receive(:init).with("~/.gitnesse/gitnesse").and_return(@repo)
|
11
|
+
|
12
|
+
@wiki = Wiki.new "", "~/.gitnesse/gitnesse"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "removes gitnesse-created files from the wiki" do
|
16
|
+
files = [
|
17
|
+
double(path: "Home.md"),
|
18
|
+
double(path: "features.md"),
|
19
|
+
double(path: "features > test.md"),
|
20
|
+
double(path: "features > test > thing.feature.md")
|
21
|
+
]
|
22
|
+
|
23
|
+
allow(@repo).to receive(:status).and_return(files)
|
24
|
+
|
25
|
+
expect(@repo).to_not receive(:remove).with("Home.md")
|
26
|
+
expect(@repo).to receive(:remove).with("features.md")
|
27
|
+
expect(@repo).to receive(:remove).with("features > test.md")
|
28
|
+
expect(@repo).to receive(:remove).with("features > test > thing.feature.md")
|
29
|
+
|
30
|
+
@wiki.remove_features
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/support/cli.rb
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
@@ -1,16 +1,3 @@
|
|
1
|
-
require "minitest/matchers"
|
2
|
-
require "minitest/autorun"
|
3
|
-
require "minitest/pride"
|
4
|
-
require "mocha"
|
5
|
-
require File.expand_path('../../lib/gitnesse.rb', __FILE__)
|
6
|
-
|
7
|
-
module FeatureTestMethods
|
8
|
-
|
9
|
-
# Creates a basic test feature
|
10
|
-
#
|
11
|
-
# Returns a string
|
12
|
-
def create_test_feature
|
13
|
-
<<-EOF
|
14
1
|
Feature: Addition
|
15
2
|
In order to avoid silly mistakes
|
16
3
|
As a math idiot
|
@@ -21,6 +8,3 @@ Feature: Addition
|
|
21
8
|
And I have entered 70 into the calculator
|
22
9
|
When I press add
|
23
10
|
Then the result should be 120 on the screen
|
24
|
-
EOF
|
25
|
-
end
|
26
|
-
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: Division
|
2
|
+
In order to avoid silly mistakes
|
3
|
+
As a math idiot
|
4
|
+
I want to be told the quotient of two numbers
|
5
|
+
|
6
|
+
Scenario: Divide two numbers
|
7
|
+
Given I have entered 6 into the calculator
|
8
|
+
And I have entered 2 into the calculator
|
9
|
+
When I divide
|
10
|
+
Then the result should be 3
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Developer Can Sync Features To Code
|
2
|
+
|
3
|
+
```Gherkin
|
4
|
+
Feature: Addition
|
5
|
+
In order to avoid silly mistakes
|
6
|
+
As a math idiot
|
7
|
+
I want to be told the sum of two numbers
|
8
|
+
|
9
|
+
Scenario: Add two numbers
|
10
|
+
Given I have entered 50 into the calculator
|
11
|
+
And I have entered 70 into the calculator
|
12
|
+
When I press add
|
13
|
+
Then the result should be 120 on the screen
|
14
|
+
```
|
15
|
+
|
16
|
+
```gherkin
|
17
|
+
Feature: Division
|
18
|
+
In order to avoid silly mistakes
|
19
|
+
As a math idiot
|
20
|
+
I want to be told the quotient of two numbers
|
21
|
+
|
22
|
+
Scenario: Divide two numbers
|
23
|
+
Given I have entered 6 into the calculator
|
24
|
+
And I have entered 2 into the calculator
|
25
|
+
When I divide
|
26
|
+
Then the result should be 3
|
27
|
+
```
|
28
|
+
|
29
|
+
 `Last result was PASSED: Features already exist in wiki but not in code (2013-01-01 00:00:00 -0800 - Developer Computer)`
|
@@ -0,0 +1,79 @@
|
|
1
|
+
SUPPORT_FILES_DIR = File.join(File.dirname(__FILE__), "/support")
|
2
|
+
|
3
|
+
Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each { |f| require(f) }
|
4
|
+
|
5
|
+
class Support
|
6
|
+
class << self
|
7
|
+
def example_config_file_path
|
8
|
+
"#{SUPPORT_FILES_DIR}/example_config/gitnesse.rb"
|
9
|
+
end
|
10
|
+
|
11
|
+
def example_config_file
|
12
|
+
@example_config ||= begin
|
13
|
+
File.read(example_config_file_path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def addition_feature
|
18
|
+
@addition ||= begin
|
19
|
+
File.read("#{SUPPORT_FILES_DIR}/example_features/addition.feature")
|
20
|
+
end.lstrip.chomp
|
21
|
+
end
|
22
|
+
|
23
|
+
def wiki_addition_feature
|
24
|
+
<<-EOS.chomp
|
25
|
+
# Addition
|
26
|
+
|
27
|
+
```gherkin
|
28
|
+
#{addition_feature}
|
29
|
+
```
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
|
33
|
+
def division_feature
|
34
|
+
@division ||= begin
|
35
|
+
File.read "#{SUPPORT_FILES_DIR}/example_features/division.feature"
|
36
|
+
end.lstrip.chomp
|
37
|
+
end
|
38
|
+
|
39
|
+
def wiki_division_feature
|
40
|
+
<<-EOS.chomp
|
41
|
+
# Division
|
42
|
+
|
43
|
+
```gherkin
|
44
|
+
#{division_feature}
|
45
|
+
```
|
46
|
+
EOS
|
47
|
+
end
|
48
|
+
|
49
|
+
def wiki_feature_without_annotations
|
50
|
+
wiki_division_feature
|
51
|
+
end
|
52
|
+
|
53
|
+
def wiki_feature_with_annotations
|
54
|
+
<<-EOS.chomp
|
55
|
+
# Division
|
56
|
+
|
57
|
+
```gherkin
|
58
|
+
#{division_feature}
|
59
|
+
```
|
60
|
+
|
61
|
+
 `Last Result For Scenario 'Divide two numbers': PASSED (Sep 06, 2013, 10:10 AM - )`
|
62
|
+
EOS
|
63
|
+
end
|
64
|
+
|
65
|
+
def example_features
|
66
|
+
[addition_feature, division_feature]
|
67
|
+
end
|
68
|
+
|
69
|
+
def example_wiki_page
|
70
|
+
@example_wiki ||= begin
|
71
|
+
File.read "#{SUPPORT_FILES_DIR}/example_wiki_pages/developer_can_sync_features_to_code.md"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def example_wiki_page_features
|
76
|
+
[addition_feature, division_feature]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|