fluent 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +21 -0
  3. data/lib/fluent.rb +29 -2
  4. data/lib/fluent/enclosers.rb +35 -0
  5. data/lib/fluent/evaluators.rb +82 -0
  6. data/lib/fluent/factory.rb +31 -0
  7. data/lib/fluent/generators.rb +116 -18
  8. data/lib/fluent/platform_selenium.rb +18 -0
  9. data/lib/fluent/platform_selenium/platform_object.rb +21 -0
  10. data/lib/fluent/platform_watir/platform_object.rb +181 -14
  11. data/lib/fluent/platform_watir/platform_web_elements/checkbox.rb +21 -0
  12. data/lib/fluent/platform_watir/platform_web_elements/radio.rb +21 -0
  13. data/lib/fluent/platform_watir/platform_web_elements/select_list.rb +30 -4
  14. data/lib/fluent/platform_watir/platform_web_elements/text_field.rb +13 -0
  15. data/lib/fluent/platform_watir/platform_web_elements/web_element.rb +84 -5
  16. data/lib/fluent/platforms.rb +2 -1
  17. data/lib/fluent/version.rb +1 -1
  18. data/lib/fluent/web_elements/cell.rb +16 -0
  19. data/lib/fluent/web_elements/checkbox.rb +4 -0
  20. data/lib/fluent/web_elements/div.rb +16 -0
  21. data/lib/fluent/web_elements/list_item.rb +16 -0
  22. data/lib/fluent/web_elements/ordered_list.rb +16 -0
  23. data/lib/fluent/web_elements/radio.rb +4 -0
  24. data/lib/fluent/web_elements/select_list.rb +4 -0
  25. data/lib/fluent/web_elements/span.rb +16 -0
  26. data/lib/fluent/web_elements/table.rb +16 -0
  27. data/lib/fluent/web_elements/text_area.rb +16 -0
  28. data/lib/fluent/web_elements/text_field.rb +8 -0
  29. data/lib/fluent/web_elements/unordered_list.rb +16 -0
  30. data/lib/fluent/web_elements/web_element.rb +12 -0
  31. data/spec/enclosers_spec.rb +38 -0
  32. data/spec/evaluators_spec.rb +88 -0
  33. data/spec/factory_spec.rb +42 -0
  34. data/spec/fluent_spec.rb +32 -1
  35. data/spec/generators/cell_generators_spec.rb +50 -0
  36. data/spec/generators/div_generators_spec.rb +49 -0
  37. data/spec/generators/list_item_generators_spec.rb +53 -0
  38. data/spec/generators/ordered_list_generators_spec.rb +53 -0
  39. data/spec/generators/span_generators_spec.rb +49 -0
  40. data/spec/generators/table_generators_spec.rb +49 -0
  41. data/spec/generators/text_area_generators_spec.rb +55 -0
  42. data/spec/generators/unordered_list_generators_spec.rb +53 -0
  43. data/spec/generators_spec.rb +40 -0
  44. data/spec/mock_app.rb +17 -0
  45. data/spec/platform_object_spec.rb +9 -0
  46. data/spec/web_element_spec.rb +15 -0
  47. data/spec/web_element_watir_spec.rb +123 -5
  48. data/spec/web_elements/checkbox_spec.rb +21 -0
  49. data/spec/web_elements/radio_spec.rb +21 -0
  50. data/spec/web_elements/select_list_spec.rb +41 -0
  51. data/spec/web_elements/text_field_spec.rb +16 -0
  52. metadata +48 -2
data/spec/mock_app.rb CHANGED
@@ -1,14 +1,31 @@
1
1
  require 'watir-webdriver'
2
+ require 'selenium-webdriver'
2
3
 
3
4
  def mock_browser_for_watir
4
5
  watir_browser = double('watir')
5
6
  watir_browser.stub(:is_a?).with(Watir::Browser).and_return(true)
7
+ watir_browser.stub(:is_a?).with(Selenium::WebDriver::Driver).and_return(false)
6
8
  watir_browser
7
9
  end
8
10
 
11
+ def mock_browser_for_selenium
12
+ selenium_browser = double('selenium')
13
+ selenium_browser.stub(:is_a?).with(Watir::Browser).and_return(false)
14
+ selenium_browser.stub(:is_a?).with(Selenium::WebDriver::Driver).and_return(true)
15
+ selenium_browser
16
+ end
17
+
9
18
  class TestDefinition
10
19
  include Fluent
11
20
 
12
21
  url_is 'http://localhost:4567'
13
22
  title_is 'Test App'
