druid-s 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 +7 -0
- data/.gitignore +7 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +27 -0
- data/ChangeLog +541 -0
- data/Gemfile +8 -0
- data/README.md +78 -0
- data/Rakefile +33 -0
- data/cucumber.yml +6 -0
- data/druid.gemspec +30 -0
- data/features/area.feature +33 -0
- data/features/async.feature +16 -0
- data/features/audio.feature +61 -0
- data/features/bold.feature +20 -0
- data/features/button.feature +81 -0
- data/features/canvas.feature +34 -0
- data/features/checkbox.feature +48 -0
- data/features/div.feature +45 -0
- data/features/element.feature +281 -0
- data/features/file_field.feature +38 -0
- data/features/form.feature +37 -0
- data/features/frames.feature +76 -0
- data/features/generic_elements.feature +29 -0
- data/features/heading.feature +160 -0
- data/features/hidden_field.feature +39 -0
- data/features/html/async.html +31 -0
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frame_3.html +14 -0
- data/features/html/frames.html +12 -0
- data/features/html/hover.html +11 -0
- data/features/html/iframes.html +12 -0
- data/features/html/images/circle.png +0 -0
- data/features/html/images/img_pulpit.jpg +0 -0
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/html/multi_elements.html +145 -0
- data/features/html/nested_elements.html +75 -0
- data/features/html/nested_frame_1.html +1 -0
- data/features/html/nested_frame_2.html +11 -0
- data/features/html/nested_frame_3.html +14 -0
- data/features/html/nested_frames.html +10 -0
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +203 -0
- data/features/html/success.html +8 -0
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +7 -0
- data/features/image.feature +47 -0
- data/features/italic.feature +20 -0
- data/features/javascript.feature +28 -0
- data/features/label.feature +43 -0
- data/features/link.feature +56 -0
- data/features/list_item.feature +37 -0
- data/features/modal_dialog.feature +9 -0
- data/features/multi_elements.feature +498 -0
- data/features/nested_elements.feature +121 -0
- data/features/ordered_list.feature +46 -0
- data/features/page_level_actions.feature +116 -0
- data/features/paragraph.feature +33 -0
- data/features/populate_page_with.feature +25 -0
- data/features/radio_button.feature +51 -0
- data/features/radio_button_group.feature +28 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
- data/features/sample-app/public/audio_video.html +19 -0
- data/features/sample-app/public/jquery-1.3.2.js +4376 -0
- data/features/sample-app/public/jquery.html +28 -0
- data/features/sample-app/public/movie.mp4 +0 -0
- data/features/sample-app/public/movie.ogg +0 -0
- data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/features/sample-app/public/prototype.html +32 -0
- data/features/sample-app/sample_app.rb +35 -0
- data/features/section.feature +132 -0
- data/features/select_list.feature +84 -0
- data/features/span.feature +43 -0
- data/features/step_definations/area_steps.rb +23 -0
- data/features/step_definations/async_steps.rb +80 -0
- data/features/step_definations/audio_steps.rb +47 -0
- data/features/step_definations/bold_steps.rb +11 -0
- data/features/step_definations/button_steps.rb +52 -0
- data/features/step_definations/canvas_steps.rb +19 -0
- data/features/step_definations/checkbox_steps.rb +39 -0
- data/features/step_definations/div_steps.rb +28 -0
- data/features/step_definations/element_steps.rb +217 -0
- data/features/step_definations/file_field_steps.rb +31 -0
- data/features/step_definations/form_steps.rb +23 -0
- data/features/step_definations/frame_steps.rb +189 -0
- data/features/step_definations/generic_element_steps.rb +31 -0
- data/features/step_definations/heading_steps.rb +39 -0
- data/features/step_definations/hidden_field_steps.rb +27 -0
- data/features/step_definations/image_steps.rb +35 -0
- data/features/step_definations/italic_steps.rb +11 -0
- data/features/step_definations/javasript_steps.rb +52 -0
- data/features/step_definations/label_steps.rb +19 -0
- data/features/step_definations/link_steps.rb +42 -0
- data/features/step_definations/list_item_steps.rb +24 -0
- data/features/step_definations/modal_dialog_steps.rb +38 -0
- data/features/step_definations/multi_elements_steps.rb +557 -0
- data/features/step_definations/nested_elements_steps.rb +219 -0
- data/features/step_definations/ordered_list_steps.rb +49 -0
- data/features/step_definations/page_level_actions_steps.rb +172 -0
- data/features/step_definations/page_traversal_steps.rb +4 -0
- data/features/step_definations/paragraph_steps.rb +19 -0
- data/features/step_definations/populate_page_with_steps.rb +3 -0
- data/features/step_definations/radio_button_group_steps.rb +32 -0
- data/features/step_definations/radio_button_steps.rb +31 -0
- data/features/step_definations/section_steps.rb +271 -0
- data/features/step_definations/select_list_steps.rb +91 -0
- data/features/step_definations/span_steps.rb +23 -0
- data/features/step_definations/table_cell_steps.rb +27 -0
- data/features/step_definations/table_row_steps.rb +23 -0
- data/features/step_definations/table_steps.rb +109 -0
- data/features/step_definations/text_area_steps.rb +39 -0
- data/features/step_definations/text_field_steps.rb +39 -0
- data/features/step_definations/unordered_list_steps.rb +27 -0
- data/features/step_definations/video_steps.rb +27 -0
- data/features/support/ajax_test_environment.rb +26 -0
- data/features/support/audio_video_page.rb +23 -0
- data/features/support/env.rb +5 -0
- data/features/support/hooks.rb +3 -0
- data/features/support/page.rb +372 -0
- data/features/support/persistent_browser.rb +58 -0
- data/features/support/targets/firefox14_osx.rb +5 -0
- data/features/support/targets/firefox14_windows7.rb +5 -0
- data/features/support/url_helper.rb +50 -0
- data/features/table.feature +127 -0
- data/features/table_cell.feature +42 -0
- data/features/table_row.feature +30 -0
- data/features/text_area.feature +44 -0
- data/features/text_field.feature +53 -0
- data/features/unordered_list.feature +46 -0
- data/features/video.feature +66 -0
- data/lib/druid/accessors.rb +1082 -0
- data/lib/druid/assist.rb +653 -0
- data/lib/druid/element_locators.rb +21 -0
- data/lib/druid/elements/area.rb +9 -0
- data/lib/druid/elements/audio.rb +9 -0
- data/lib/druid/elements/bold.rb +8 -0
- data/lib/druid/elements/button.rb +12 -0
- data/lib/druid/elements/canvas.rb +9 -0
- data/lib/druid/elements/check_box.rb +9 -0
- data/lib/druid/elements/div.rb +9 -0
- data/lib/druid/elements/element.rb +187 -0
- data/lib/druid/elements/file_field.rb +9 -0
- data/lib/druid/elements/form.rb +9 -0
- data/lib/druid/elements/heading.rb +14 -0
- data/lib/druid/elements/hidden_field.rb +9 -0
- data/lib/druid/elements/image.rb +9 -0
- data/lib/druid/elements/italic.rb +9 -0
- data/lib/druid/elements/label.rb +8 -0
- data/lib/druid/elements/link.rb +9 -0
- data/lib/druid/elements/list_item.rb +9 -0
- data/lib/druid/elements/media.rb +11 -0
- data/lib/druid/elements/option.rb +9 -0
- data/lib/druid/elements/ordered_list.rb +29 -0
- data/lib/druid/elements/paragraph.rb +9 -0
- data/lib/druid/elements/radio_button.rb +9 -0
- data/lib/druid/elements/select_list.rb +30 -0
- data/lib/druid/elements/span.rb +9 -0
- data/lib/druid/elements/table.rb +92 -0
- data/lib/druid/elements/table_cell.rb +11 -0
- data/lib/druid/elements/table_row.rb +50 -0
- data/lib/druid/elements/text_area.rb +10 -0
- data/lib/druid/elements/text_field.rb +11 -0
- data/lib/druid/elements/unordered_list.rb +32 -0
- data/lib/druid/elements/video.rb +8 -0
- data/lib/druid/elements.rb +55 -0
- data/lib/druid/javascript/angularjs.rb +12 -0
- data/lib/druid/javascript/jquery.rb +12 -0
- data/lib/druid/javascript/prototype.rb +12 -0
- data/lib/druid/javascript/yui.rb +19 -0
- data/lib/druid/javascript_framework_facade.rb +76 -0
- data/lib/druid/locator_generator.rb +181 -0
- data/lib/druid/nested_elements.rb +56 -0
- data/lib/druid/page_factory.rb +115 -0
- data/lib/druid/page_populator.rb +104 -0
- data/lib/druid/section_collection.rb +17 -0
- data/lib/druid/version.rb +3 -0
- data/lib/druid.rb +452 -0
- data/spec/druid/accessors_spec.rb +1209 -0
- data/spec/druid/druid_spec.rb +295 -0
- data/spec/druid/element_locators_spec.rb +750 -0
- data/spec/druid/elements/bold_spec.rb +12 -0
- data/spec/druid/elements/button_spec.rb +23 -0
- data/spec/druid/elements/check_box_spec.rb +14 -0
- data/spec/druid/elements/div_spec.rb +10 -0
- data/spec/druid/elements/element_spec.rb +250 -0
- data/spec/druid/elements/file_field_spec.rb +13 -0
- data/spec/druid/elements/form_spec.rb +18 -0
- data/spec/druid/elements/heading_spec.rb +30 -0
- data/spec/druid/elements/hidden_field_spec.rb +10 -0
- data/spec/druid/elements/image_spec.rb +23 -0
- data/spec/druid/elements/itatic_spec.rb +11 -0
- data/spec/druid/elements/label_spec.rb +10 -0
- data/spec/druid/elements/link_spec.rb +10 -0
- data/spec/druid/elements/list_item_spec.rb +10 -0
- data/spec/druid/elements/media_spec.rb +12 -0
- data/spec/druid/elements/option_spec.rb +21 -0
- data/spec/druid/elements/ordered_list_spec.rb +38 -0
- data/spec/druid/elements/page_factory_spec.rb +40 -0
- data/spec/druid/elements/paragraph_spec.rb +12 -0
- data/spec/druid/elements/radio_button_spec.rb +14 -0
- data/spec/druid/elements/select_list_spec.rb +51 -0
- data/spec/druid/elements/span_spec.rb +10 -0
- data/spec/druid/elements/table_cell_spec.rb +14 -0
- data/spec/druid/elements/table_row_spec.rb +34 -0
- data/spec/druid/elements/table_spec.rb +47 -0
- data/spec/druid/elements/text_area_spec.rb +13 -0
- data/spec/druid/elements/text_field_spec.rb +22 -0
- data/spec/druid/elements/unordered_list_spec.rb +39 -0
- data/spec/druid/javascript_framework_facade_spec.rb +59 -0
- data/spec/druid/nested_element_spec.rb +128 -0
- data/spec/druid/page_factory_spec.rb +235 -0
- data/spec/druid/page_populator_spec.rb +173 -0
- data/spec/druid/page_section_spec.rb +70 -0
- data/spec/spec_helper.rb +9 -0
- metadata +517 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
class Section
|
|
4
|
+
include Druid
|
|
5
|
+
|
|
6
|
+
text_field(:stf, id: 'id')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class DruidPagePopulator
|
|
10
|
+
include Druid
|
|
11
|
+
|
|
12
|
+
text_field(:tf, :id => 'id')
|
|
13
|
+
text_area(:ta, :id => 'id')
|
|
14
|
+
select_list(:sl, :id => 'id')
|
|
15
|
+
checkbox(:cb, :id => 'id')
|
|
16
|
+
radio_button(:rb, :id => 'id')
|
|
17
|
+
file_field(:ff, :id => 'id')
|
|
18
|
+
radio_button_group(:rbg, :id => 'id')
|
|
19
|
+
page_section(:section, Section, id: 'foo')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe Druid::PagePopulator do
|
|
23
|
+
let(:driver) { mock_driver }
|
|
24
|
+
let(:druid) { DruidPagePopulator.new(driver) }
|
|
25
|
+
|
|
26
|
+
it "should accept any object that can be converted to a Hash" do
|
|
27
|
+
os = OpenStruct.new('tf' => 'value', 'sl' => 'value')
|
|
28
|
+
expect(druid).to receive(:tf=).with('value')
|
|
29
|
+
expect(druid).to receive(:sl=).with('value')
|
|
30
|
+
|
|
31
|
+
allow(druid).to receive(:is_enabled?).and_return(true)
|
|
32
|
+
druid.populate_page_with(os)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should set a value in a text field" do
|
|
36
|
+
expect(druid).to receive(:tf=).with('value')
|
|
37
|
+
expect(druid).to receive(:is_enabled?).and_return(true)
|
|
38
|
+
druid.populate_page_with('tf' => 'value')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should not set a value if it is not found on the page" do
|
|
42
|
+
expect(druid).not_to receive(:text_field)
|
|
43
|
+
druid.populate_page_with('coffee' => 'value')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should not populate a text field when it is not visible" do
|
|
47
|
+
expect(druid).not_to receive(:tf=)
|
|
48
|
+
expect(druid).to receive(:tf_element).twice.and_return(driver)
|
|
49
|
+
expect(driver).to receive(:enabled?).and_return(true)
|
|
50
|
+
expect(driver).to receive(:present?).and_return(false)
|
|
51
|
+
expect(driver).to receive(:tag_name).and_return('input')
|
|
52
|
+
druid.populate_page_with('tf' => true)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should set a value in a text area" do
|
|
56
|
+
expect(druid).to receive(:ta=).with('value')
|
|
57
|
+
expect(druid).to receive(:ta_element).and_return(driver)
|
|
58
|
+
expect(driver).to receive(:tag_name).and_return('textarea')
|
|
59
|
+
druid.populate_page_with('ta' => 'value')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should set a value in a select list" do
|
|
63
|
+
expect(druid).to receive(:sl=).with('value')
|
|
64
|
+
druid.populate_page_with('sl' => 'value')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should set a value in a file field" do
|
|
68
|
+
expect(druid).to receive(:ff=).with('value')
|
|
69
|
+
expect(druid).to receive(:is_enabled?).and_return(true)
|
|
70
|
+
druid.populate_page_with('ff' => 'value')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should check a checkbox to true is specified" do
|
|
74
|
+
expect(druid).to receive(:check_cb)
|
|
75
|
+
expect(druid).to receive(:is_enabled?).and_return(true)
|
|
76
|
+
druid.populate_page_with('cb' => true)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should uncheck a checkbox to false is specified" do
|
|
80
|
+
expect(druid).to receive(:uncheck_cb)
|
|
81
|
+
expect(druid).to receive(:is_enabled?).and_return(true)
|
|
82
|
+
druid.populate_page_with('cb' => false)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should select a radio button when true is specified" do
|
|
86
|
+
expect(druid).to receive(:select_rb)
|
|
87
|
+
expect(druid).to receive(:is_enabled?).and_return(true)
|
|
88
|
+
druid.populate_page_with('rb' => true)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should select the correct element from a radio button group" do
|
|
92
|
+
expect(druid).to receive(:select_rbg).with('blah')
|
|
93
|
+
druid.populate_page_with('rbg' => 'blah')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "should not populate a checkbox if it is disabled" do
|
|
97
|
+
expect(druid).not_to receive(:check_cb)
|
|
98
|
+
expect(druid).to receive(:cb_element).twice.and_return(driver)
|
|
99
|
+
expect(driver).to receive(:enabled?).and_return(false)
|
|
100
|
+
expect(driver).to receive(:tag_name).and_return('input')
|
|
101
|
+
druid.populate_page_with('cb' => true)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should not populate a checkbox if it is not visible" do
|
|
105
|
+
expect(druid).not_to receive(:check_cb)
|
|
106
|
+
expect(druid).to receive(:cb_element).twice.and_return(driver)
|
|
107
|
+
expect(driver).to receive(:enabled?).and_return(true)
|
|
108
|
+
expect(driver).to receive(:present?).and_return(false)
|
|
109
|
+
expect(driver).to receive(:tag_name).and_return('input')
|
|
110
|
+
druid.populate_page_with('cb' => true)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "should not populate a radio button when it is disabled" do
|
|
114
|
+
expect(druid).not_to receive(:select_rb)
|
|
115
|
+
expect(druid).to receive(:rb_element).twice.and_return(driver)
|
|
116
|
+
expect(driver).to receive(:enabled?).and_return(false)
|
|
117
|
+
expect(driver).to receive(:tag_name).and_return('input')
|
|
118
|
+
druid.populate_page_with('rb' => true)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "should not populate a text field when it is disabled" do
|
|
122
|
+
expect(druid).not_to receive(:tf=)
|
|
123
|
+
expect(druid).to receive(:tf_element).twice.and_return(driver)
|
|
124
|
+
expect(driver).to receive(:enabled?).and_return(false)
|
|
125
|
+
expect(driver).to receive(:tag_name).and_return("input")
|
|
126
|
+
druid.populate_page_with('tf' => 'test')
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should not populate a radio button when it is not visible" do
|
|
130
|
+
expect(druid).not_to receive(:select_rb)
|
|
131
|
+
expect(druid).to receive(:rb_element).twice.and_return(driver)
|
|
132
|
+
expect(driver).to receive(:enabled?).and_return(true)
|
|
133
|
+
expect(driver).to receive(:present?).and_return(false)
|
|
134
|
+
expect(driver).to receive(:tag_name).and_return('input')
|
|
135
|
+
druid.populate_page_with('rb' => true)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
context "when using a nested for a section" do
|
|
139
|
+
let(:section) { double('section') }
|
|
140
|
+
|
|
141
|
+
before do
|
|
142
|
+
allow(druid).to receive(:section).and_return section
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should populate a page section when the value is a hash and it exists" do
|
|
146
|
+
expect(section).to receive(:stf=).with('value')
|
|
147
|
+
expect(druid).to receive(:is_enabled?).and_return(true)
|
|
148
|
+
druid.populate_page_with('section' => {'stf' => 'value'})
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "populate a page section when the value repsonds to #to_h and it exists" do
|
|
152
|
+
os = OpenStruct.new('tf' => 'value', 'sl' => 'value')
|
|
153
|
+
expect(section).to receive(:tf=).with('value')
|
|
154
|
+
expect(section).to receive(:sl=).with('value')
|
|
155
|
+
|
|
156
|
+
allow(druid).to receive(:is_enabled?).twice.and_return(true)
|
|
157
|
+
druid.populate_page_with('section' => os)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should not set a value in a text field if it is not found on the page" do
|
|
161
|
+
expect(section).not_to receive(:text_field)
|
|
162
|
+
druid.populate_page_with('section' => {'coffee' => 'value'})
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it "should not populate a text field when it is disabled" do
|
|
166
|
+
expect(section).not_to receive(:stf=)
|
|
167
|
+
expect(section).to receive(:stf_element).twice.and_return(driver)
|
|
168
|
+
expect(driver).to receive(:enabled?).and_return(false)
|
|
169
|
+
expect(driver).to receive(:tag_name).and_return('input')
|
|
170
|
+
druid.populate_page_with('section' => {'stf' => true})
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
class Container
|
|
4
|
+
include Druid
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class SectionsPage
|
|
8
|
+
include Druid
|
|
9
|
+
|
|
10
|
+
page_section(:container, Container, :id => 'blah')
|
|
11
|
+
page_sections(:containers, Container, :class => 'foo')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe Druid::Accessors do
|
|
15
|
+
context "when using watir" do
|
|
16
|
+
let(:driver) { mock_driver }
|
|
17
|
+
let(:druid) { SectionsPage.new(driver) }
|
|
18
|
+
|
|
19
|
+
it "it should find a page section" do
|
|
20
|
+
expect(driver).to receive(:element).with(:id => 'blah').and_return(driver)
|
|
21
|
+
section = druid.container
|
|
22
|
+
expect(section).to be_instance_of Container
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "it should find page sections" do
|
|
26
|
+
expect(driver).to receive(:elements).with(:class => 'foo').and_return([driver, driver])
|
|
27
|
+
sections = druid.containers
|
|
28
|
+
expect(sections).to be_instance_of Druid::SectionCollection
|
|
29
|
+
sections.each do |section|
|
|
30
|
+
expect(section).to be_instance_of Container
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe Druid::SectionCollection do
|
|
36
|
+
ContainedItem = Struct.new(:type, :name)
|
|
37
|
+
let(:section_collection) do
|
|
38
|
+
contained_items = [ContainedItem.new(:sandwich, :reuben), ContainedItem.new(:soup, :lobstar_bisque), ContainedItem.new(:sandwich, :dagwood)]
|
|
39
|
+
Druid::SectionCollection[*contained_items]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should inherit from Array" do
|
|
43
|
+
expect(Druid::SectionCollection.superclass).to eq Array
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should have functioning array methods" do
|
|
47
|
+
expect(section_collection.methods).to include *Array.instance_methods
|
|
48
|
+
expect(section_collection.last.type).to eq :sandwich
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should be indexed to the sections" do
|
|
52
|
+
expect(section_collection[0]).to be_an_instance_of ContainedItem
|
|
53
|
+
expect(section_collection[-1]).to be_an_instance_of ContainedItem
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should be able to iterate over the sections" do
|
|
57
|
+
section_collection.each do |section|
|
|
58
|
+
expect(section).to be_an_instance_of ContainedItem
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should find a section by one of its values" do
|
|
63
|
+
expect(section_collection.find_by(name: :dagwood).name).to eq :dagwood
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should find all sections matching a value" do
|
|
67
|
+
expect(section_collection.select_by(type: :sandwich).map(&:type)).to eq [:sandwich, :sandwich]
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
data/spec/spec_helper.rb
ADDED