kosmas58-cucumber 0.3.11.6 → 0.3.90
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +62 -4
- data/Manifest.txt +4 -0
- data/examples/i18n/ko/features/addition.feature +5 -5
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/self_test/features/support/env.rb +2 -1
- data/examples/steps_library/features/step_definitions/steps_lib1.rb +8 -0
- data/examples/steps_library/features/step_definitions/steps_lib2.rb +8 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +15 -0
- data/examples/tickets/features/table_diffing.feature +13 -0
- data/examples/watir/features/step_definitons/search_steps.rb +5 -1
- data/features/bug_371.feature +32 -0
- data/features/cucumber_cli_diff_disabled.feature +2 -1
- data/features/html_formatter/a.html +6 -5
- data/features/language_from_header.feature +30 -0
- data/features/rake_task.feature +28 -0
- data/features/steps_formatter.feature +25 -0
- data/features/support/env.rb +5 -0
- data/features/table_diffing.feature +45 -0
- data/features/unicode_table.feature +35 -0
- data/gem_tasks/sass.rake +4 -0
- data/lib/cucumber/ast/outline_table.rb +2 -1
- data/lib/cucumber/ast/py_string.rb +0 -1
- data/lib/cucumber/ast/step.rb +4 -1
- data/lib/cucumber/ast/table.rb +286 -48
- data/lib/cucumber/ast/visitor.rb +2 -1
- data/lib/cucumber/cli/configuration.rb +8 -2
- data/lib/cucumber/cli/language_help_formatter.rb +9 -7
- data/lib/cucumber/feature_file.rb +53 -0
- data/lib/cucumber/filter.rb +50 -0
- data/lib/cucumber/formatter/html.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +20 -5
- data/lib/cucumber/formatter/progress.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +49 -0
- data/lib/cucumber/parser/feature.rb +27 -0
- data/lib/cucumber/parser/i18n/language.rb +83 -0
- data/lib/cucumber/rake/task.rb +6 -0
- data/lib/cucumber/step_match.rb +1 -1
- data/lib/cucumber/version.rb +2 -2
- data/lib/cucumber/webrat/table_locator.rb +66 -0
- data/rails_generators/cucumber/templates/en/webrat_steps.rb +17 -0
- data/rails_generators/cucumber/templates/env.rb +1 -0
- data/rails_generators/feature/templates/feature.erb +1 -1
- data/rails_generators/feature/templates/steps.erb +2 -8
- data/spec/cucumber/ast/table_spec.rb +145 -0
- data/spec/cucumber/cli/configuration_spec.rb +13 -0
- data/spec/cucumber/cli/main_spec.rb +0 -1
- data/spec/cucumber/formatter/progress_spec.rb +2 -2
- metadata +18 -4
@@ -13,13 +13,13 @@ module Cucumber
|
|
13
13
|
include Console
|
14
14
|
attr_writer :indent
|
15
15
|
|
16
|
-
def initialize(step_mother, io, options
|
16
|
+
def initialize(step_mother, io, options)
|
17
17
|
super(step_mother)
|
18
18
|
@io = io
|
19
19
|
@options = options
|
20
|
-
@delim = delim
|
21
20
|
@exceptions = []
|
22
21
|
@indent = 0
|
22
|
+
@prefixes = options[:prefixes] || {}
|
23
23
|
end
|
24
24
|
|
25
25
|
def visit_features(features)
|
@@ -145,6 +145,7 @@ module Cucumber
|
|
145
145
|
|
146
146
|
def visit_multiline_arg(multiline_arg)
|
147
147
|
return if @options[:no_multiline]
|
148
|
+
@table = multiline_arg
|
148
149
|
super
|
149
150
|
end
|
150
151
|
|
@@ -154,7 +155,8 @@ module Cucumber
|
|
154
155
|
end
|
155
156
|
|
156
157
|
def visit_table_row(table_row)
|
157
|
-
@
|
158
|
+
@col_index = 0
|
159
|
+
@io.print ' |'.indent(@indent-2)
|
158
160
|
super
|
159
161
|
@io.puts
|
160
162
|
if table_row.exception && !@exceptions.index(table_row.exception)
|
@@ -169,13 +171,26 @@ module Cucumber
|
|
169
171
|
@io.flush
|
170
172
|
end
|
171
173
|
|
172
|
-
def
|
174
|
+
def visit_table_cell(cell)
|
175
|
+
super
|
176
|
+
@col_index += 1
|
177
|
+
end
|
178
|
+
|
179
|
+
def visit_table_cell_value(value, status)
|
173
180
|
status ||= @status || :passed
|
174
|
-
|
181
|
+
width = @table.col_width(@col_index)
|
182
|
+
cell_text = value.to_s || ''
|
183
|
+
padded = cell_text + (' ' * (width - cell_text.jlength))
|
184
|
+
prefix = cell_prefix(status)
|
185
|
+
@io.print(' ' + format_string("#{prefix}#{padded}", status) + ::Term::ANSIColor.reset(" |"))
|
175
186
|
@io.flush
|
176
187
|
end
|
177
188
|
|
178
189
|
private
|
190
|
+
|
191
|
+
def cell_prefix(status)
|
192
|
+
@prefixes[status]
|
193
|
+
end
|
179
194
|
|
180
195
|
def print_summary(features)
|
181
196
|
print_stats(features)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Formatter
|
3
|
+
class Steps < Ast::Visitor
|
4
|
+
|
5
|
+
def initialize(step_mother, io, options)
|
6
|
+
super(step_mother)
|
7
|
+
@io = io
|
8
|
+
@options = options
|
9
|
+
@step_definition_files = collect_steps(step_mother)
|
10
|
+
end
|
11
|
+
|
12
|
+
def visit_features(features)
|
13
|
+
print_summary
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def print_summary
|
19
|
+
count = 0
|
20
|
+
@step_definition_files.keys.sort.each do |step_definition_file|
|
21
|
+
@io.puts step_definition_file
|
22
|
+
|
23
|
+
sources = @step_definition_files[step_definition_file]
|
24
|
+
source_indent = source_indent(sources)
|
25
|
+
sources.sort.each do |file_colon_line, regexp|
|
26
|
+
@io.print "#{regexp}".indent(2)
|
27
|
+
@io.print " # #{file_colon_line}".indent(source_indent - regexp.size)
|
28
|
+
@io.puts
|
29
|
+
end
|
30
|
+
@io.puts
|
31
|
+
count += sources.size
|
32
|
+
end
|
33
|
+
@io.puts "#{count} step definition(s) in #{@step_definition_files.size} source file(s)."
|
34
|
+
end
|
35
|
+
|
36
|
+
def collect_steps(step_mother)
|
37
|
+
step_mother.step_definitions.inject({}) do |step_definitions, step_definition|
|
38
|
+
step_definitions[step_definition.file] ||= []
|
39
|
+
step_definitions[step_definition.file] << [ step_definition.file_colon_line, step_definition.regexp.inspect ]
|
40
|
+
step_definitions
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def source_indent(sources)
|
45
|
+
sources.map { |file_colon_line, regexp| regexp.size }.max + 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -55,6 +55,10 @@ module Cucumber
|
|
55
55
|
def has_tags?(tag_names)
|
56
56
|
tags.has_tags?(tag_names)
|
57
57
|
end
|
58
|
+
|
59
|
+
def has_all_tags?(tag_names)
|
60
|
+
tags.has_all_tags?(tag_names)
|
61
|
+
end
|
58
62
|
|
59
63
|
def build(filter)
|
60
64
|
if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
|
@@ -211,6 +215,10 @@ module Cucumber
|
|
211
215
|
ts.elements.detect{|e| e.tag.line == line}
|
212
216
|
end
|
213
217
|
|
218
|
+
def has_all_tags?(tags)
|
219
|
+
(tags & tag_names) == tags
|
220
|
+
end
|
221
|
+
|
214
222
|
def has_tags?(tags)
|
215
223
|
(tag_names & tags).any?
|
216
224
|
end
|
@@ -491,6 +499,11 @@ module Cucumber
|
|
491
499
|
feature_tags.has_tags?(tag_names)
|
492
500
|
end
|
493
501
|
|
502
|
+
def has_all_tags?(tag_names)
|
503
|
+
feature_tags = self.parent.tags
|
504
|
+
feature_tags.has_all_tags?(tag_names)
|
505
|
+
end
|
506
|
+
|
494
507
|
def build
|
495
508
|
Ast::Background.new(
|
496
509
|
comment.build,
|
@@ -688,6 +701,11 @@ module Cucumber
|
|
688
701
|
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
689
702
|
end
|
690
703
|
|
704
|
+
def has_all_tags?(tag_names)
|
705
|
+
feature_tags = self.parent.parent.tags
|
706
|
+
tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
|
707
|
+
end
|
708
|
+
|
691
709
|
def matches_name?(regexp_to_match)
|
692
710
|
name.build =~ regexp_to_match
|
693
711
|
end
|
@@ -826,6 +844,11 @@ module Cucumber
|
|
826
844
|
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
827
845
|
end
|
828
846
|
|
847
|
+
def has_all_tags?(tag_names)
|
848
|
+
feature_tags = self.parent.parent.tags
|
849
|
+
tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
|
850
|
+
end
|
851
|
+
|
829
852
|
def matches_name?(regexp_to_match)
|
830
853
|
outline_matches_name?(regexp_to_match) || examples_sections.matches_name?(regexp_to_match)
|
831
854
|
end
|
@@ -1162,6 +1185,10 @@ module Cucumber
|
|
1162
1185
|
true
|
1163
1186
|
end
|
1164
1187
|
|
1188
|
+
def has_all_tags?(tag_names)
|
1189
|
+
true
|
1190
|
+
end
|
1191
|
+
|
1165
1192
|
def outline_at_line?(line)
|
1166
1193
|
true
|
1167
1194
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Parser
|
3
|
+
module I18n
|
4
|
+
class Language
|
5
|
+
KEYWORD_KEYS = %w{name native encoding feature background scenario scenario_outline examples given when then but}
|
6
|
+
|
7
|
+
class << self
|
8
|
+
LANGUAGES = Hash.new{|h,k| h[k] = Language.new(k)}
|
9
|
+
|
10
|
+
def [](key)
|
11
|
+
LANGUAGES[key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def alias_step_definitions(keywords) #:nodoc:
|
15
|
+
all_keywords = %w{given when then and but}.map{|keyword| keywords[keyword].split('|')}.flatten
|
16
|
+
alias_steps(all_keywords)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Sets up additional method aliases for Given, When and Then.
|
20
|
+
# This does *not* affect how feature files are parsed. If you
|
21
|
+
# want to create aliases in the parser, you have to do this in
|
22
|
+
# languages.yml. For example:
|
23
|
+
#
|
24
|
+
# and: And|With
|
25
|
+
def alias_steps(keywords)
|
26
|
+
keywords.each do |adverb|
|
27
|
+
StepMother.alias_adverb(adverb)
|
28
|
+
World.alias_adverb(adverb)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
alias_step_definitions(Cucumber::LANGUAGES['en'])
|
34
|
+
|
35
|
+
def initialize(lang)
|
36
|
+
@keywords = Cucumber::LANGUAGES[lang]
|
37
|
+
raise "Language not supported: #{lang.inspect}" if @keywords.nil?
|
38
|
+
@keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
|
39
|
+
end
|
40
|
+
|
41
|
+
def parser
|
42
|
+
return @parser if @parser
|
43
|
+
i18n_tt = File.expand_path(File.dirname(__FILE__) + '/../i18n.tt')
|
44
|
+
template = File.open(i18n_tt, Cucumber.file_mode('r')).read
|
45
|
+
erb = ERB.new(template)
|
46
|
+
grammar = erb.result(binding)
|
47
|
+
Treetop.load_from_string(grammar)
|
48
|
+
self.class.alias_step_definitions(@keywords)
|
49
|
+
@parser = Parser::I18n.const_get("#{@keywords['grammar_name']}Parser").new
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse(source, path, filter)
|
53
|
+
feature = parser.parse_or_fail(source, path, filter)
|
54
|
+
feature.language = self if feature
|
55
|
+
feature
|
56
|
+
end
|
57
|
+
|
58
|
+
def keywords(key, raw=false)
|
59
|
+
return @keywords[key] if raw
|
60
|
+
return nil unless @keywords[key]
|
61
|
+
values = @keywords[key].split('|')
|
62
|
+
values.map{|value| "'#{value}'"}.join(" / ")
|
63
|
+
end
|
64
|
+
|
65
|
+
def incomplete?
|
66
|
+
KEYWORD_KEYS.detect{|key| @keywords[key].nil?}
|
67
|
+
end
|
68
|
+
|
69
|
+
def scenario_keyword
|
70
|
+
@keywords['scenario'].split('|')[0] + ':'
|
71
|
+
end
|
72
|
+
|
73
|
+
def but_keywords
|
74
|
+
@keywords['but'].split('|')
|
75
|
+
end
|
76
|
+
|
77
|
+
def and_keywords
|
78
|
+
@keywords['and'].split('|')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -194,6 +194,7 @@ module Cucumber
|
|
194
194
|
result = []
|
195
195
|
result += feature_list.to_a if feature_list
|
196
196
|
result += FileList[feature_pattern].to_a if feature_pattern
|
197
|
+
result = make_command_line_safe(result)
|
197
198
|
FileList[result]
|
198
199
|
end
|
199
200
|
end
|
@@ -208,6 +209,11 @@ module Cucumber
|
|
208
209
|
FileList[result]
|
209
210
|
end
|
210
211
|
end
|
212
|
+
|
213
|
+
private
|
214
|
+
def make_command_line_safe(list)
|
215
|
+
list.map{|string| string.gsub(' ', '\ ')}
|
216
|
+
end
|
211
217
|
end
|
212
218
|
|
213
219
|
class FeatureTask < Task
|
data/lib/cucumber/step_match.rb
CHANGED
data/lib/cucumber/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Webrat
|
2
|
+
class Table < Element
|
3
|
+
def self.xpath_search
|
4
|
+
".//table"
|
5
|
+
end
|
6
|
+
|
7
|
+
# Converts this Table element into a 2-dimensional array of String where each cell
|
8
|
+
# represents the inner_html of the <td> and <th> elements. The number of columns is
|
9
|
+
# determined by the number of cells in the first row.
|
10
|
+
def to_a
|
11
|
+
col_count = nil
|
12
|
+
Webrat::XML.css_search(@element, 'tr').map do |row|
|
13
|
+
cols = Webrat::XML.css_search(row, 'th,td')
|
14
|
+
col_count ||= cols.length
|
15
|
+
cols[0...col_count].map do |col|
|
16
|
+
col.inner_html
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Locators
|
23
|
+
class TableLocator < Locator
|
24
|
+
def locate
|
25
|
+
Table.load(@session, table_element)
|
26
|
+
end
|
27
|
+
|
28
|
+
def table_element
|
29
|
+
table_elements.detect do |table_element|
|
30
|
+
matches_id?(table_element) ||
|
31
|
+
matches_css_selector?(table_element)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def matches_id?(table_element)
|
36
|
+
Webrat::XML.attribute(table_element, "id") == @value.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def matches_css_selector?(table_element)
|
40
|
+
Webrat::XML.css_at(@dom, @value)
|
41
|
+
end
|
42
|
+
|
43
|
+
def table_elements
|
44
|
+
Webrat::XML.xpath_search(@dom, *Table.xpath_search)
|
45
|
+
end
|
46
|
+
|
47
|
+
def error_message
|
48
|
+
"Could not find table matching '#{@value}'"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns a Table element located by +id_or_selector+, which can
|
53
|
+
# be a DOM id or a CSS selector.
|
54
|
+
def table_at(id_or_selector)
|
55
|
+
TableLocator.new(@session, dom, id_or_selector).locate!
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module Methods
|
60
|
+
delegate_to_session :table_at
|
61
|
+
end
|
62
|
+
|
63
|
+
class Session
|
64
|
+
def_delegators :current_scope, :table_at
|
65
|
+
end
|
66
|
+
end
|
@@ -98,6 +98,15 @@ Then /^I should see "([^\"]*)"$/ do |text|
|
|
98
98
|
<% end -%>
|
99
99
|
end
|
100
100
|
|
101
|
+
Then /^I should see \/([^\/]*)\/$/ do |regexp|
|
102
|
+
regexp = Regexp.new(regexp)
|
103
|
+
<% if framework == :rspec -%>
|
104
|
+
response.should contain(regexp)
|
105
|
+
<% else -%>
|
106
|
+
assert_contain regexp
|
107
|
+
<% end -%>
|
108
|
+
end
|
109
|
+
|
101
110
|
Then /^I should not see "([^\"]*)"$/ do |text|
|
102
111
|
<% if framework == :rspec -%>
|
103
112
|
response.should_not contain(text)
|
@@ -106,6 +115,14 @@ Then /^I should not see "([^\"]*)"$/ do |text|
|
|
106
115
|
<% end -%>
|
107
116
|
end
|
108
117
|
|
118
|
+
Then /^I should not see \/([^\/]*)\/$/ do |regexp|
|
119
|
+
<% if framework == :rspec -%>
|
120
|
+
response.should_not contain(text)
|
121
|
+
<% else -%>
|
122
|
+
assert_not_contain text
|
123
|
+
<% end -%>
|
124
|
+
end
|
125
|
+
|
109
126
|
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
110
127
|
<% if framework == :rspec -%>
|
111
128
|
field_labeled(field).value.should =~ /#{value}/
|
@@ -25,7 +25,7 @@ Feature: Manage <%= plural_name %>
|
|
25
25
|
<% end -%>
|
26
26
|
When I delete the 3rd <%= singular_name %>
|
27
27
|
Then I should see the following <%= plural_name %>:
|
28
|
-
|<%= named_args.map
|
28
|
+
|<%= named_args.map{|arg| arg.name.humanize}.join('|') %>|
|
29
29
|
<% [1,2,4].each do |n| -%>
|
30
30
|
|<%= named_args.map{|arg| arg.value(n)}.join('|') %>|
|
31
31
|
<% end -%>
|
@@ -9,12 +9,6 @@ When /^I delete the (\d+)(?:st|nd|rd|th) <%= singular_name %>$/ do |pos|
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
Then /^I should see the following <%= plural_name %>:$/ do
|
13
|
-
<%= plural_name
|
14
|
-
row.each_with_index do |cell, j|
|
15
|
-
response.should have_selector("table > tr:nth-child(#{i+2}) > td:nth-child(#{j+1})") { |td|
|
16
|
-
td.inner_text.should == cell
|
17
|
-
}
|
18
|
-
end
|
19
|
-
end
|
12
|
+
Then /^I should see the following <%= plural_name %>:$/ do |expected_<%= plural_name %>_table|
|
13
|
+
expected_<%= plural_name %>_table.diff!(table_at('table').to_a)
|
20
14
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
3
|
require 'cucumber/ast/table'
|
3
4
|
|
@@ -168,6 +169,150 @@ module Cucumber
|
|
168
169
|
|
169
170
|
end
|
170
171
|
|
172
|
+
describe "diff!" do
|
173
|
+
it "should detect a complex diff" do
|
174
|
+
t1 = table(%{
|
175
|
+
| 1 | 22 | 333 | 4444 |
|
176
|
+
| 55555 | 666666 | 7777777 | 88888888 |
|
177
|
+
| 999999999 | 0000000000 | 01010101010 | 121212121212 |
|
178
|
+
| 4000 | ABC | DEF | 50000 |
|
179
|
+
})
|
180
|
+
|
181
|
+
t2 = table(%{
|
182
|
+
| a | 4444 | 1 |
|
183
|
+
| bb | 88888888 | 55555 |
|
184
|
+
| ccc | xxxxxxxx | 999999999 |
|
185
|
+
| dddd | 4000 | 300 |
|
186
|
+
| e | 50000 | 4000 |
|
187
|
+
})
|
188
|
+
lambda{t1.diff!(t2)}.should raise_error
|
189
|
+
t1.to_s(:indent => 12, :color => false).should == %{
|
190
|
+
| 1 | (-) 22 | (-) 333 | 4444 | (+) a |
|
191
|
+
| 55555 | (-) 666666 | (-) 7777777 | 88888888 | (+) bb |
|
192
|
+
| (-) 999999999 | (-) 0000000000 | (-) 01010101010 | (-) 121212121212 | (+) |
|
193
|
+
| (+) 999999999 | (+) | (+) | (+) xxxxxxxx | (+) ccc |
|
194
|
+
| (+) 300 | (+) | (+) | (+) 4000 | (+) dddd |
|
195
|
+
| 4000 | (-) ABC | (-) DEF | 50000 | (+) e |
|
196
|
+
}
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should not change table when diffed with identical" do
|
200
|
+
t = table(%{
|
201
|
+
|a|b|c|
|
202
|
+
|d|e|f|
|
203
|
+
|g|h|i|
|
204
|
+
})
|
205
|
+
t.diff!(t.dup)
|
206
|
+
t.to_s(:indent => 12, :color => false).should == %{
|
207
|
+
| a | b | c |
|
208
|
+
| d | e | f |
|
209
|
+
| g | h | i |
|
210
|
+
}
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should inspect missing and surplus cells" do
|
214
|
+
t1 = Table.new([
|
215
|
+
['name', 'male', 'lastname', 'swedish'],
|
216
|
+
['aslak', 'true', 'hellesøy', 'false']
|
217
|
+
])
|
218
|
+
t2 = Table.new([
|
219
|
+
['name', 'male', 'lastname', 'swedish'],
|
220
|
+
['aslak', true, 'hellesøy', false]
|
221
|
+
])
|
222
|
+
lambda{t1.diff!(t2)}.should raise_error
|
223
|
+
t1.to_s(:indent => 12, :color => false).should == %{
|
224
|
+
| name | male | lastname | swedish |
|
225
|
+
| (-) aslak | (-) (i) "true" | (-) hellesøy | (-) (i) "false" |
|
226
|
+
| (+) aslak | (+) (i) true | (+) hellesøy | (+) (i) false |
|
227
|
+
}
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should allow column mapping before diffing" do
|
231
|
+
t1 = Table.new([
|
232
|
+
['name', 'male'],
|
233
|
+
['aslak', 'true']
|
234
|
+
])
|
235
|
+
t1.map_column!('male') { |m| m == 'true' }
|
236
|
+
t2 = Table.new([
|
237
|
+
['name', 'male'],
|
238
|
+
['aslak', true]
|
239
|
+
])
|
240
|
+
t1.diff!(t2)
|
241
|
+
t1.to_s(:indent => 12, :color => false).should == %{
|
242
|
+
| name | male |
|
243
|
+
| aslak | true |
|
244
|
+
}
|
245
|
+
end
|
246
|
+
|
247
|
+
it "should allow header mapping before diffing" do
|
248
|
+
t1 = Table.new([
|
249
|
+
['Name', 'Male'],
|
250
|
+
['aslak', 'true']
|
251
|
+
])
|
252
|
+
t1.map_headers!('Name' => 'name', 'Male' => 'male')
|
253
|
+
t1.map_column!('male') { |m| m == 'true' }
|
254
|
+
t2 = Table.new([
|
255
|
+
['name', 'male'],
|
256
|
+
['aslak', true]
|
257
|
+
])
|
258
|
+
t1.diff!(t2)
|
259
|
+
t1.to_s(:indent => 12, :color => false).should == %{
|
260
|
+
| name | male |
|
261
|
+
| aslak | true |
|
262
|
+
}
|
263
|
+
end
|
264
|
+
|
265
|
+
describe "raising" do
|
266
|
+
before do
|
267
|
+
@t = table(%{
|
268
|
+
| a | b |
|
269
|
+
| c | d |
|
270
|
+
})
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should raise on missing rows" do
|
274
|
+
t = table(%{
|
275
|
+
| a | b |
|
276
|
+
})
|
277
|
+
lambda { @t.dup.diff!(t) }.should raise_error
|
278
|
+
lambda { @t.dup.diff!(t, :missing_row => false) }.should_not raise_error
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should raise on surplus rows" do
|
282
|
+
t = table(%{
|
283
|
+
| a | b |
|
284
|
+
| c | d |
|
285
|
+
| e | f |
|
286
|
+
})
|
287
|
+
lambda { @t.dup.diff!(t) }.should raise_error
|
288
|
+
lambda { @t.dup.diff!(t, :surplus_row => false) }.should_not raise_error
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should raise on missing columns" do
|
292
|
+
t = table(%{
|
293
|
+
| a |
|
294
|
+
| c |
|
295
|
+
})
|
296
|
+
lambda { @t.dup.diff!(t) }.should raise_error
|
297
|
+
lambda { @t.dup.diff!(t, :missing_col => false) }.should_not raise_error
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should not raise on surplus columns" do
|
301
|
+
t = table(%{
|
302
|
+
| a | b | x |
|
303
|
+
| c | d | y |
|
304
|
+
})
|
305
|
+
lambda { @t.dup.diff!(t) }.should_not raise_error
|
306
|
+
lambda { @t.dup.diff!(t, :surplus_col => true) }.should raise_error
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def table(text, file=nil, line_offset=0)
|
311
|
+
@table_parser ||= Parser::TableParser.new
|
312
|
+
@table_parser.parse_or_fail(text.strip, file, line_offset)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
171
316
|
it "should convert to sexp" do
|
172
317
|
@table.to_sexp.should ==
|
173
318
|
[:table,
|
@@ -55,6 +55,19 @@ module Cli
|
|
55
55
|
]
|
56
56
|
end
|
57
57
|
|
58
|
+
it "should require files in vendor/{plugins,gems}/*/cucumber/*.rb" do
|
59
|
+
given_the_following_files("/vendor/plugins/plugin_a/cucumber/foo.rb",
|
60
|
+
"/vendor/gems/gem_a/cucumber/bar.rb")
|
61
|
+
|
62
|
+
config = Configuration.new(StringIO.new)
|
63
|
+
config.parse!(%w{--require /features})
|
64
|
+
|
65
|
+
config.files_to_require.should == [
|
66
|
+
"/vendor/plugins/plugin_a/cucumber/foo.rb",
|
67
|
+
"/vendor/gems/gem_a/cucumber/bar.rb"
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
58
71
|
describe "--exclude" do
|
59
72
|
|
60
73
|
it "excludes a ruby file from requiring when the name matches exactly" do
|
@@ -17,7 +17,7 @@ module Cucumber
|
|
17
17
|
describe "visiting a table cell value without a status" do
|
18
18
|
it "should take the status from the last run step" do
|
19
19
|
@progress.visit_step_result('', '', nil, :failed, nil, 10, nil)
|
20
|
-
@progress.visit_table_cell_value('value',
|
20
|
+
@progress.visit_table_cell_value('value', nil)
|
21
21
|
|
22
22
|
@out.string.should == "FF"
|
23
23
|
end
|
@@ -25,7 +25,7 @@ module Cucumber
|
|
25
25
|
|
26
26
|
describe "visiting a table cell which is a table header" do
|
27
27
|
it "should not output anything" do
|
28
|
-
@progress.visit_table_cell_value('value',
|
28
|
+
@progress.visit_table_cell_value('value', :skipped_param)
|
29
29
|
|
30
30
|
@out.string.should == ""
|
31
31
|
end
|