23
+
24
+ look_for :name
25
+
26
+ text_field :name, id: 'name'
27
+
28
+ within_frame(id: 'frame') do |frame|
29
+ text_field :framedName, id: 'framedName', frame: frame
30
+ end
14
31
  end
@@ -6,7 +6,10 @@ end
6
6
 
7
7
  describe Fluent do
8
8
  let(:watir_browser) { mock_browser_for_watir }
9
+ let(:selenium_browser) { mock_browser_for_selenium }
10
+
9
11
  let(:watir_definition) { PageDefinition.new(watir_browser) }
12
+ let(:selenium_definition) { PageDefinition.new(selenium_browser) }
10
13
 
11
14
  context 'a definition using watir-webdriver' do
12
15
  it 'should return a watir platform object' do
@@ -14,6 +17,12 @@ describe Fluent do
14
17
  end
15
18
  end
16
19
 
20
+ context 'a definition using selenium-webdriver' do
21
+ it 'should return a selenium platform object' do
22
+ selenium_definition.platform.should be_kind_of Fluent::Platforms::SeleniumWebDriver::PlatformObject
23
+ end
24
+ end
25
+
17
26
  context 'a definition using an unrecognized driver' do
18
27
  it 'should raise an exception' do
19
28
  msg = 'Unable to create a platform object for unknown_browser.'
@@ -4,6 +4,11 @@ describe 'Web Elements' do
4
4
  let(:watir_browser) { mock_browser_for_watir }
5
5
  let(:watir_definition) { ::Fluent::WebElements::WebElement.new(watir_browser, :platform => :watir_webdriver) }
6
6
 
7
+ it 'should return the text contained by a web element' do
8
+ watir_browser.should_receive(:text).and_return('testing')
9
+ watir_definition.text.should == 'testing'
10
+ end
11
+
7
12
  it 'should perform a click event on a web element' do
8
13
  watir_browser.should_receive(:click)
9
14
  watir_definition.click
@@ -20,4 +25,14 @@ describe 'Web Elements' do
20
25
  watir_definition.disabled?.should == true
21
26
  watir_definition.should be_disabled
22
27
  end
28
+
29
+ it 'should retrieve the style of a web element' do
30
+ watir_browser.should_receive(:style).with('display').and_return('none')
31
+ watir_definition.style('display').should == 'none'
32
+ end
33
+
34
+ it 'should retrieve the class name of a web element' do
35
+ watir_browser.should_receive(:attribute_value).and_return('class')
36
+ watir_definition.class_name
37
+ end
23
38
  end
@@ -4,11 +4,6 @@ describe 'Web Elements for Watir' do
4
4
  let(:watir_browser) { mock_browser_for_watir }
5
5
  let(:watir_definition) { ::Fluent::WebElements::WebElement.new(watir_browser, :platform => :watir_webdriver) }
6
6
 
7
- it 'should return the text contained by a web element' do
8
- watir_browser.should_receive(:text).and_return('testing')
9
- watir_definition.text.should == 'testing'
10
- end
11
-
12
7
  it 'should determine if a web element exists' do
13
8
  watir_browser.should_receive(:exists?).and_return(true)
14
9
  watir_definition.exists?.should == true
@@ -29,4 +24,127 @@ describe 'Web Elements for Watir' do
29
24
  watir_browser.should_receive(:present?).and_return(false)
30
25
  watir_definition.visible?.should == false
31
26
  end
