cucumber_analytics 0.0.9 → 1.0.0
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 +15 -0
- data/History.rdoc +16 -0
- data/README.rdoc +5 -3
- data/Rakefile +7 -2
- data/cucumber_analytics.gemspec +7 -5
- data/features/analysis/step_collection.feature +44 -45
- data/features/modeling/background_modeling.feature +14 -144
- data/features/modeling/directory_modeling.feature +3 -2
- data/features/modeling/doc_string_modeling.feature +46 -0
- data/features/modeling/example_modeling.feature +13 -34
- data/features/modeling/feature_file_modeling.feature +3 -2
- data/features/modeling/feature_modeling.feature +18 -80
- data/features/modeling/outline_modeling.feature +25 -164
- data/features/modeling/scenario_modeling.feature +17 -144
- data/features/modeling/step_modeling.feature +68 -0
- data/features/modeling/table_modeling.feature +41 -0
- data/features/step_definitions/background_steps.rb +12 -11
- data/features/step_definitions/directory_steps.rb +6 -3
- data/features/step_definitions/doc_string_steps.rb +50 -0
- data/features/step_definitions/{file_steps.rb → feature_file_steps.rb} +8 -2
- data/features/step_definitions/feature_steps.rb +8 -4
- data/features/step_definitions/outline_steps.rb +12 -6
- data/features/step_definitions/setup_steps.rb +2 -2
- data/features/step_definitions/spec_steps.rb +6 -3
- data/features/step_definitions/step_steps.rb +91 -0
- data/features/step_definitions/table_steps.rb +10 -0
- data/features/step_definitions/test_steps.rb +6 -10
- data/features/step_definitions/world_steps.rb +28 -19
- data/features/support/env.rb +0 -2
- data/lib/cucumber_analytics/background.rb +16 -0
- data/lib/cucumber_analytics/containing.rb +18 -0
- data/lib/cucumber_analytics/directory.rb +83 -0
- data/lib/cucumber_analytics/doc_string.rb +55 -0
- data/lib/cucumber_analytics/example.rb +100 -0
- data/lib/cucumber_analytics/feature.rb +120 -0
- data/lib/cucumber_analytics/feature_element.rb +22 -40
- data/lib/cucumber_analytics/feature_file.rb +74 -0
- data/lib/cucumber_analytics/outline.rb +49 -0
- data/lib/cucumber_analytics/parsing.rb +30 -0
- data/lib/cucumber_analytics/scenario.rb +31 -0
- data/lib/cucumber_analytics/step.rb +142 -32
- data/lib/cucumber_analytics/table.rb +51 -0
- data/lib/cucumber_analytics/taggable.rb +35 -0
- data/lib/cucumber_analytics/test_element.rb +36 -91
- data/lib/cucumber_analytics/version.rb +1 -1
- data/lib/cucumber_analytics/world.rb +109 -153
- data/lib/cucumber_analytics.rb +12 -8
- data/spec/integration/background_integration_spec.rb +18 -0
- data/spec/integration/directory_integration_spec.rb +24 -0
- data/spec/{feature_spec.rb → integration/feature_file_integration_spec.rb} +5 -5
- data/spec/integration/feature_integration_spec.rb +86 -0
- data/spec/integration/outline_integration_spec.rb +22 -0
- data/spec/integration/scenario_integration_spec.rb +18 -0
- data/spec/integration/step_integration_spec.rb +116 -0
- data/spec/integration/world_integration_spec.rb +40 -0
- data/spec/spec_helper.rb +7 -3
- data/spec/unit/background_unit_spec.rb +22 -0
- data/spec/unit/bare_bones_unit_specs.rb +13 -0
- data/spec/unit/containing_element_unit_specs.rb +17 -0
- data/spec/unit/directory_unit_spec.rb +91 -0
- data/spec/unit/doc_string_unit_spec.rb +65 -0
- data/spec/unit/example_unit_spec.rb +171 -0
- data/spec/unit/feature_element_unit_spec.rb +19 -0
- data/spec/unit/feature_element_unit_specs.rb +39 -0
- data/spec/unit/feature_file_unit_spec.rb +82 -0
- data/spec/unit/feature_unit_spec.rb +81 -0
- data/spec/unit/nested_element_unit_specs.rb +24 -0
- data/spec/unit/outline_unit_spec.rb +56 -0
- data/spec/unit/parsing_unit_spec.rb +21 -0
- data/spec/unit/prepopulated_unit_specs.rb +13 -0
- data/spec/unit/scenario_unit_spec.rb +36 -0
- data/spec/unit/step_unit_spec.rb +231 -0
- data/spec/unit/table_unit_spec.rb +52 -0
- data/spec/unit/taggable_unit_spec.rb +63 -0
- data/spec/unit/tagged_element_unit_specs.rb +48 -0
- data/spec/unit/test_element_unit_spec.rb +40 -0
- data/spec/unit/test_element_unit_specs.rb +31 -0
- data/spec/unit/world_unit_spec.rb +167 -0
- metadata +106 -41
- data/lib/cucumber_analytics/logging.rb +0 -28
- data/lib/cucumber_analytics/outline_example.rb +0 -110
- data/lib/cucumber_analytics/parsed_background.rb +0 -45
- data/lib/cucumber_analytics/parsed_directory.rb +0 -78
- data/lib/cucumber_analytics/parsed_feature.rb +0 -97
- data/lib/cucumber_analytics/parsed_file.rb +0 -199
- data/lib/cucumber_analytics/parsed_scenario.rb +0 -67
- data/lib/cucumber_analytics/parsed_scenario_outline.rb +0 -122
- data/spec/background_spec.rb +0 -23
- data/spec/directory_spec.rb +0 -18
- data/spec/example_spec.rb +0 -37
- data/spec/file_spec.rb +0 -20
- data/spec/outline_spec.rb +0 -32
- data/spec/scenario_spec.rb +0 -33
- data/spec/step_spec.rb +0 -24
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('World') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'World, Integration' do
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
@world = CucumberAnalytics::World
|
|
9
|
+
@world.loaded_step_patterns.clear
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'collecting stuff' do
|
|
13
|
+
|
|
14
|
+
before(:each) do
|
|
15
|
+
@patterns = [/a defined step/, /another defined step/]
|
|
16
|
+
@defined_steps = [CucumberAnalytics::Step.new('* a defined step'), CucumberAnalytics::Step.new('* another defined step')]
|
|
17
|
+
@undefined_steps = [CucumberAnalytics::Step.new('* an undefined step'), CucumberAnalytics::Step.new('* another undefined step')]
|
|
18
|
+
|
|
19
|
+
@patterns.each do |pattern|
|
|
20
|
+
@world.load_step_pattern(pattern)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'can collect defined steps from containers' do
|
|
25
|
+
nested_container = double(:steps => @defined_steps)
|
|
26
|
+
container = double(:steps => @undefined_steps, :contains => [nested_container])
|
|
27
|
+
|
|
28
|
+
@defined_steps.should =~ @world.defined_steps_in(container)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'can collect undefined steps from containers' do
|
|
32
|
+
nested_container = double(:steps => @defined_steps)
|
|
33
|
+
container = double(:steps => @undefined_steps, :contains => [nested_container])
|
|
34
|
+
|
|
35
|
+
@undefined_steps.should =~ @world.undefined_steps_in(container)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
require 'rspec'
|
|
2
|
-
|
|
3
1
|
require 'simplecov' unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
2
|
|
|
5
3
|
require "#{File.dirname(__FILE__)}/../lib/cucumber_analytics"
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
require "#{File.dirname(__FILE__)}/unit/feature_element_unit_specs"
|
|
6
|
+
require "#{File.dirname(__FILE__)}/unit/nested_element_unit_specs"
|
|
7
|
+
require "#{File.dirname(__FILE__)}/unit/tagged_element_unit_specs"
|
|
8
|
+
require "#{File.dirname(__FILE__)}/unit/containing_element_unit_specs"
|
|
9
|
+
require "#{File.dirname(__FILE__)}/unit/bare_bones_unit_specs"
|
|
10
|
+
require "#{File.dirname(__FILE__)}/unit/test_element_unit_specs"
|
|
11
|
+
require "#{File.dirname(__FILE__)}/unit/prepopulated_unit_specs"
|
|
8
12
|
|
|
9
13
|
|
|
10
14
|
DEFAULT_FEATURE_FILE_NAME = 'test_feature.feature'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Background') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Background, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Background
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a containing element', clazz
|
|
12
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
13
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
14
|
+
it_should_behave_like 'a test element', clazz
|
|
15
|
+
|
|
16
|
+
it 'can be parsed from stand alone text' do
|
|
17
|
+
source = 'Background: '
|
|
18
|
+
|
|
19
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a containing element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'has children - #contains' do
|
|
10
|
+
@element.should respond_to(:contains)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'returns a collection of children - #contains' do
|
|
14
|
+
@element.contains.is_a?(Array).should be_true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Directory') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Directory, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Directory
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
|
10
|
+
it_should_behave_like 'a containing element', clazz
|
|
11
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
12
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
13
|
+
|
|
14
|
+
before(:each) do
|
|
15
|
+
@directory = clazz.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'cannot model a non-existent directory' do
|
|
19
|
+
path = "#{DEFAULT_FILE_DIRECTORY}/missing_directory"
|
|
20
|
+
|
|
21
|
+
expect { CucumberAnalytics::Directory.new(path) }.to raise_error(ArgumentError)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'knows the name of the directory that it is modeling' do
|
|
25
|
+
path = "#{DEFAULT_FILE_DIRECTORY}"
|
|
26
|
+
|
|
27
|
+
directory = CucumberAnalytics::Directory.new(path)
|
|
28
|
+
|
|
29
|
+
directory.name.should == 'temp_files'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'knows the path of the directory that it is modeling' do
|
|
33
|
+
path = "#{DEFAULT_FILE_DIRECTORY}"
|
|
34
|
+
|
|
35
|
+
directory = CucumberAnalytics::Directory.new(path)
|
|
36
|
+
|
|
37
|
+
directory.path.should == path
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'has feature files - #feature_files' do
|
|
41
|
+
@directory.should respond_to(:feature_files)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'can get and set its feature files - #feature_files, #feature_files=' do
|
|
45
|
+
@directory.feature_files = :some_feature_files
|
|
46
|
+
@directory.feature_files.should == :some_feature_files
|
|
47
|
+
@directory.feature_files = :some_other_feature_files
|
|
48
|
+
@directory.feature_files.should == :some_other_feature_files
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'knows how many feature files it has - #feature_file_count' do
|
|
52
|
+
@directory.feature_files = [:file_1, :file_2, :file_3]
|
|
53
|
+
|
|
54
|
+
@directory.feature_file_count.should == 3
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'has directories - #directories' do
|
|
58
|
+
@directory.should respond_to(:directories)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'can get and set its directories - #directories, #directories=' do
|
|
62
|
+
@directory.directories = :some_directories
|
|
63
|
+
@directory.directories.should == :some_directories
|
|
64
|
+
@directory.directories = :some_other_directories
|
|
65
|
+
@directory.directories.should == :some_other_directories
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'knows how many directories it has - #directory_count' do
|
|
69
|
+
@directory.directories = [:directory_1, :directory_2, :directory_3]
|
|
70
|
+
|
|
71
|
+
@directory.directory_count.should == 3
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'starts with no feature files or directories' do
|
|
75
|
+
@directory.feature_files.should == []
|
|
76
|
+
@directory.directories.should == []
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'contains feature files and directories' do
|
|
80
|
+
directories = [:directory_1, :directory_2, :directory_3]
|
|
81
|
+
files = [:file_1, :file_2, :file_3]
|
|
82
|
+
everything = files + directories
|
|
83
|
+
|
|
84
|
+
@directory.directories = directories
|
|
85
|
+
@directory.feature_files = files
|
|
86
|
+
|
|
87
|
+
@directory.contains.should =~ everything
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('DocString') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'DocString, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::DocString
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
|
10
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
11
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
12
|
+
|
|
13
|
+
it 'can be parsed from stand alone text' do
|
|
14
|
+
source = "\"\"\"\nsome doc string\n\"\"\""
|
|
15
|
+
|
|
16
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
before(:each) do
|
|
20
|
+
@doc_string = clazz.new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'has a content type - #content_type' do
|
|
24
|
+
@doc_string.should respond_to(:content_type)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'can get and set its content type - #content_type, #content_type=' do
|
|
28
|
+
@doc_string.content_type = :some_content_type
|
|
29
|
+
@doc_string.content_type.should == :some_content_type
|
|
30
|
+
@doc_string.content_type = :some_other_content_type
|
|
31
|
+
@doc_string.content_type.should == :some_other_content_type
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'starts with no content type' do
|
|
35
|
+
@doc_string.content_type.should == nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'has contents - #contents' do
|
|
39
|
+
@doc_string.should respond_to(:contents)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'can get and set its contents - #contents, #contents=' do
|
|
43
|
+
@doc_string.contents = :some_contents
|
|
44
|
+
@doc_string.contents.should == :some_contents
|
|
45
|
+
@doc_string.contents = :some_other_contents
|
|
46
|
+
@doc_string.contents.should == :some_other_contents
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'starts with no contents' do
|
|
50
|
+
@doc_string.contents.should == []
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'stores its contents as an array of strings' do
|
|
54
|
+
source = "\"\"\"\nsome text\nsome more text\n\"\"\""
|
|
55
|
+
doc_string = CucumberAnalytics::DocString.new(source)
|
|
56
|
+
|
|
57
|
+
contents = doc_string.contents
|
|
58
|
+
|
|
59
|
+
contents.is_a?(Array).should be_true
|
|
60
|
+
contents.each do |line|
|
|
61
|
+
line.is_a?(String).should be_true
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Example') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Example, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Example
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a tagged element', clazz
|
|
12
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
13
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
it 'can be parsed from stand alone text' do
|
|
17
|
+
source = ['Examples: ',
|
|
18
|
+
'|param| ']
|
|
19
|
+
|
|
20
|
+
source = source.join("\n")
|
|
21
|
+
|
|
22
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
before(:each) do
|
|
27
|
+
@example = clazz.new
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
it 'has parameters - #parameters' do
|
|
32
|
+
@example.should respond_to(:parameters)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'can get and set its parameters - #parameters, #parameters=' do
|
|
36
|
+
@example.parameters = :some_parameters
|
|
37
|
+
@example.parameters.should == :some_parameters
|
|
38
|
+
@example.parameters = :some_other_parameters
|
|
39
|
+
@example.parameters.should == :some_other_parameters
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'starts with no parameters' do
|
|
43
|
+
@example.parameters.should == []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'has rows - #rows' do
|
|
47
|
+
@example.should respond_to(:rows)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'can get and set its rows - #rows, #rows=' do
|
|
51
|
+
@example.rows = :some_rows
|
|
52
|
+
@example.rows.should == :some_rows
|
|
53
|
+
@example.rows = :some_other_rows
|
|
54
|
+
@example.rows.should == :some_other_rows
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'starts with no rows' do
|
|
58
|
+
@example.rows.should == []
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'stores its rows as an nested array of hashes' do
|
|
62
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|"
|
|
63
|
+
example = CucumberAnalytics::Example.new(source)
|
|
64
|
+
|
|
65
|
+
rows = example.rows
|
|
66
|
+
|
|
67
|
+
rows.is_a?(Array).should be_true
|
|
68
|
+
rows.empty?.should be_false
|
|
69
|
+
rows.each { |row| row.is_a?(Hash).should be_true }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'does not include the parameter row as a row' do
|
|
73
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
|
74
|
+
example = CucumberAnalytics::Example.new(source)
|
|
75
|
+
|
|
76
|
+
rows = example.rows
|
|
77
|
+
|
|
78
|
+
rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4']]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context '#add_row' do
|
|
82
|
+
|
|
83
|
+
it 'can add a new example row' do
|
|
84
|
+
clazz.new.should respond_to(:add_row)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'can add a new row as a hash' do
|
|
88
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|"
|
|
89
|
+
example = CucumberAnalytics::Example.new(source)
|
|
90
|
+
|
|
91
|
+
new_row = {'param1' => 'value3', 'param2' => 'value4'}
|
|
92
|
+
example.add_row(new_row)
|
|
93
|
+
|
|
94
|
+
example.rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4']]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'can add a new row as an array' do
|
|
98
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|"
|
|
99
|
+
example = CucumberAnalytics::Example.new(source)
|
|
100
|
+
|
|
101
|
+
new_row = ['value3', 'value4']
|
|
102
|
+
example.add_row(new_row)
|
|
103
|
+
|
|
104
|
+
example.rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4']]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'can only use a Hash or an Array to add a new row' do
|
|
108
|
+
expect { @example.add_row({}) }.to_not raise_error
|
|
109
|
+
expect { @example.add_row([]) }.to_not raise_error
|
|
110
|
+
expect { @example.add_row(:a_row) }.to raise_error(ArgumentError)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'trims whitespace from added rows' do
|
|
114
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|"
|
|
115
|
+
example = CucumberAnalytics::Example.new(source)
|
|
116
|
+
|
|
117
|
+
hash_row = {'param1' => 'value3 ', 'param2' => ' value4'}
|
|
118
|
+
array_row = ['value5', ' value6 ']
|
|
119
|
+
example.add_row(hash_row)
|
|
120
|
+
example.add_row(array_row)
|
|
121
|
+
|
|
122
|
+
example.rows.collect { |row| row.values }.should == [['value1', 'value2'], ['value3', 'value4'], ['value5', 'value6']]
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
context '#remove_row' do
|
|
127
|
+
|
|
128
|
+
it 'can remove an existing example row' do
|
|
129
|
+
clazz.new.should respond_to(:remove_row)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'can remove an existing row as a hash' do
|
|
133
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
|
134
|
+
example = CucumberAnalytics::Example.new(source)
|
|
135
|
+
|
|
136
|
+
old_row = {'param1' => 'value3', 'param2' => 'value4'}
|
|
137
|
+
example.remove_row(old_row)
|
|
138
|
+
|
|
139
|
+
example.rows.collect { |row| row.values }.should == [['value1', 'value2']]
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'can remove an existing row as an array' do
|
|
143
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
|
144
|
+
example = CucumberAnalytics::Example.new(source)
|
|
145
|
+
|
|
146
|
+
old_row = ['value3', 'value4']
|
|
147
|
+
example.remove_row(old_row)
|
|
148
|
+
|
|
149
|
+
example.rows.collect { |row| row.values }.should == [['value1', 'value2']]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it 'can only use a Hash or an Array to remove an existing row' do
|
|
153
|
+
expect { @example.remove_row({}) }.to_not raise_error
|
|
154
|
+
expect { @example.remove_row([]) }.to_not raise_error
|
|
155
|
+
expect { @example.remove_row(:a_row) }.to raise_error(ArgumentError)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it 'trims whitespace from removed rows' do
|
|
159
|
+
source = "Examples:\n|param1|param2|\n|value1|value2|\n|value3|value4|\n|value5|value6|"
|
|
160
|
+
example = CucumberAnalytics::Example.new(source)
|
|
161
|
+
|
|
162
|
+
hash_row = {'param1' => 'value3 ', 'param2' => ' value4'}
|
|
163
|
+
array_row = ['value5', ' value6 ']
|
|
164
|
+
example.remove_row(hash_row)
|
|
165
|
+
example.remove_row(array_row)
|
|
166
|
+
|
|
167
|
+
example.rows.collect { |row| row.values }.should == [['value1', 'value2']]
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('FeatureElement') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'FeatureElement, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::FeatureElement
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
12
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
before(:each) do
|
|
16
|
+
@element = clazz.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a feature element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'has a name - #name' do
|
|
10
|
+
@element.should respond_to(:name)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'can get and set its name - #name, #name=' do
|
|
14
|
+
@element.name = :some_name
|
|
15
|
+
@element.name.should == :some_name
|
|
16
|
+
@element.name = :some_other_name
|
|
17
|
+
@element.name.should == :some_other_name
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'has a description - #description' do
|
|
21
|
+
@element.should respond_to(:description)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'can get and set its description - #description, #description=' do
|
|
25
|
+
@element.description = :some_description
|
|
26
|
+
@element.description.should == :some_description
|
|
27
|
+
@element.description = :some_other_description
|
|
28
|
+
@element.description.should == :some_other_description
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'starts with no name' do
|
|
32
|
+
@element.name.should == ''
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'starts with no description' do
|
|
36
|
+
@element.description.should == []
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('FeatureFile') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'FeatureFile, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::FeatureFile
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a nested element', clazz
|
|
10
|
+
it_should_behave_like 'a containing element', clazz
|
|
11
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
12
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
before(:each) do
|
|
16
|
+
@feature_file = clazz.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'cannot model a non-existent directory' do
|
|
20
|
+
path = "#{DEFAULT_FILE_DIRECTORY}/missing_file.txt"
|
|
21
|
+
|
|
22
|
+
expect { CucumberAnalytics::FeatureFile.new(path) }.to raise_error(ArgumentError)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'knows the name of the file that it is modeling' do
|
|
26
|
+
path = "#{DEFAULT_FILE_DIRECTORY}/#{DEFAULT_FEATURE_FILE_NAME}"
|
|
27
|
+
File.open(path, "w") {}
|
|
28
|
+
|
|
29
|
+
feature = CucumberAnalytics::FeatureFile.new(path)
|
|
30
|
+
|
|
31
|
+
feature.name.should == DEFAULT_FEATURE_FILE_NAME
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'knows the path of the file that it is modeling' do
|
|
35
|
+
path = "#{DEFAULT_FILE_DIRECTORY}/#{DEFAULT_FEATURE_FILE_NAME}"
|
|
36
|
+
File.open(path, "w") {}
|
|
37
|
+
|
|
38
|
+
directory = CucumberAnalytics::FeatureFile.new(path)
|
|
39
|
+
|
|
40
|
+
directory.path.should == path
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'has features - #features' do
|
|
44
|
+
@feature_file.should respond_to(:features)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'can get and set its features - #features, #features=' do
|
|
48
|
+
@feature_file.features = :some_features
|
|
49
|
+
@feature_file.features.should == :some_features
|
|
50
|
+
@feature_file.features = :some_other_features
|
|
51
|
+
@feature_file.features.should == :some_other_features
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'knows how many features it has - #feature_count' do
|
|
55
|
+
@feature_file.features = [:a_feature]
|
|
56
|
+
@feature_file.feature_count.should == 1
|
|
57
|
+
@feature_file.features = []
|
|
58
|
+
@feature_file.feature_count.should == 0
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'starts with no features' do
|
|
62
|
+
@feature_file.features.should == []
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'contains features' do
|
|
66
|
+
features = [:a_feature]
|
|
67
|
+
everything = features
|
|
68
|
+
|
|
69
|
+
@feature_file.features = features
|
|
70
|
+
|
|
71
|
+
@feature_file.contains.should =~ everything
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'can easily access its sole feature' do
|
|
75
|
+
@feature_file.features = []
|
|
76
|
+
@feature_file.feature.should be_nil
|
|
77
|
+
|
|
78
|
+
@feature_file.features = [:a_feature]
|
|
79
|
+
@feature_file.feature.should == :a_feature
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
SimpleCov.command_name('Feature') unless RUBY_VERSION.to_s < '1.9.0'
|
|
4
|
+
|
|
5
|
+
describe 'Feature, Unit' do
|
|
6
|
+
|
|
7
|
+
clazz = CucumberAnalytics::Feature
|
|
8
|
+
|
|
9
|
+
it_should_behave_like 'a feature element', clazz
|
|
10
|
+
it_should_behave_like 'a nested element', clazz
|
|
11
|
+
it_should_behave_like 'a containing element', clazz
|
|
12
|
+
it_should_behave_like 'a tagged element', clazz
|
|
13
|
+
it_should_behave_like 'a bare bones element', clazz
|
|
14
|
+
it_should_behave_like 'a prepopulated element', clazz
|
|
15
|
+
|
|
16
|
+
before(:each) do
|
|
17
|
+
@feature = clazz.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'can be parsed from stand alone text' do
|
|
21
|
+
source = 'Feature: '
|
|
22
|
+
|
|
23
|
+
expect { clazz.new(source) }.to_not raise_error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'has a background - #background' do
|
|
27
|
+
@feature.should respond_to(:background)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'can get and set its background - #background, #background=' do
|
|
31
|
+
@feature.background = :some_background
|
|
32
|
+
@feature.background.should == :some_background
|
|
33
|
+
@feature.background = :some_other_background
|
|
34
|
+
@feature.background.should == :some_other_background
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'knows whether or not it presently has a background - has_background?' do
|
|
38
|
+
@feature.background = :a_background
|
|
39
|
+
@feature.has_background?.should be_true
|
|
40
|
+
@feature.background = nil
|
|
41
|
+
@feature.has_background?.should be_false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'has tests - #tests' do
|
|
45
|
+
@feature.should respond_to(:tests)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'can get and set its tests - #tests, #tests=' do
|
|
49
|
+
@feature.tests = :some_tests
|
|
50
|
+
@feature.tests.should == :some_tests
|
|
51
|
+
@feature.tests = :some_other_tests
|
|
52
|
+
@feature.tests.should == :some_other_tests
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'knows how many tests it has - #test_count' do
|
|
56
|
+
@feature.tests = []
|
|
57
|
+
@feature.test_count.should == 0
|
|
58
|
+
@feature.tests = [:test_1, :test_2]
|
|
59
|
+
@feature.test_count.should == 2
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'contains backgrounds and tests' do
|
|
63
|
+
tests = [:test_1, :test_2]
|
|
64
|
+
background = :a_background
|
|
65
|
+
everything = [background] + tests
|
|
66
|
+
|
|
67
|
+
@feature.background = background
|
|
68
|
+
@feature.tests = tests
|
|
69
|
+
|
|
70
|
+
@feature.contains.should =~ everything
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'starts with no background' do
|
|
74
|
+
@feature.background.should == nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'starts with no tests' do
|
|
78
|
+
@feature.tests.should == []
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
shared_examples_for 'a nested element' do |clazz|
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@nested_element = clazz.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'has a parent element - #parent_element' do
|
|
10
|
+
@nested_element.should respond_to(:parent_element)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'can get and set its parent element - #parent_element, #parent_element=' do
|
|
14
|
+
@nested_element.parent_element = :some_parent_element
|
|
15
|
+
@nested_element.parent_element.should == :some_parent_element
|
|
16
|
+
@nested_element.parent_element = :some_other_parent_element
|
|
17
|
+
@nested_element.parent_element.should == :some_other_parent_element
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'starts with no parent element' do
|
|
21
|
+
@nested_element.parent_element.should == nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|