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
@@ -0,0 +1,50 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class CellGenerators
4
+ include Fluent
5
+
6
+ cell :total, id: 'total'
7
+ end
8
+
9
+ describe Fluent::Generators do
10
+ let(:watir_browser) { mock_browser_for_watir }
11
+ let(:watir_definition) { CellGenerators.new(watir_browser) }
12
+
13
+ describe 'cell generators' do
14
+ context 'when declared on a page definition' do
15
+ it 'should generate methods for referencing the cell' do
16
+ watir_definition.should respond_to(:total_object)
17
+ watir_definition.should respond_to(:total_element)
18
+ watir_definition.should respond_to(:total_cell)
19
+ watir_definition.should respond_to(:total_td)
20
+ end
21
+
22
+ it 'should generate methods for interacting with the cell' do
23
+ watir_definition.should respond_to(:total)
24
+ watir_definition.should respond_to(:total_exists?)
25
+ watir_definition.should respond_to(:total_visible?)
26
+ watir_definition.should respond_to(:total?)
27
+ watir_definition.should respond_to(:total_?)
28
+ watir_definition.should respond_to(:total_td_exists?)
29
+ watir_definition.should respond_to(:total_td_visible?)
30
+ watir_definition.should respond_to(:total_td?)
31
+ watir_definition.should respond_to(:total_td_?)
32
+ end
33
+ end
34
+
35
+ context 'when used by the watir platform' do
36
+ it 'should locate the cell' do
37
+ watir_browser.should_receive(:td).and_return(watir_browser)
38
+ web_element = watir_definition.total_cell
39
+ web_element.should_not be_nil
40
+ web_element.should be_instance_of Fluent::WebElements::Cell
41
+ end
42
+
43
+ it 'should return the text of a table' do
44
+ watir_browser.should_receive(:td).and_return(watir_browser)
45
+ watir_browser.should_receive(:text).and_return('testing')
46
+ watir_definition.total.should == 'testing'
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,49 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class DivGenerators
4
+ include Fluent
5
+
6
+ div :section, id: 'section'
7
+ end
8
+
9
+ describe Fluent::Generators do
10
+ let(:watir_browser) { mock_browser_for_watir }
11
+ let(:watir_definition) { DivGenerators.new(watir_browser) }
12
+
13
+ describe 'div generators' do
14
+ context 'when declared on a page definition' do
15
+ it 'should generate methods for referencing the div' do
16
+ watir_definition.should respond_to(:section_object)
17
+ watir_definition.should respond_to(:section_element)
18
+ watir_definition.should respond_to(:section_div)
19
+ end
20
+
21
+ it 'should generate methods for interacting with the div' do
22
+ watir_definition.should respond_to(:section)
23
+ watir_definition.should respond_to(:section_exists?)
24
+ watir_definition.should respond_to(:section_visible?)
25
+ watir_definition.should respond_to(:section?)
26
+ watir_definition.should respond_to(:section_?)
27
+ watir_definition.should respond_to(:section_div_exists?)
28
+ watir_definition.should respond_to(:section_div_visible?)
29
+ watir_definition.should respond_to(:section_div?)
30
+ watir_definition.should respond_to(:section_div_?)
31
+ end
32
+ end
33
+
34
+ context 'when used by the watir platform' do
35
+ it 'should locate the div' do
36
+ watir_browser.should_receive(:div).and_return(watir_browser)
37
+ web_element = watir_definition.section_div
38
+ web_element.should_not be_nil
39
+ web_element.should be_instance_of Fluent::WebElements::Div
40
+ end
41
+
42
+ it 'should return the text of a div' do
43
+ watir_browser.should_receive(:div).and_return(watir_browser)
44
+ watir_browser.should_receive(:text).and_return('testing')
45
+ watir_definition.section.should == 'testing'
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class ListItemGenerators
4
+ include Fluent
5
+
6
+ li :list_short, id: 'list1'
7
+ list_item :list, id: 'list2'
8
+ end
9
+
10
+ describe Fluent::Generators do
11
+ let(:watir_browser) { mock_browser_for_watir }
12
+ let(:watir_definition) { ListItemGenerators.new(watir_browser) }
13
+
14
+ describe 'list item generators' do
15
+ context 'when declared on a page definition' do
16
+ it 'should generate methods for referencing the list item' do
17
+ watir_definition.should respond_to(:list_object)
18
+ watir_definition.should respond_to(:list_element)
19
+ watir_definition.should respond_to(:list_list_item)
20
+ watir_definition.should respond_to(:list_short_li)
21
+ end
22
+
23
+ it 'should generate methods for interacting with the list item' do
24
+ watir_definition.should respond_to(:list)
25
+ watir_definition.should respond_to(:list_exists?)
26
+ watir_definition.should respond_to(:list_visible?)
27
+ watir_definition.should respond_to(:list?)
28
+ watir_definition.should respond_to(:list_?)
29
+ watir_definition.should respond_to(:list_li_exists?)
30
+ watir_definition.should respond_to(:list_li_visible?)
31
+ watir_definition.should respond_to(:list_li?)
32
+ watir_definition.should respond_to(:list_li_?)
33
+ end
34
+ end
35
+
36
+ context 'when used by the watir platform' do
37
+ it 'should locate the list item' do
38
+ watir_browser.should_receive(:li).and_return(watir_browser)
39
+ web_element = watir_definition.list_list_item
40
+ web_element.should_not be_nil
41
+ web_element.should be_instance_of Fluent::WebElements::ListItem
42
+ end
43
+
44
+ it 'should return the text of a list item' do
45
+ watir_browser.should_receive(:li).twice.and_return(watir_browser)
46
+ watir_browser.should_receive(:text).twice.and_return('testing')
47
+ watir_definition.list.should == 'testing'
48
+ watir_definition.list_short.should == 'testing'
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class OrderedListGenerators
4
+ include Fluent
5
+
6
+ ol :list_short, id: 'list1'
7
+ ordered_list :list, id: 'list2'
8
+ end
9
+
10
+ describe Fluent::Generators do
11
+ let(:watir_browser) { mock_browser_for_watir }
12
+ let(:watir_definition) { OrderedListGenerators.new(watir_browser) }
13
+
14
+ describe 'ordered list generators' do
15
+ context 'when declared on a page definition' do
16
+ it 'should generate methods for referencing the ordered list' do
17
+ watir_definition.should respond_to(:list_object)
18
+ watir_definition.should respond_to(:list_element)
19
+ watir_definition.should respond_to(:list_ordered_list)
20
+ watir_definition.should respond_to(:list_short_ol)
21
+ end
22
+
23
+ it 'should generate methods for interacting with the ordered list' do
24
+ watir_definition.should respond_to(:list)
25
+ watir_definition.should respond_to(:list_exists?)
26
+ watir_definition.should respond_to(:list_visible?)
27
+ watir_definition.should respond_to(:list?)
28
+ watir_definition.should respond_to(:list_?)
29
+ watir_definition.should respond_to(:list_ol_exists?)
30
+ watir_definition.should respond_to(:list_ol_visible?)
31
+ watir_definition.should respond_to(:list_ol?)
32
+ watir_definition.should respond_to(:list_ol_?)
33
+ end
34
+ end
35
+
36
+ context 'when used by the watir platform' do
37
+ it 'should locate the ordered list' do
38
+ watir_browser.should_receive(:ol).and_return(watir_browser)
39
+ web_element = watir_definition.list_ordered_list
40
+ web_element.should_not be_nil
41
+ web_element.should be_instance_of Fluent::WebElements::OrderedList
42
+ end
43
+
44
+ it 'should return the text of a ordered list' do
45
+ watir_browser.should_receive(:ol).twice.and_return(watir_browser)
46
+ watir_browser.should_receive(:text).twice.and_return('testing')
47
+ watir_definition.list.should == 'testing'
48
+ watir_definition.list_short.should == 'testing'
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,49 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class SpanGenerators
4
+ include Fluent
5
+
6
+ span :inline, id: 'inline'
7
+ end
8
+
9
+ describe Fluent::Generators do
10
+ let(:watir_browser) { mock_browser_for_watir }
11
+ let(:watir_definition) { SpanGenerators.new(watir_browser) }
12
+
13
+ describe 'span generators' do
14
+ context 'when declared on a page definition' do
15
+ it 'should generate methods for referencing the span' do
16
+ watir_definition.should respond_to(:inline_object)
17
+ watir_definition.should respond_to(:inline_element)
18
+ watir_definition.should respond_to(:inline_span)
19
+ end
20
+
21
+ it 'should generate methods for interacting with the span' do
22
+ watir_definition.should respond_to(:inline)
23
+ watir_definition.should respond_to(:inline_exists?)
24
+ watir_definition.should respond_to(:inline_visible?)
25
+ watir_definition.should respond_to(:inline?)
26
+ watir_definition.should respond_to(:inline_?)
27
+ watir_definition.should respond_to(:inline_span_exists?)
28
+ watir_definition.should respond_to(:inline_span_visible?)
29
+ watir_definition.should respond_to(:inline_span?)
30
+ watir_definition.should respond_to(:inline_span_?)
31
+ end
32
+ end
33
+
34
+ context 'when used by the watir platform' do
35
+ it 'should locate the span' do
36
+ watir_browser.should_receive(:span).and_return(watir_browser)
37
+ web_element = watir_definition.inline_span
38
+ web_element.should_not be_nil
39
+ web_element.should be_instance_of Fluent::WebElements::Span
40
+ end
41
+
42
+ it 'should return the text of a span' do
43
+ watir_browser.should_receive(:span).and_return(watir_browser)
44
+ watir_browser.should_receive(:text).and_return('testing')
45
+ watir_definition.inline.should == 'testing'
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class TableGenerators
4
+ include Fluent
5
+
6
+ table :accounts, id: 'accounts'
7
+ end
8
+
9
+ describe Fluent::Generators do
10
+ let(:watir_browser) { mock_browser_for_watir }
11
+ let(:watir_definition) { TableGenerators.new(watir_browser) }
12
+
13
+ describe 'table generators' do
14
+ context 'when declared on a page definition' do
15
+ it 'should generate methods for referencing the table' do
16
+ watir_definition.should respond_to(:accounts_object)
17
+ watir_definition.should respond_to(:accounts_element)
18
+ watir_definition.should respond_to(:accounts_table)
19
+ end
20
+
21
+ it 'should generate methods for interacting with the table' do
22
+ watir_definition.should respond_to(:accounts)
23
+ watir_definition.should respond_to(:accounts_exists?)
24
+ watir_definition.should respond_to(:accounts_visible?)
25
+ watir_definition.should respond_to(:accounts?)
26
+ watir_definition.should respond_to(:accounts_?)
27
+ watir_definition.should respond_to(:accounts_table_exists?)
28
+ watir_definition.should respond_to(:accounts_table_visible?)
29
+ watir_definition.should respond_to(:accounts_table?)
30
+ watir_definition.should respond_to(:accounts_table_?)
31
+ end
32
+ end
33
+
34
+ context 'when used by the watir platform' do
35
+ it 'should locate the table' do
36
+ watir_browser.should_receive(:table).and_return(watir_browser)
37
+ web_element = watir_definition.accounts_table
38
+ web_element.should_not be_nil
39
+ web_element.should be_instance_of Fluent::WebElements::Table
40
+ end
41
+
42
+ it 'should return the text of a table' do
43
+ watir_browser.should_receive(:table).and_return(watir_browser)
44
+ watir_browser.should_receive(:text).and_return('testing')
45
+ watir_definition.accounts.should == 'testing'
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,55 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class TextAreaGenerators
4
+ include Fluent
5
+
6
+ text_area :summary, id: 'summary'
7
+ end
8
+
9
+ describe Fluent::Generators do
10
+ let(:watir_browser) { mock_browser_for_watir }
11
+ let(:watir_definition) { TextAreaGenerators.new(watir_browser) }
12
+
13
+ describe 'text area generators' do
14
+ context 'when declared on a page definition' do
15
+ it 'should generate methods for referencing the text area' do
16
+ watir_definition.should respond_to(:summary_object)
17
+ watir_definition.should respond_to(:summary_element)
18
+ watir_definition.should respond_to(:summary_text_area)
19
+ end
20
+
21
+ it 'should generate methods for interacting with the text area' do
22
+ watir_definition.should respond_to(:summary)
23
+ watir_definition.should respond_to(:summary_exists?)
24
+ watir_definition.should respond_to(:summary_visible?)
25
+ watir_definition.should respond_to(:summary?)
26
+ watir_definition.should respond_to(:summary_?)
27
+ watir_definition.should respond_to(:summary_text_area_exists?)
28
+ watir_definition.should respond_to(:summary_text_area_visible?)
29
+ watir_definition.should respond_to(:summary_text_area?)
30
+ watir_definition.should respond_to(:summary_text_area_?)
31
+ end
32
+ end
33
+
34
+ context 'when used by the watir platform' do
35
+ it 'should locate the text area' do
36
+ watir_browser.should_receive(:text_area).and_return(watir_browser)
37
+ web_element = watir_definition.summary_object
38
+ web_element.should_not be_nil
39
+ web_element.should be_instance_of Fluent::WebElements::TextArea
40
+ end
41
+
42
+ it 'should retrieve text from the text area' do
43
+ watir_browser.should_receive(:text_area).and_return(watir_browser)
44
+ watir_browser.should_receive(:value).and_return('testing')
45
+ watir_definition.summary.should == 'testing'
46
+ end
47
+
48
+ it 'should enter text into a text area' do
49
+ watir_browser.should_receive(:text_area).and_return(watir_browser)
50
+ watir_browser.should_receive(:set).with('testing')
51
+ watir_definition.summary = 'testing'
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../spec_helper'
2
+
3
+ class UnorderedListGenerators
4
+ include Fluent
5
+
6
+ ul :list_short, id: 'list1'
7
+ unordered_list :list, id: 'list2'
8
+ end
9
+
10
+ describe Fluent::Generators do
11
+ let(:watir_browser) { mock_browser_for_watir }
12
+ let(:watir_definition) { UnorderedListGenerators.new(watir_browser) }
13
+
14
+ describe 'unordered list generators' do
15
+ context 'when declared on a page definition' do
16
+ it 'should generate methods for referencing the unordered list' do
17
+ watir_definition.should respond_to(:list_object)
18
+ watir_definition.should respond_to(:list_element)
19
+ watir_definition.should respond_to(:list_unordered_list)
20
+ watir_definition.should respond_to(:list_short_ul)
21
+ end
22
+
23
+ it 'should generate methods for interacting with the unordered list' do
24
+ watir_definition.should respond_to(:list)
25
+ watir_definition.should respond_to(:list_exists?)
26
+ watir_definition.should respond_to(:list_visible?)
27
+ watir_definition.should respond_to(:list?)
28
+ watir_definition.should respond_to(:list_?)
29
+ watir_definition.should respond_to(:list_ul_exists?)
30
+ watir_definition.should respond_to(:list_ul_visible?)
31
+ watir_definition.should respond_to(:list_ul?)
32
+ watir_definition.should respond_to(:list_ul_?)
33
+ end
34
+ end
35
+
36
+ context 'when used by the watir platform' do
37
+ it 'should locate the unordered list' do
38
+ watir_browser.should_receive(:ul).and_return(watir_browser)
39
+ web_element = watir_definition.list_unordered_list
40
+ web_element.should_not be_nil
41
+ web_element.should be_instance_of Fluent::WebElements::UnorderedList
42
+ end
43
+
44
+ it 'should return the text of a unordered list' do
45
+ watir_browser.should_receive(:ul).twice.and_return(watir_browser)
46
+ watir_browser.should_receive(:text).twice.and_return('testing')
47
+ watir_definition.list.should == 'testing'
48
+ watir_definition.list_short.should == 'testing'
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -3,13 +3,19 @@ require 'mock_app'
3
3
 