27
+
28
+ it 'should simulate a double-click event on a web element' do
29
+ watir_browser.should_receive(:double_click)
30
+ watir_definition.double_click
31
+ end
32
+
33
+ it 'should allow a clear event on a web element' do
34
+ watir_browser.should_receive(:clear)
35
+ watir_definition.clear
36
+ end
37
+
38
+ it 'should be able to flash a web element' do
39
+ watir_browser.should_receive(:flash).exactly(5).times.and_return(watir_definition)
40
+ watir_browser.should_receive(:exists?).and_return(watir_definition)
41
+ watir_definition.flash.should be_instance_of Fluent::WebElements::WebElement
42
+ end
43
+
44
+ it 'should be able to flash a web element a specified number of times' do
45
+ watir_browser.should_receive(:flash).exactly(1).times.and_return(watir_definition)
46
+ watir_browser.should_receive(:exists?).and_return(watir_definition)
47
+ watir_definition.flash(1).should be_instance_of Fluent::WebElements::WebElement
48
+ end
49
+
50
+ it 'should retrieve the tag of a web element' do
51
+ watir_browser.should_receive(:tag_name).and_return('div')
52
+ watir_definition.tag_name.should == 'div'
53
+ end
54
+
55
+ it 'should retrieve the html of a web element' do
56
+ watir_browser.should_receive(:html).and_return('<p>Testing</p>')
57
+ watir_definition.html.should == '<p>Testing</p>'
58
+ end
59
+
60
+ it 'should retrieve the value of an attribute' do
61
+ watir_browser.should_receive(:attribute_value).and_return(true)
62
+ watir_definition.attribute('readonly').should be_true
63
+ end
64
+
65
+ it 'should be able to fire an event on a web element' do
66
+ watir_browser.should_receive(:fire_event).and_return('onclick')
67
+ watir_definition.fire_event('onclick')
68
+ end
69
+
70
+ it 'should retrieve the value of a web element' do
71
+ watir_browser.should_receive(:value).and_return("value")
72
+ watir_definition.value.should == 'value'
73
+ end
74
+
75
+ it 'should retrieve the id of a web element' do
76
+ watir_browser.should_receive(:id).and_return('id')
77
+ watir_definition.id.should == 'id'
78
+ end
79
+
80
+ it 'should send key presses to a web element' do
81
+ watir_browser.should_receive(:send_keys).with([:control, 'a'])
82
+ watir_definition.send_keys([:control, 'a'])
83
+ end
84
+
85
+ it 'should scroll elements into view' do
86
+ watir_browser.should_receive(:wd).and_return(watir_browser)
87
+ watir_browser.should_receive(:location_once_scrolled_into_view)
88
+ watir_definition.scroll_into_view
89
+ end
90
+
91
+ it 'should be able to focus on a web element' do
92
+ watir_browser.should_receive(:focus).and_return(watir_definition)
93
+ watir_definition.focus
94
+ end
95
+
96
+ it 'should be able to hover over a web element' do
97
+ watir_browser.should_receive(:hover).and_return(watir_definition)
98
+ watir_definition.hover
99
+ end
100
+
101
+ it 'should wait for a web element to be present' do
102
+ watir_browser.should_receive(:wait_until_present).twice.with(5)
103
+ watir_definition.when_actionable(5)
104
+ watir_definition.when_present(5)
105
+ end
106
+
107
+ it 'should use the provided element wait time for presence checks' do
108
+ Fluent.element_level_wait = 30
109
+ watir_browser.should_receive(:wait_until_present).with(30)
110
+ watir_definition.when_present
111
+ end
112
+
113
+ it 'should reference a web element when it is present' do
114
+ watir_browser.should_receive(:wait_until_present).with(5)
115
+ web_element = watir_definition.when_actionable(5)
116
+ web_element.should === watir_definition
117
+ end
118
+
119
+ it 'should wait for a web element to become non-present' do
120
+ watir_browser.should_receive(:wait_while_present).and_return(false)
121
+ watir_definition.when_not_present(5)
122
+ end
123
+
124
+ it 'should wait for a web element to become visible' do
125
+ watir_browser.should_receive(:present?).and_return(true)
126
+ watir_definition.when_visible(5)
127
+ end
128
+
129
+ it 'should reference a web element when it is visible' do
130
+ watir_browser.should_receive(:present?).and_return(true)
131
+ web_element = watir_definition.when_visible(5)
132
+ web_element.should === watir_definition
133
+ end
134
+
135
+ it 'should wait for a web element to become invisible' do
136
+ watir_browser.should_receive(:present?).and_return(false)
137
+ watir_definition.when_not_visible(5)
138
+ end
139
+
140
+ it 'should reference a web element when it is not visible' do
141
+ watir_browser.stub(:present?).and_return(false)
142
+ web_element = watir_definition.when_not_visible(5)
143
+ web_element.should === watir_definition
144
+ end
145
+
146
+ it 'should wait until a specific condition occurs' do
147
+ Object::Watir::Wait.stub(:until).with(5, 'Condition occurred.')
148
+ watir_definition.wait_until(5, 'Condition occurred.') { true }
149
+ end
32
150
  end
