jasmine-parser 0.0.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/.gitignore +1 -0
- data/Gemfile +37 -0
- data/LICENSE.txt +29 -0
- data/README.md +118 -0
- data/Rakefile +43 -0
- data/jasmine-parser.gemspec +50 -0
- data/lib/jasmine-parser/announcer.rb +55 -0
- data/lib/jasmine-parser/config.rb +57 -0
- data/lib/jasmine-parser/exceptions.rb +46 -0
- data/lib/jasmine-parser/file_parser.rb +62 -0
- data/lib/jasmine-parser/jasmine_suite.rb +69 -0
- data/lib/jasmine-parser/javascript_object_wrapper.rb +136 -0
- data/lib/jasmine-parser/location_finder.rb +100 -0
- data/lib/jasmine-parser/node_collector.rb +88 -0
- data/lib/jasmine-parser/node_factory.rb +121 -0
- data/lib/jasmine-parser/nodes/example_node.rb +40 -0
- data/lib/jasmine-parser/nodes/function_invocation_node.rb +70 -0
- data/lib/jasmine-parser/nodes/group_node.rb +40 -0
- data/lib/jasmine-parser/nodes/node.rb +120 -0
- data/lib/jasmine-parser/nodes/root_node.rb +40 -0
- data/lib/jasmine-parser/nodes/shared_behavior_decl_node.rb +54 -0
- data/lib/jasmine-parser/nodes/shared_behavior_invoc_node.rb +80 -0
- data/lib/jasmine-parser.rb +53 -0
- data/spec/end_to_end_suite_parser_spec.rb +100 -0
- data/spec/file_parser_spec.rb +68 -0
- data/spec/fixture/spec/call_to_shared_example_in_other_file_spec.js +38 -0
- data/spec/fixture/spec/empty_shared_examples_spec.js +21 -0
- data/spec/fixture/spec/example_spec.js +48 -0
- data/spec/fixture/spec/example_spec_with_strange_spacing.js +48 -0
- data/spec/fixture/spec/multi_declaration_shared_spec.js +26 -0
- data/spec/fixture/spec/not_properly_formatted.js +24 -0
- data/spec/fixture/spec/shared_examples_function_declaration_spec.js +49 -0
- data/spec/fixture/spec/shared_examples_spec.js +43 -0
- data/spec/fixture/spec/small_file.js +5 -0
- data/spec/location_finder_spec.rb +263 -0
- data/spec/node_cloning_spec.rb +123 -0
- data/spec/node_collector_spec.rb +87 -0
- data/spec/node_spec.rb +102 -0
- data/spec/shared_behavior_decl_node_spec.rb +59 -0
- data/spec/shared_behavior_invoc_node_spec.rb +129 -0
- data/spec/shared_examples_for_end_to_end.rb +239 -0
- data/spec/shared_examples_in_new_function_spec.rb +74 -0
- data/spec/shared_examples_spec.rb +71 -0
- data/spec/spec_helper.rb +54 -0
- data/spec/suite_spec.rb +70 -0
- metadata +128 -0
data/spec/node_spec.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Copyright (c) 2013, Groupon, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions
|
6
|
+
# are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of GROUPON nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
20
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
25
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
describe JasmineParser::Node do
|
34
|
+
|
35
|
+
before(:each) do
|
36
|
+
@node_info = {
|
37
|
+
:name => "Node Name",
|
38
|
+
:line => 1,
|
39
|
+
:filename => "foo.txt"
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "Node object" do
|
44
|
+
|
45
|
+
before(:each) do
|
46
|
+
@parent_node = JasmineParser::Node.new @node_info.merge({:name => "Parent Node"})
|
47
|
+
|
48
|
+
@child1 = JasmineParser::Node.new @node_info.merge({:name => "Child 1"})
|
49
|
+
@child2 = JasmineParser::Node.new @node_info.merge({:name => "Child 2"})
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to create a new node with all the info" do
|
54
|
+
node = JasmineParser::Node.new @node_info
|
55
|
+
|
56
|
+
node.name.should == @node_info[:name]
|
57
|
+
node.line.should == @node_info[:line]
|
58
|
+
node.filename.should == @node_info[:filename]
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should accept children nodes" do
|
62
|
+
@parent_node.children << @child1
|
63
|
+
@parent_node.children << @child2
|
64
|
+
|
65
|
+
@parent_node.children.size.should == 2
|
66
|
+
@parent_node.children.first.should == @child1
|
67
|
+
@parent_node.children.last.should == @child2
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should accept a parent node" do
|
71
|
+
child_with_parent = JasmineParser::Node.new @node_info.merge({:parent => @parent_node})
|
72
|
+
child_with_parent.parent.should == @parent_node
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
describe "Node Creation by type" do
|
80
|
+
|
81
|
+
it "should create a root node" do
|
82
|
+
node = JasmineParser::Node.root @node_info
|
83
|
+
node.type.should == :root
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should accept describe nodes" do
|
87
|
+
node = JasmineParser::Node.describe @node_info
|
88
|
+
node.type.should == :group
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should accept context nodes" do
|
92
|
+
node = JasmineParser::Node.context @node_info
|
93
|
+
node.type.should == :group
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should accept it nodes" do
|
97
|
+
node = JasmineParser::Node.it @node_info
|
98
|
+
node.type.should == :it
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2013, Groupon, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions
|
6
|
+
# are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of GROUPON nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
20
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
25
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
describe JasmineParser::SharedBehaviorDeclaration do
|
34
|
+
|
35
|
+
|
36
|
+
before(:each) do
|
37
|
+
@parent_node = JasmineParser::Node.describe({:name => "parent", :line => 1})
|
38
|
+
|
39
|
+
@shared_node = JasmineParser::Node.shared_behavior_declaration({:name => "shared node", :parent => @parent_node})
|
40
|
+
|
41
|
+
@parent_node.children << JasmineParser::Node.it({:name => "old child 1", :parent => @parent_node})
|
42
|
+
@parent_node.children << @shared_node
|
43
|
+
@parent_node.children << JasmineParser::Node.it({:name => "old child 3", :parent => @parent_node})
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not be in the children count for parent" do
|
48
|
+
@parent_node.children.size.should == 3
|
49
|
+
@shared_node.delete!
|
50
|
+
@parent_node.children.size.should == 2
|
51
|
+
@parent_node.children.include?(@shared_node).should == false
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not reference parent anymore" do
|
55
|
+
@shared_node.delete!
|
56
|
+
@shared_node.parent.should == nil
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Copyright (c) 2013, Groupon, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions
|
6
|
+
# are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of GROUPON nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
20
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
25
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
describe JasmineParser::SharedBehaviorInvocation do
|
34
|
+
|
35
|
+
before(:each) do
|
36
|
+
@parent_node = JasmineParser::Node.describe({:name => "parent", :line => 1})
|
37
|
+
|
38
|
+
|
39
|
+
@shared_invocation = JasmineParser::Node.shared_behavior_invocation({:name => "shared",
|
40
|
+
:line => 3,
|
41
|
+
:parent => @parent_node})
|
42
|
+
|
43
|
+
@parent_node.children << JasmineParser::Node.it({:name => "old child 1", :parent => @parent_node})
|
44
|
+
@parent_node.children << @shared_invocation
|
45
|
+
@parent_node.children << JasmineParser::Node.it({:name => "old child 3", :parent => @parent_node})
|
46
|
+
|
47
|
+
@parent_to_inherit_from = JasmineParser::Node.describe({:name => "other parent", :line => 1})
|
48
|
+
|
49
|
+
|
50
|
+
@new_children = [
|
51
|
+
JasmineParser::Node.describe({:name => "new child 1", :line => 2, :parent => @parent_to_inherit_from}),
|
52
|
+
JasmineParser::Node.context({:name => "new child 2", :line => 4, :parent => @parent_to_inherit_from}),
|
53
|
+
JasmineParser::Node.describe({:name => "new child 3", :line => 6, :parent => @parent_to_inherit_from}),
|
54
|
+
JasmineParser::Node.describe({:name => "new child 4", :line => 8, :parent => @parent_to_inherit_from})
|
55
|
+
]
|
56
|
+
|
57
|
+
@parent_to_inherit_from.children = @new_children
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe "inheriting children" do
|
62
|
+
|
63
|
+
context "exception handling" do
|
64
|
+
it "should only accept nodes as arguments" do
|
65
|
+
expect {@shared_invocation.adopt_children({})}.to raise_error JasmineParser::UnsupportedObjectType
|
66
|
+
expect {@shared_invocation.adopt_children([])}.to raise_error JasmineParser::UnsupportedObjectType
|
67
|
+
expect {@shared_invocation.adopt_children("")}.to raise_error JasmineParser::UnsupportedObjectType
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "cloning children" do
|
72
|
+
before(:each) do
|
73
|
+
@shared_invocation.adopt_children @parent_to_inherit_from
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should not set name to blank after inheriting" do
|
77
|
+
@shared_invocation.name.should == "shared"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have nil in formatted name" do
|
81
|
+
@shared_invocation.formatted_name.should == nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should inherit the children of another node" do
|
85
|
+
@shared_invocation.children.size.should == 4
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should copy the names of all children properly" do
|
89
|
+
@shared_invocation.children[0].name.should == "new child 1"
|
90
|
+
@shared_invocation.children[1].name.should == "new child 2"
|
91
|
+
@shared_invocation.children[2].name.should == "new child 3"
|
92
|
+
@shared_invocation.children[3].name.should == "new child 4"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should copy the lines of all children properly" do
|
96
|
+
@shared_invocation.children[0].line.should == 2
|
97
|
+
@shared_invocation.children[1].line.should == 4
|
98
|
+
@shared_invocation.children[2].line.should == 6
|
99
|
+
@shared_invocation.children[3].line.should == 8
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should adjust the parent for all of the inherited children" do
|
103
|
+
@shared_invocation.children[0].parent.should == @shared_invocation
|
104
|
+
@shared_invocation.children[1].parent.should == @shared_invocation
|
105
|
+
@shared_invocation.children[2].parent.should == @shared_invocation
|
106
|
+
@shared_invocation.children[3].parent.should == @shared_invocation
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should be able to reach new children from parent" do
|
110
|
+
@parent_node.children[1].children[0].name.should == "new child 1"
|
111
|
+
@parent_node.children[1].children[1].name.should == "new child 2"
|
112
|
+
@parent_node.children[1].children[2].name.should == "new child 3"
|
113
|
+
@parent_node.children[1].children[3].name.should == "new child 4"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should be able to reach parent from new children" do
|
117
|
+
children = @shared_invocation.children
|
118
|
+
children[0].parent.parent.should == @parent_node
|
119
|
+
children[1].parent.parent.should == @parent_node
|
120
|
+
children[2].parent.parent.should == @parent_node
|
121
|
+
children[3].parent.parent.should == @parent_node
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
# Copyright (c) 2013, Groupon, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions
|
6
|
+
# are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of GROUPON nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
20
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
25
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
shared_examples "node info tests" do
|
32
|
+
|
33
|
+
it "should contain correct node name" do
|
34
|
+
@node.name.should == @node_name
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should correct type" do
|
38
|
+
@node.type.should == @node_type
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should start on correct line" do
|
42
|
+
@node.line.should == @node_line
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not have correct parent" do
|
46
|
+
@node.parent.should == @node_parent
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have correct filename" do
|
50
|
+
@node.filename.should == @node_filename
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have correct children nodes" do
|
54
|
+
@node.children.size.should == @node_children_count
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
shared_examples "node children tests" do
|
60
|
+
it "should have correct name for children nodes" do
|
61
|
+
|
62
|
+
@node.children.each_with_index do |child, index|
|
63
|
+
child.name.should == @children[index]
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
shared_examples "In depth tests of nodes" do
|
70
|
+
it "should suite should contain only 1 spec_file" do
|
71
|
+
@suite.spec_files.size.should == @file_count
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "root node" do
|
75
|
+
before(:each) do
|
76
|
+
@node = @suite.spec_files.first
|
77
|
+
|
78
|
+
@node_name = ""
|
79
|
+
@node_type = :root
|
80
|
+
@node_line = 0
|
81
|
+
@node_parent = nil
|
82
|
+
@node_filename = @filename
|
83
|
+
@node_children_count = 3
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
it_behaves_like "node info tests"
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
describe "example_spec node" do
|
92
|
+
before(:each) do
|
93
|
+
@node = @suite.spec_files.first.children.first
|
94
|
+
@node_name = "example_spec"
|
95
|
+
@node_type = :group
|
96
|
+
@node_line = 1
|
97
|
+
@node_parent = @suite.spec_files.first
|
98
|
+
@node_filename = @filename
|
99
|
+
@node_children_count = 3
|
100
|
+
|
101
|
+
@children = ["should be here for path loading tests", "nested_groups", "context group"]
|
102
|
+
end
|
103
|
+
|
104
|
+
it_behaves_like "node info tests"
|
105
|
+
it_behaves_like "node children tests"
|
106
|
+
|
107
|
+
describe "it node" do
|
108
|
+
before(:each) do
|
109
|
+
@node = @suite.spec_files.first.children.first.children.first
|
110
|
+
@node_name = "should be here for path loading tests"
|
111
|
+
@node_type = :it
|
112
|
+
@node_line = 2
|
113
|
+
@node_parent = @suite.spec_files.first.children.first
|
114
|
+
@node_filename = @filename
|
115
|
+
@node_children_count = 1
|
116
|
+
end
|
117
|
+
it_behaves_like "node info tests"
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "nested_group" do
|
121
|
+
before(:each) do
|
122
|
+
@node = @suite.spec_files.first.children.first.children[1]
|
123
|
+
@node_name = "nested_groups"
|
124
|
+
@node_type = :group
|
125
|
+
@node_line = 6
|
126
|
+
@node_parent = @suite.spec_files.first.children.first
|
127
|
+
@node_filename = @filename
|
128
|
+
@node_children_count = 1
|
129
|
+
|
130
|
+
@children = ["should contain the full name of nested example"]
|
131
|
+
end
|
132
|
+
it_behaves_like "node info tests"
|
133
|
+
it_behaves_like "node children tests"
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "context group" do
|
137
|
+
before(:each) do
|
138
|
+
@node = @suite.spec_files.first.children.first.children[2]
|
139
|
+
@node_name = "context group"
|
140
|
+
@node_type = :group
|
141
|
+
@node_line = 12
|
142
|
+
@node_parent = @suite.spec_files.first.children.first
|
143
|
+
@node_filename = @filename
|
144
|
+
@node_children_count = 1
|
145
|
+
|
146
|
+
@children = ["nested group in context"]
|
147
|
+
end
|
148
|
+
it_behaves_like "node info tests"
|
149
|
+
it_behaves_like "node children tests"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "example with return" do
|
154
|
+
before(:each) do
|
155
|
+
@node = @suite.spec_files.first.children[1]
|
156
|
+
@node_name = "example with return"
|
157
|
+
@node_type = :group
|
158
|
+
@node_line = 21
|
159
|
+
@node_parent = @suite.spec_files.first
|
160
|
+
@node_filename = @filename
|
161
|
+
@node_children_count = 1
|
162
|
+
|
163
|
+
@children = ["return example_spec"]
|
164
|
+
end
|
165
|
+
|
166
|
+
it_behaves_like "node info tests"
|
167
|
+
it_behaves_like "node children tests"
|
168
|
+
|
169
|
+
describe "return group" do
|
170
|
+
before(:each) do
|
171
|
+
@node = @suite.spec_files.first.children[1].children.first
|
172
|
+
@node_name = "return example_spec"
|
173
|
+
@node_type = :group
|
174
|
+
@node_line = 22
|
175
|
+
@node_parent = @suite.spec_files.first.children[1]
|
176
|
+
@node_filename = @filename
|
177
|
+
@node_children_count = 2
|
178
|
+
|
179
|
+
@children = ["should have example name with return upfront", "return context"]
|
180
|
+
end
|
181
|
+
|
182
|
+
it_behaves_like "node info tests"
|
183
|
+
it_behaves_like "node children tests"
|
184
|
+
|
185
|
+
describe "return it" do
|
186
|
+
before(:each) do
|
187
|
+
@node = @suite.spec_files.first.children[1].children.first.children.first
|
188
|
+
@node_name = "should have example name with return upfront"
|
189
|
+
@node_type = :it
|
190
|
+
@node_line = 23
|
191
|
+
@node_parent = @suite.spec_files.first.children[1].children.first
|
192
|
+
@node_filename = @filename
|
193
|
+
@node_children_count = 1
|
194
|
+
end
|
195
|
+
|
196
|
+
it_behaves_like "node info tests"
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "return context" do
|
200
|
+
before(:each) do
|
201
|
+
@node = @suite.spec_files.first.children[1].children.first.children.last
|
202
|
+
@node_name = "return context"
|
203
|
+
@node_type = :group
|
204
|
+
@node_line = 27
|
205
|
+
@node_parent = @suite.spec_files.first.children[1].children.first
|
206
|
+
@node_filename = @filename
|
207
|
+
@node_children_count = 1
|
208
|
+
|
209
|
+
@children = ["group inside return context"]
|
210
|
+
end
|
211
|
+
|
212
|
+
it_behaves_like "node info tests"
|
213
|
+
it_behaves_like "node children tests"
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "root context" do
|
220
|
+
before(:each) do
|
221
|
+
@node = @suite.spec_files.first.children.last
|
222
|
+
@node_name = "root context"
|
223
|
+
@node_type = :group
|
224
|
+
@node_line = 37
|
225
|
+
@node_parent = @suite.spec_files.first
|
226
|
+
@node_filename = @filename
|
227
|
+
@node_children_count = 1
|
228
|
+
|
229
|
+
@children = ["nested_group in context"]
|
230
|
+
end
|
231
|
+
|
232
|
+
it_behaves_like "node info tests"
|
233
|
+
it_behaves_like "node children tests"
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright (c) 2013, Groupon, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions
|
6
|
+
# are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of GROUPON nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
20
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
25
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
require 'spec_helper'
|
32
|
+
require 'shared_examples_for_end_to_end'
|
33
|
+
|
34
|
+
describe JasmineParser::FileParser do
|
35
|
+
before(:each) do
|
36
|
+
@suite = JasmineParser::JasmineSuite.new
|
37
|
+
@parser = JasmineParser::FileParser.new(@suite)
|
38
|
+
@filename = "spec/fixture/spec/shared_examples_function_declaration_spec.js"
|
39
|
+
@parser.parse ["spec/fixture/spec/shared_examples_function_declaration_spec.js"]
|
40
|
+
@file = @suite.spec_files.first
|
41
|
+
@invocation_node = @file.children.first.children.first.children.first
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
describe "shared examples declared in a function" do
|
46
|
+
|
47
|
+
describe "parsing of the file" do
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
it "should move the shared function declaration to invocation node" do
|
52
|
+
@invocation_node.name.should == "group 2"
|
53
|
+
@invocation_node.type.should == :group
|
54
|
+
@invocation_node.line.should == 29
|
55
|
+
@invocation_node.children.first.name.should == "sharedBehaviorInFunction"
|
56
|
+
@invocation_node.children.first.children.size.should == 1
|
57
|
+
@invocation_node.children.first.children.first.name.should == "(shared)"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should not have any decoy functions" do
|
61
|
+
@file.children.size.should == 1
|
62
|
+
@file.children.last.name.should == "shared example declared in new function"
|
63
|
+
|
64
|
+
@file.children.first.children.first.children.size.should == 2
|
65
|
+
|
66
|
+
@file.children.first.children.first.children.first.name.should == "group 2"
|
67
|
+
@file.children.first.children.first.children.last.name.should == "group 3"
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (c) 2013, Groupon, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions
|
6
|
+
# are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of GROUPON nor the names of its contributors may be
|
16
|
+
# used to endorse or promote products derived from this software without
|
17
|
+
# specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
20
|
+
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
21
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
25
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
26
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
27
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
describe JasmineParser::FileParser do
|
34
|
+
before(:each) do
|
35
|
+
@suite = JasmineParser::JasmineSuite.new
|
36
|
+
@parser = JasmineParser::FileParser.new(@suite)
|
37
|
+
@parser.parse ["spec/fixture/spec/shared_examples_spec.js"]
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
describe "globally shared behavior" do
|
42
|
+
before(:each) do
|
43
|
+
@invocation_node = @suite.spec_files.first.children.first.children.last
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "declaration" do
|
47
|
+
|
48
|
+
it "should delete the declaration node" do
|
49
|
+
@suite.spec_files.first.children.first.children.first.type.should_not == :shared_behavior_declaration
|
50
|
+
@suite.spec_files.first.children.first.children.size.should == 1
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "invocation" do
|
56
|
+
it "should have the correct type" do
|
57
|
+
@invocation_node.type.should == :shared_behavior_invocation
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should be named correctly" do
|
61
|
+
@invocation_node.name.should == "shared example on window"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should have 2 children" do
|
65
|
+
@invocation_node.children.size.should == 2
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|