4
4
  describe Fluent::Generators do
5
5
  let(:watir_browser) { mock_browser_for_watir }
6
+ let(:selenium_browser) { mock_browser_for_selenium }
7
+
6
8
  let(:watir_definition) { TestDefinition.new(watir_browser) }
9
+ let(:selenium_definition) { TestDefinition.new(selenium_browser) }
7
10
 
8
11
  context 'any page definition' do
9
12
  context 'providing a page title to be verified' do
10
13
  it 'should specify and verify the page title' do
11
14
  watir_browser.should_receive(:title).twice.and_return('Test App')
12
15
  watir_definition.check_title
16
+
17
+ selenium_browser.should_receive(:title).twice.and_return('Test App')
18
+ selenium_definition.check_title
13
19
  end
14
20
 
15
21
  it 'should raise an error if the page title is not verified' do
@@ -27,6 +33,30 @@ describe Fluent::Generators do
27
33
  watir_browser.should_receive(:title).twice.and_return('Symbiote')
28
34
  QuickDefinition.new(watir_browser).check_title
29
35
  end
36
+
37
+ it 'should allow frames to act as a context' do
38
+ watir_browser.should_receive(:frame).with(id: 'frame').and_return(watir_browser)
39
+ watir_browser.should_receive(:text_field).and_return(watir_browser)
40
+ web_element = watir_definition.framedName_text_field
41
+ web_element.should_not be_nil
42
+ web_element.should be_instance_of Fluent::WebElements::TextField
43
+ end
44
+
45
+ context 'automatically looking for an element' do
46
+ it 'should specify and verify an expected elements' do
47
+ watir_definition.should_receive(:name_object).and_return(watir_browser)
48
+ watir_browser.should_receive(:when_present).with(5).and_return(watir_browser)
49
+ watir_definition.check_objects
50
+ end
51
+
52
+ it 'should raise an error if an expected elements are not verified' do
53
+ class QuickDefinition
54
+ include Fluent
55
+ look_for :fakeLink
56
+ end
57
+ expect { QuickDefinition.new(watir_browser).check_objects }.to raise_error
58
+ end
59
+ end
30
60
  end
31
61
 
32
62
  context 'a definition using watir-webdriver' do
@@ -37,6 +67,16 @@ describe Fluent::Generators do
37
67
  end
38
68
  end
39
69
  end
70
+
71
+ context 'a definition using selenium-webdriver' do
72
+ context 'providing a url' do
73
+ it 'should navigate to the page when viewed' do
74
+ selenium_browser.should_receive(:navigate).and_return(selenium_browser)
75
+ selenium_browser.should_receive(:to)
76
+ selenium_definition.view
77
+ end
78
+ end
79
+ end
40
80
 
41
81
  end
42
82
  end