cukable 0.1.1

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.
data/spec/cuke_spec.rb ADDED
@@ -0,0 +1,134 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'tmpdir'
4
+
5
+ describe Cukable::Cuke do
6
+ before(:each) do
7
+ @cuke = Cukable::Cuke.new
8
+ @feature = File.join(Dir.tmpdir, 'cuke_spec.feature')
9
+ end
10
+
11
+ after(:each) do
12
+ File.delete(@feature) if File.exists?(@feature)
13
+ end
14
+
15
+
16
+ context '#do_table' do
17
+ end # do_table
18
+
19
+
20
+ context '#write_feature' do
21
+ context "raises a FormatError" do
22
+ it "for empty tables" do
23
+ table = []
24
+ lambda do
25
+ @cuke.write_feature(table, @feature)
26
+ end.should raise_error(Cukable::FormatError)
27
+ end
28
+
29
+ it "when table has no Feature" do
30
+ table = [
31
+ ['Scenario: No feature'],
32
+ ]
33
+ lambda do
34
+ @cuke.write_feature(table, @feature)
35
+ end.should raise_error(Cukable::FormatError)
36
+ end
37
+
38
+ it "when table has too many Features" do
39
+ table = [
40
+ ['Feature: Too many features'],
41
+ ['Feature: There can be only one'],
42
+ ['Scenario: Too many features'],
43
+ ]
44
+ lambda do
45
+ @cuke.write_feature(table, @feature)
46
+ end.should raise_error(Cukable::FormatError)
47
+ end
48
+
49
+ it "when table has no Scenario" do
50
+ table = [
51
+ ['Feature: No scenario'],
52
+ ]
53
+ lambda do
54
+ @cuke.write_feature(table, @feature)
55
+ end.should raise_error(Cukable::FormatError)
56
+ end
57
+ end # FormatError
58
+
59
+ it "writes embedded tables correctly" do
60
+ table = [
61
+ ['Feature: Table'],
62
+ ['Scenario: Table'],
63
+ ['Given a table:'],
64
+ ['', 'foo', 'bar'],
65
+ ['', 'boo', 'far'],
66
+ ]
67
+ feature_text = [
68
+ ['Feature: Table'],
69
+ ['Scenario: Table'],
70
+ ['Given a table:'],
71
+ [' | foo | bar |'],
72
+ [' | boo | far |'],
73
+ ].join("\n")
74
+ @cuke.write_feature(table, @feature)
75
+ File.read(@feature).strip.should == feature_text
76
+ end
77
+
78
+ it "unescapes < and >" do
79
+ table = [
80
+ ['Feature: Brackets'],
81
+ ['Scenario Outline: Brackets'],
82
+ ['Given <thing>'],
83
+ ['Examples:'],
84
+ ['', 'thing'],
85
+ ['', 'spaceship'],
86
+ ['', 'time machine'],
87
+ ]
88
+ feature_text = [
89
+ ['Feature: Brackets'],
90
+ ['Scenario Outline: Brackets'],
91
+ ['Given <thing>'],
92
+ ['Examples:'],
93
+ [' | thing |'],
94
+ [' | spaceship |'],
95
+ [' | time machine |'],
96
+ ].join("\n")
97
+ @cuke.write_feature(table, @feature)
98
+ File.read(@feature).strip.should == feature_text
99
+ end
100
+
101
+ end # write_feature
102
+
103
+
104
+ context "#merge_table_with_results" do
105
+ it "marks missing lines as ignored" do
106
+ input_table = [
107
+ ['Feature: Merge'],
108
+ ['Scenario: Skip'],
109
+ ['Given a scenario is skipped'],
110
+ ['Scenario: Run'],
111
+ ['Given a scenario is run'],
112
+ ['Scenario: Skip again'],
113
+ ['Given a scenario is skipped'],
114
+ ]
115
+ json_results = [
116
+ ['report:Feature: Merge'],
117
+ ['report:Scenario: Run'],
118
+ ['pass:Given a <b>scenario</b> is run'],
119
+ ]
120
+ expected_results = [
121
+ ['report:Feature: Merge'],
122
+ ['ignore:Scenario: Skip'],
123
+ ['ignore:Given a scenario is skipped'],
124
+ ['report:Scenario: Run'],
125
+ ['pass:Given a <b>scenario</b> is run'],
126
+ ['ignore:Scenario: Skip again'],
127
+ ['ignore:Given a scenario is skipped'],
128
+ ]
129
+ actual_results = @cuke.merge_table_with_results(input_table, json_results)
130
+ actual_results.should == expected_results
131
+ end
132
+ end # merge_table_with_results
133
+
134
+ end
@@ -0,0 +1,203 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Cukable::Helper do
4
+
5
+ context "#literalize" do
6
+ it "escapes CamelCase words" do
7
+ literalize("E2E").should == "!-E2E-!"
8
+ literalize("BoB").should == "!-BoB-!"
9
+ literalize("CamelCase").should == "!-CamelCase-!"
10
+ literalize("Has a CamelCase word").should == "Has a !-CamelCase-! word"
11
+ literalize("CamelCase at start").should == "!-CamelCase-! at start"
12
+ literalize("ending with CamelCase").should == "ending with !-CamelCase-!"
13
+ end
14
+
15
+ it "escapes email addresses" do
16
+ literalize("epierce@foo-bar.com").should == "!-epierce@foo-bar.com-!"
17
+ literalize("Email epierce@foo-bar.com").should == "Email !-epierce@foo-bar.com-!"
18
+ literalize("epierce@foo-bar.com is my email").should == "!-epierce@foo-bar.com-! is my email"
19
+ literalize("Email epierce@foo-bar.com again").should == "Email !-epierce@foo-bar.com-! again"
20
+ end
21
+
22
+ it "escapes URLs" do
23
+ literalize("http://my.site/").should == "!-http://my.site/-!"
24
+ literalize("Go to http://my.site/").should == "Go to !-http://my.site/-!"
25
+ literalize("http://my.site/ is my site").should == "!-http://my.site/-! is my site"
26
+ literalize("My site http://my.site/ is cool").should == "My site !-http://my.site/-! is cool"
27
+ end
28
+ end # literalize
29
+
30
+
31
+ context "#wikify" do
32
+ context "recognizes word separators and strips them out" do
33
+ it "underscores" do
34
+ wikify("one_underscore").should == "OneUnderscore"
35
+ wikify("two_under_scores").should == "TwoUnderScores"
36
+ wikify("_underscore_at_start").should == "UnderscoreAtStart"
37
+ wikify("underscore_at_end_").should == "UnderscoreAtEnd"
38
+ end
39
+
40
+ it "hyphens" do
41
+ wikify("one-hyphen").should == "OneHyphen"
42
+ wikify("with-two-hyphens").should == "WithTwoHyphens"
43
+ wikify("-hyphen-at-start").should == "HyphenAtStart"
44
+ wikify("hyphen-at-end-").should == "HyphenAtEnd"
45
+ end
46
+
47
+ it "spaces" do
48
+ wikify("one space").should == "OneSpace"
49
+ wikify("with two spaces").should == "WithTwoSpaces"
50
+ wikify(" space at start").should == "SpaceAtStart"
51
+ wikify("space at end ").should == "SpaceAtEnd"
52
+ end
53
+
54
+ it "periods" do
55
+ wikify("one.period").should == "OnePeriod"
56
+ wikify("with.two.periods").should == "WithTwoPeriods"
57
+ wikify(".period.at.start").should == "PeriodAtStart"
58
+ wikify("period.at.end.").should == "PeriodAtEnd"
59
+ end
60
+
61
+ it "mixed periods, hyphens, underscores, and spaces" do
62
+ wikify("period.with space").should == "PeriodWithSpace"
63
+ wikify("period.with-hyphen").should == "PeriodWithHyphen"
64
+ wikify("period.with-underscore").should == "PeriodWithUnderscore"
65
+ wikify("under_with space").should == "UnderWithSpace"
66
+ wikify("under_with.period").should == "UnderWithPeriod"
67
+ wikify("under_with-hyphen").should == "UnderWithHyphen"
68
+ wikify("with_under.period-hyphen space").should == "WithUnderPeriodHyphenSpace"
69
+ end
70
+ end
71
+
72
+ it "capitalizes the last letter of single-word inputs" do
73
+ wikify("name").should == "NamE"
74
+ wikify("quest").should == "QuesT"
75
+ end
76
+
77
+ it "leaves already-CamelCased inputs unchanged" do
78
+ wikify("CamelCase").should == "CamelCase"
79
+ wikify("WikiWord with suffix").should == "WikiWordWithSuffix"
80
+ wikify("prefix before WikiWord").should == "PrefixBeforeWikiWord"
81
+ end
82
+ end # wikify
83
+
84
+
85
+ context "#wikify_path" do
86
+ it "turns each path component into a WikiWord" do
87
+ wikify_path("hello_world").should == "HelloWorld"
88
+ wikify_path("hello_world/readme.txt").should == "HelloWorld/ReadmeTxt"
89
+ end
90
+
91
+ it "capitalizes the last letter of single-word path components" do
92
+ wikify_path("features/basic").should == "FeatureS/BasiC"
93
+ wikify_path("features/basic/some.feature").should == "FeatureS/BasiC/SomeFeature"
94
+ end
95
+ end # wikify_path
96
+
97
+
98
+ context "#clean_filename" do
99
+ it "converts path separators to underscores" do
100
+ clean_filename('some/path/name', '', '').should == 'some_path_name'
101
+ end
102
+
103
+ it "removes prefix and suffix" do
104
+ clean_filename('abc/some/path/xyz', 'abc', 'xyz').should == 'some_path'
105
+ end
106
+ end # clean_filename
107
+
108
+
109
+ context "#remove_cruft" do
110
+ it "removes anchor tags and keep the content" do
111
+ string = 'Go to <a href="SomePage">this page</a>'
112
+ expect = 'Go to this page'
113
+ remove_cruft(string).should == expect
114
+ end
115
+
116
+ it "removes [?] content" do
117
+ string = 'See SomePage<a href="SomePage">[?]</a>'
118
+ expect = 'See SomePage'
119
+ remove_cruft(string).should == expect
120
+ end
121
+ end # remove_cruft
122
+
123
+
124
+ context "#table_digest" do
125
+ it "returns the expected digest for a known table" do
126
+ table_digest(['foo', 'bar']).should == '3858f62230ac3c915f300c664312c63f'
127
+ table_digest(['foo', 'baz']).should == '80338e79d2ca9b9c090ebaaa2ef293c7'
128
+ end
129
+
130
+ it "returns the same digest for identical input" do
131
+ table1 = [
132
+ ["Name", "Quest"],
133
+ ["Arthur", "Holy Grail"],
134
+ ["Bevedere", "Holy Grail"],
135
+ ]
136
+ table2 = [
137
+ ["Name", "Quest"],
138
+ ["Arthur", "Holy Grail"],
139
+ ["Bevedere", "Holy Grail"],
140
+ ]
141
+ table_digest(table1).should == table_digest(table2)
142
+ end
143
+
144
+ it "returns different digests for different input" do
145
+ table1 = [
146
+ ["Name", "Quest"],
147
+ ["Arthur", "Holy Grail"],
148
+ ["Bevedere", "Holy Grail"],
149
+ ]
150
+ table2 = [
151
+ ["Name", "Quest"],
152
+ ["Arthur", "Holy Grail"],
153
+ ["Lancelot", "Holy Grail"],
154
+ ]
155
+ table_digest(table1).should_not == table_digest(table2)
156
+ end
157
+
158
+ it "unescapes HTML entities before calculating digest" do
159
+ table1 = [
160
+ ["Name", "Quest"],
161
+ ["!-Arthur-!", "Holy &lt;Grail&gt;"],
162
+ ]
163
+ table2 = [
164
+ ["Name", "Quest"],
165
+ ["Arthur", "Holy <Grail>"],
166
+ ]
167
+ table_digest(table1).should == table_digest(table2)
168
+ end
169
+ end # table_digest
170
+
171
+
172
+ context "#clean_cell" do
173
+ it "strips all markup added by the SlimJSON formatter" do
174
+ clean_cell("report:Feature: Some feature").should == "Feature: Some feature"
175
+ clean_cell("report:Scenario: A scenario").should == "Scenario: A scenario"
176
+ clean_cell("ignore:@some_tag").should == "@some_tag"
177
+ clean_cell("pass:Given a passing step").should == "Given a passing step"
178
+ clean_cell("pass:Given some <b>bold text</b>").should == "Given some bold text"
179
+ clean_cell("pass:Given some <b>bold text</b>").should == "Given some bold text"
180
+ clean_cell("fail:When failing step <br>With line break").should == "When failing step"
181
+ span = '<span class="source_file">features/steps/whatever.rb:15</span>'
182
+ clean_cell("pass:Given a step #{span}").should == "Given a step"
183
+ clean_cell("pass:Given a <b>bold</b> step #{span}").should == "Given a bold step"
184
+ clean_cell("pass:Given a step #{span} <br>with line break").should == "Given a step"
185
+ end
186
+ end # clean_cell
187
+
188
+
189
+ context "#unescape" do
190
+ it "unescapes HTML entities" do
191
+ unescape("With &lt;angle brackets&gt;").should == "With <angle brackets>"
192
+ unescape("Stuff &amp; things").should == "Stuff & things"
193
+ end
194
+
195
+ it "unescapes FitNesse literal markup" do
196
+ unescape("!-a literal-!").should == "a literal"
197
+ unescape("ends with !-a literal-!").should == "ends with a literal"
198
+ unescape("!-starts with-! a literal").should == "starts with a literal"
199
+ end
200
+ end # unescape
201
+
202
+ end
203
+
@@ -0,0 +1,10 @@
1
+ require 'rspec'
2
+ require 'cukable/conversion'
3
+ require 'cukable/cuke'
4
+ require 'cukable/helper'
5
+
6
+ RSpec.configure do |config|
7
+ config.include Cukable::Helper
8
+ config.include Cukable::Conversion
9
+ end
10
+
Binary file
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cukable
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
+ - Eric Pierce
14
+ - Ken Brazier
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-03-23 00:00:00 -06:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: json
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: cucumber
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: diff-lcs
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: rspec
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 7
73
+ segments:
74
+ - 2
75
+ - 2
76
+ - 0
77
+ version: 2.2.0
78
+ type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: rcov
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ type: :development
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: yard
96
+ prerelease: false
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ type: :development
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: bluecloth
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ type: :development
121
+ version_requirements: *id007
122
+ description: " Cukable allows running Cucumber test scenarios from FitNesse\n"
123
+ email: wapcaplet88@gmail.com
124
+ executables:
125
+ - cuke2fit
126
+ extensions: []
127
+
128
+ extra_rdoc_files: []
129
+
130
+ files:
131
+ - .yardopts
132
+ - Gemfile
133
+ - Gemfile.lock
134
+ - README.md
135
+ - Rakefile
136
+ - bin/cuke2fit
137
+ - cukable.gemspec
138
+ - features/conversion.feature
139
+ - features/cuke_fixture.feature
140
+ - features/slim_json_formatter.feature
141
+ - features/step_definitions/cukable_steps.rb
142
+ - features/support/env.rb
143
+ - lib/cukable.rb
144
+ - lib/cukable/conversion.rb
145
+ - lib/cukable/cuke.rb
146
+ - lib/cukable/helper.rb
147
+ - lib/cukable/slim_json_formatter.rb
148
+ - spec/conversion_spec.rb
149
+ - spec/cuke_spec.rb
150
+ - spec/helper_spec.rb
151
+ - spec/spec_helper.rb
152
+ - vendor/cache/rubyslim-0.1.1.gem
153
+ has_rdoc: true
154
+ homepage: http://github.com/wapcaplet/cukable
155
+ licenses: []
156
+
157
+ post_install_message:
158
+ rdoc_options: []
159
+
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ hash: 3
168
+ segments:
169
+ - 0
170
+ version: "0"
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ hash: 3
177
+ segments:
178
+ - 0
179
+ version: "0"
180
+ requirements: []
181
+
182
+ rubyforge_project:
183
+ rubygems_version: 1.3.7
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: Runs Cucumber tests from FitNesse
187
+ test_files: []
188
+