cukehead 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +55 -0
- data/Rakefile +101 -0
- data/bin/cukehead +7 -0
- data/lib/cukehead.rb +1 -0
- data/lib/cukehead/app.rb +241 -0
- data/lib/cukehead/feature_file_section.rb +73 -0
- data/lib/cukehead/feature_node.rb +111 -0
- data/lib/cukehead/feature_node_child.rb +58 -0
- data/lib/cukehead/feature_node_tags.rb +41 -0
- data/lib/cukehead/feature_part.rb +25 -0
- data/lib/cukehead/feature_reader.rb +78 -0
- data/lib/cukehead/feature_writer.rb +42 -0
- data/lib/cukehead/freemind_builder.rb +184 -0
- data/lib/cukehead/freemind_reader.rb +69 -0
- data/lib/cukehead/freemind_writer.rb +21 -0
- data/spec/app_spec.rb +275 -0
- data/spec/cukehead_spec.rb +104 -0
- data/spec/feature_file_section_spec.rb +93 -0
- data/spec/feature_node_spec.rb +115 -0
- data/spec/feature_part_spec.rb +37 -0
- data/spec/feature_reader_spec.rb +33 -0
- data/spec/feature_writer_spec.rb +73 -0
- data/spec/freemind_builder_spec.rb +91 -0
- data/spec/freemind_reader_spec.rb +62 -0
- data/spec/freemind_writer_spec.rb +25 -0
- data/spec/spec_helper.rb +88 -0
- metadata +93 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require 'cukehead/freemind_reader'
|
3
|
+
|
4
|
+
module Cukehead
|
5
|
+
|
6
|
+
describe "FreemindReader" do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@test_filename = File.join $testing_tmp, 'freemind_reader_test_input.mm'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "takes a file name when initializing and loads it as an XML document" do
|
13
|
+
File.open(@test_filename, 'w') {|f| f.write($testing_freemind_data)}
|
14
|
+
File.exists?(@test_filename).should be_true
|
15
|
+
@reader = FreemindReader.new(@test_filename)
|
16
|
+
@reader.should_not be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can find a node containing Cucumber features in the XML document" do
|
20
|
+
File.open(@test_filename, 'w') {|f| f.write($testing_freemind_data)}
|
21
|
+
File.exists?(@test_filename).should be_true
|
22
|
+
@reader = FreemindReader.new(@test_filename)
|
23
|
+
@reader.cucumber_features_node.should_not be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "extracts features as text from the XML document as a hash {filename => text}" do
|
27
|
+
File.open(@test_filename, 'w') {|f| f.write($testing_freemind_data)}
|
28
|
+
File.exists?(@test_filename).should be_true
|
29
|
+
@reader = FreemindReader.new(@test_filename)
|
30
|
+
result = @reader.get_features
|
31
|
+
result.should be_a Hash
|
32
|
+
result.should have(1).feature
|
33
|
+
filename, text = result.shift
|
34
|
+
filename.should eql 'manage_website.feature'
|
35
|
+
text.should match /^Feature: Manage websites.*/m
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns an empty hash if there are no Cucumber features nodes in the XML document" do
|
39
|
+
File.open(@test_filename, 'w') {|f| f.write($testing_freemind_data_nocukes)}
|
40
|
+
File.exists?(@test_filename).should be_true
|
41
|
+
@reader = FreemindReader.new(@test_filename)
|
42
|
+
result = @reader.get_features
|
43
|
+
result.should be_a Hash
|
44
|
+
result.should have(0).items
|
45
|
+
end
|
46
|
+
|
47
|
+
it "ignores case when finding a cucumber features node in the mind map." do
|
48
|
+
xml = <<xxx
|
49
|
+
<map>
|
50
|
+
<node TEXT='Cucumber Features:'>
|
51
|
+
<node TEXT='Feature: Do nothing' />
|
52
|
+
</node>
|
53
|
+
</map>
|
54
|
+
xxx
|
55
|
+
@reader = FreemindReader.new
|
56
|
+
@reader.load_xml xml
|
57
|
+
@reader.cucumber_features_node.should_not be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require 'cukehead/freemind_writer'
|
3
|
+
|
4
|
+
module Cukehead
|
5
|
+
|
6
|
+
describe "FreemindWriter" do
|
7
|
+
|
8
|
+
it "should add newlines after tags because that's what FreeMind does" do
|
9
|
+
writer = FreemindWriter.new
|
10
|
+
x = writer.add_newline_after_tags("<fake TEXT='XML'><node TEXT='fake'/></fake>")
|
11
|
+
x.should eql "<fake TEXT='XML'>\n<node TEXT='fake'/>\n</fake>\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should take XML generated by FreemindBuilder and write it to a file" do
|
15
|
+
builder = FreemindBuilder.new
|
16
|
+
writer = FreemindWriter.new
|
17
|
+
filename = File.join($testing_tmp, 'test.mm')
|
18
|
+
File.delete(filename) if File.exist? filename
|
19
|
+
writer.write_mm(filename, builder.xml)
|
20
|
+
File.exist?(filename).should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
$TESTING=true
|
2
|
+
|
3
|
+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
$testing_tmp = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))
|
6
|
+
|
7
|
+
$cukehead_bin = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'cukehead'))
|
8
|
+
|
9
|
+
# Fake FreeMind data with one feature with background and two scenarios.
|
10
|
+
$testing_freemind_data = <<xxx
|
11
|
+
<map>
|
12
|
+
<node TEXT='Cucumber features:'>
|
13
|
+
<node TEXT='Feature: Manage websites'>
|
14
|
+
<node TEXT='[file: manage_website.feature]'/>
|
15
|
+
<node TEXT='In order to manage a website'></node>
|
16
|
+
<node TEXT='I want to create and manage a website'></node>
|
17
|
+
<node TEXT='Background:'>
|
18
|
+
<node TEXT='Given I am the registered user Lime Neeson'></node>
|
19
|
+
<node TEXT='And I am on login'></node>
|
20
|
+
<node TEXT='When I login with valid credentials'></node>
|
21
|
+
<node TEXT='Then I should see "My sites"'></node>
|
22
|
+
</node>
|
23
|
+
<node TEXT='Scenario: Sites List'>
|
24
|
+
<node TEXT='When I go to my sites'></node>
|
25
|
+
<node TEXT='Then I should see "My First Site"'></node>
|
26
|
+
<node TEXT='And I should see "My Second Site;'></node>
|
27
|
+
</node>
|
28
|
+
<node TEXT='Scenario: Creating a new site'>
|
29
|
+
<node TEXT='When I go to my sites'></node>
|
30
|
+
<node TEXT='Then I should see "New site"'></node>
|
31
|
+
</node>
|
32
|
+
</node>
|
33
|
+
</node>
|
34
|
+
</map>
|
35
|
+
xxx
|
36
|
+
|
37
|
+
# Fake FreeMind data with two features.
|
38
|
+
$testing_freemind_data_2 = <<xxx
|
39
|
+
<map>
|
40
|
+
<node TEXT='Cucumber features:'>
|
41
|
+
<node TEXT='Feature: First feature'>
|
42
|
+
<node TEXT='In order to test cukehead'></node>
|
43
|
+
<node TEXT='I want some fake data'></node>
|
44
|
+
<node TEXT='Scenario: A scenario'>
|
45
|
+
<node TEXT='When I ask for a scenario'></node>
|
46
|
+
<node TEXT='Then I should get this one'></node>
|
47
|
+
</node>
|
48
|
+
</node>
|
49
|
+
<node TEXT='Feature: Second feature'>
|
50
|
+
<node TEXT='In order to further test cukehead'></node>
|
51
|
+
<node TEXT='I want to some more fake data'></node>
|
52
|
+
<node TEXT='Scenario: Fishing'>
|
53
|
+
<node TEXT='When we go fishing'></node>
|
54
|
+
<node TEXT='Then you should bring a line'></node>
|
55
|
+
<node TEXT='And I should bring a pole'></node>
|
56
|
+
</node>
|
57
|
+
</node>
|
58
|
+
</node>
|
59
|
+
</map>
|
60
|
+
xxx
|
61
|
+
|
62
|
+
# Fake FreeMind data with no Cucumber features node.
|
63
|
+
$testing_freemind_data_nocukes = <<xxx
|
64
|
+
<map>
|
65
|
+
<node TEXT='Yes I have no cukes.'>
|
66
|
+
<node TEXT='I have no cukes today'/>
|
67
|
+
</node>
|
68
|
+
</map>
|
69
|
+
xxx
|
70
|
+
|
71
|
+
class FakeFreemindBuilder
|
72
|
+
def add_feature(part, filename)
|
73
|
+
@part = part
|
74
|
+
@filename = filename
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_background(part)
|
78
|
+
@part = part
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_scenario(part)
|
82
|
+
@part = part
|
83
|
+
end
|
84
|
+
|
85
|
+
def lines
|
86
|
+
@part.lines
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cukehead
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Bill Melvin
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-02 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A gem that creates a FreeMind mind map from Cucumber feature files and vice versa.
|
23
|
+
email: bill@bogusoft.com
|
24
|
+
executables:
|
25
|
+
- cukehead
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README
|
30
|
+
files:
|
31
|
+
- LICENSE
|
32
|
+
- README
|
33
|
+
- Rakefile
|
34
|
+
- bin/cukehead
|
35
|
+
- lib/cukehead.rb
|
36
|
+
- lib/cukehead/app.rb
|
37
|
+
- lib/cukehead/feature_file_section.rb
|
38
|
+
- lib/cukehead/feature_node.rb
|
39
|
+
- lib/cukehead/feature_node_child.rb
|
40
|
+
- lib/cukehead/feature_node_tags.rb
|
41
|
+
- lib/cukehead/feature_part.rb
|
42
|
+
- lib/cukehead/feature_reader.rb
|
43
|
+
- lib/cukehead/feature_writer.rb
|
44
|
+
- lib/cukehead/freemind_builder.rb
|
45
|
+
- lib/cukehead/freemind_reader.rb
|
46
|
+
- lib/cukehead/freemind_writer.rb
|
47
|
+
- spec/app_spec.rb
|
48
|
+
- spec/cukehead_spec.rb
|
49
|
+
- spec/feature_file_section_spec.rb
|
50
|
+
- spec/feature_node_spec.rb
|
51
|
+
- spec/feature_part_spec.rb
|
52
|
+
- spec/feature_reader_spec.rb
|
53
|
+
- spec/feature_writer_spec.rb
|
54
|
+
- spec/freemind_builder_spec.rb
|
55
|
+
- spec/freemind_reader_spec.rb
|
56
|
+
- spec/freemind_writer_spec.rb
|
57
|
+
- spec/spec_helper.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://www.bogusoft.com/cukehead/
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.3.7
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: A gem that creates a FreeMind mind map from Cucumber feature files and vice versa.
|
92
|
+
test_files: []
|
93
|
+
|