@@ -0,0 +1,21 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe 'WebElements::CheckBox' do
4
+ let(:checkbox_object) { double('checkbox_object') }
5
+ let(:checkbox_definition) { ::Fluent::WebElements::CheckBox.new(checkbox_object, :platform => :watir_webdriver) }
6
+
7
+ it 'should be able to determine if the checkbox element is checked' do
8
+ checkbox_object.should_receive(:set?).and_return(true)
9
+ checkbox_definition.checked?
10
+ end
11
+
12
+ it 'should be able to check the checkbox' do
13
+ checkbox_object.should_receive(:set)
14
+ checkbox_definition.check
15
+ end
16
+
17
+ it 'should be able to uncheck the checkbox' do
18
+ checkbox_object.should_receive(:clear)
19
+ checkbox_definition.uncheck
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe 'WebElements::Radio' do
4
+ let(:radio_object) { double('radio_object') }
5
+ let(:radio_definition) { ::Fluent::WebElements::Radio.new(radio_object, :platform => :watir_webdriver) }
6
+
7
+ it 'should be able to see if a radio is selected' do
8
+ radio_object.should_receive(:set?).and_return(true)
9
+ radio_definition.selected?
10
+ end
11
+
12
+ it 'should be able to select a radio' do
13
+ radio_object.should_receive(:set).and_return(true)
14
+ radio_definition.select
15
+ end
16
+
17
+ it 'should be able to clear a radio' do
18
+ radio_object.should_receive(:clear).and_return(true)
19
+ radio_definition.clear
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe 'WebElements::SelectList' do
4
+ let(:select_list_object) { double('select_list_object') }
5
+ let(:select_list_definition) { ::Fluent::WebElements::SelectList.new(select_list_object, :platform => :watir_webdriver) }
6
+ let(:select_list_options) { [select_list_object, select_list_object] }
7
+
8
+ # select_list_actual == select_list_definition
9
+
10
+ it 'should determine if an option is selected' do
11
+ select_list_object.stub(:selected?).with('testing').and_return(true)
12
+ select_list_definition.selected?('testing')
13
+ end
14
+
15
+ it 'should be able to select an item by option' do
16
+ select_list_object.should_receive(:select).and_return(true)
17
+ select_list_definition.select('testing')
18
+ end
19
+
20
+ it 'should be able to select an item by value' do
21
+ select_list_object.should_receive(:select_value).and_return(true)
22
+ select_list_definition.select_value('testing')
23
+ end
24
+
25
+ it 'should return an array of selected options' do
26
+ select_list_object.stub(:selected_options).and_return(select_list_options)
27
+ select_list_object.stub(:text).and_return(select_list_object)
28
+ select_list_definition.selected_options.should == select_list_options
29
+ end
30
+
31
+ it 'should get the values for any selected options' do
32
+ select_list_object.stub(:selected_options).and_return(select_list_options)
33
+ select_list_object.stub(:value).and_return(select_list_object)
34
+ select_list_definition.selected_values.should == select_list_options
35
+ end
36
+
37
+ it 'should determine if an option is available in the list' do
38
+ select_list_object.stub(:include?).with('testing').and_return(true)
39
+ select_list_definition.include?('testing')
40
+ end
41
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe 'WebElements::TextField' do
4
+ let(:text_field_object) { double('text_field_object') }
5
+ let(:text_field_definition) { ::Fluent::WebElements::TextField.new(text_field_object, :platform => :watir_webdriver) }
6
+
7
+ it 'should append text to a text field' do
8
+ text_field_object.should_receive(:send_keys).with('testing')
9
+ text_field_definition.append 'testing'
10
+ end
11
+
12
+ it 'should set the value of a text field' do
13
+ text_field_object.should_receive(:set).with('testing')
14
+ text_field_definition.value = 'testing'
15
+ end
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Nyman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2013-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,38 +110,69 @@ files:
110
110
  - Rakefile
111
111
  - fluent.gemspec
112
112
  - lib/fluent.rb
113
+ - lib/fluent/enclosers.rb
113
114
  - lib/fluent/errors.rb
115
+ - lib/fluent/evaluators.rb
116
+ - lib/fluent/factory.rb
114
117
  - lib/fluent/generators.rb
115
118
  - lib/fluent/logger.rb
119
+ - lib/fluent/platform_selenium.rb
120
+ - lib/fluent/platform_selenium/platform_object.rb
116
121
  - lib/fluent/platform_watir.rb
117
122
  - lib/fluent/platform_watir/platform_object.rb
123
+ - lib/fluent/platform_watir/platform_web_elements/checkbox.rb
124
+ - lib/fluent/platform_watir/platform_web_elements/radio.rb
118
125
  - lib/fluent/platform_watir/platform_web_elements/select_list.rb
126
+ - lib/fluent/platform_watir/platform_web_elements/text_field.rb
119
127
  - lib/fluent/platform_watir/platform_web_elements/web_element.rb
120
128
  - lib/fluent/platforms.rb
121
129
  - lib/fluent/version.rb
122
130
  - lib/fluent/web_elements/button.rb
131
+ - lib/fluent/web_elements/cell.rb
123
132
  - lib/fluent/web_elements/checkbox.rb
133
+ - lib/fluent/web_elements/div.rb
124
134
  - lib/fluent/web_elements/link.rb
135
+ - lib/fluent/web_elements/list_item.rb
125
136
  - lib/fluent/web_elements/option.rb
137
+ - lib/fluent/web_elements/ordered_list.rb
126
138
  - lib/fluent/web_elements/paragraph.rb
127
139
  - lib/fluent/web_elements/radio.rb
128
140
  - lib/fluent/web_elements/select_list.rb
141
+ - lib/fluent/web_elements/span.rb
142
+ - lib/fluent/web_elements/table.rb
143
+ - lib/fluent/web_elements/text_area.rb
129
144
  - lib/fluent/web_elements/text_field.rb
145
+ - lib/fluent/web_elements/unordered_list.rb
130
146
  - lib/fluent/web_elements/web_element.rb
147
+ - spec/enclosers_spec.rb
148
+ - spec/evaluators_spec.rb
149
+ - spec/factory_spec.rb
131
150
  - spec/fluent_spec.rb
132
151
  - spec/generators/button_generators_spec.rb
152
+ - spec/generators/cell_generators_spec.rb
133
153
  - spec/generators/checkbox_generators_spec.rb
154
+ - spec/generators/div_generators_spec.rb
134
155
  - spec/generators/link_generators_spec.rb
156
+ - spec/generators/list_item_generators_spec.rb
157
+ - spec/generators/ordered_list_generators_spec.rb
135
158
  - spec/generators/paragraph_generators_spec.rb
136
159
  - spec/generators/radio_generators_spec.rb
137
160
  - spec/generators/select_list_generators_spec.rb
161
+ - spec/generators/span_generators_spec.rb
162
+ - spec/generators/table_generators_spec.rb
163
+ - spec/generators/text_area_generators_spec.rb
138
164
  - spec/generators/text_field_generators_spec.rb
165
+ - spec/generators/unordered_list_generators_spec.rb
139
166
  - spec/generators_spec.rb
140
167
  - spec/mock_app.rb
141
168
  - spec/platform_object_spec.rb
142
169
  - spec/spec_helper.rb
143
170
  - spec/web_element_spec.rb
144
171
  - spec/web_element_watir_spec.rb
172
+ - spec/web_elements/checkbox_spec.rb
173
+ - spec/web_elements/radio_spec.rb
174
+ - spec/web_elements/select_list_spec.rb
175
+ - spec/web_elements/text_field_spec.rb
145
176
  homepage: https://github.com/jnyman/fluent
146
177
  licenses:
147
178
  - MIT
@@ -167,17 +198,32 @@ signing_key:
167
198
  specification_version: 4
168
199
  summary: A Semantically Clean Fluent Interface Test Framework
169
200
  test_files:
201
+ - spec/enclosers_spec.rb
202
+ - spec/evaluators_spec.rb
203
+ - spec/factory_spec.rb
170
204
  - spec/fluent_spec.rb
171
205
  - spec/generators/button_generators_spec.rb
206
+ - spec/generators/cell_generators_spec.rb
172
207
  - spec/generators/checkbox_generators_spec.rb
208
+ - spec/generators/div_generators_spec.rb
173
209
  - spec/generators/link_generators_spec.rb
210
+ - spec/generators/list_item_generators_spec.rb
211
+ - spec/generators/ordered_list_generators_spec.rb
174
212
  - spec/generators/paragraph_generators_spec.rb
175
213
  - spec/generators/radio_generators_spec.rb
176
214
  - spec/generators/select_list_generators_spec.rb
215
+ - spec/generators/span_generators_spec.rb
216
+ - spec/generators/table_generators_spec.rb
217
+ - spec/generators/text_area_generators_spec.rb
177
218
  - spec/generators/text_field_generators_spec.rb
219
+ - spec/generators/unordered_list_generators_spec.rb
178
220
  - spec/generators_spec.rb
179
221
  - spec/mock_app.rb
180
222
  - spec/platform_object_spec.rb
181
223
  - spec/spec_helper.rb
182
224
  - spec/web_element_spec.rb
183
225
  - spec/web_element_watir_spec.rb
226
+ - spec/web_elements/checkbox_spec.rb
227
+ - spec/web_elements/radio_spec.rb
228
+ - spec/web_elements/select_list_spec.rb
229
+ - spec/web_elements/text_field_spec.rb