fluent 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +7 -0
- data/fluent.gemspec +1 -0
- data/lib/fluent.rb +8 -9
- data/lib/fluent/evaluators.rb +1 -1
- data/lib/fluent/factory.rb +1 -1
- data/lib/fluent/generators.rb +5 -5
- data/lib/fluent/platform_mechanize.rb +18 -0
- data/lib/fluent/platform_mechanize/platform_object.rb +21 -0
- data/lib/fluent/platform_selenium.rb +4 -4
- data/lib/fluent/platform_selenium/platform_object.rb +4 -4
- data/lib/fluent/platform_watir.rb +4 -4
- data/lib/fluent/platform_watir/platform_object.rb +24 -24
- data/lib/fluent/platforms.rb +7 -6
- data/lib/fluent/version.rb +1 -1
- data/spec/factory_spec.rb +5 -5
- data/spec/generators_spec.rb +27 -27
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83879b044030a03d6874a004d81a15013eb36507
|
4
|
+
data.tar.gz: 8d373bac702368bb6b66af1f762a0e95d527ceb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a3cee3e749c9f5a704bd5d0a1d8a2cb9c5db3173cfe0258bc0807bb52436e1c17e926c4ebeb0d407ffe615515e74df86bf1c356708ef391ca0d33511fb2b52
|
7
|
+
data.tar.gz: b020387965fde7eb8e7574c1cca3924303796da4a4e5f50da033257a727e15f7a8864ee411743dec4a4d32cf05e2a8efc801dbdbfc024d06cbf20cc3f2aa077b
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Change Log and History
|
2
2
|
======================
|
3
3
|
|
4
|
+
Version 0.4.0 / 2013-11-13
|
5
|
+
--------------------------
|
6
|
+
|
7
|
+
This release is relatively minor in terms of number of changes but it does change some aspects of how drivers are specified. Prior to this release, Fluent counted on there being a @browser instance in order to create a platform object. That is now a @driver instance. Further, Fluent used to default solely to testing with browsers and thus Watir WebDriver was used as a default. The ability to support drivers by default is now removed.
|
8
|
+
|
9
|
+
The reason for that is Fluent is now supporting Mechanize. While that is technically "just another browser" it is different enough in interface implementation, that it was no longer feasible to assume GUI-based browsers as a default option. What this means is that Fluent can now create a platform object for Mechanize.
|
10
|
+
|
4
11
|
Version 0.3.0 / 2013-10-29
|
5
12
|
--------------------------
|
6
13
|
|
data/fluent.gemspec
CHANGED
data/lib/fluent.rb
CHANGED
@@ -9,6 +9,7 @@ require 'fluent/generators'
|
|
9
9
|
|
10
10
|
require 'watir-webdriver'
|
11
11
|
require 'selenium-webdriver'
|
12
|
+
require 'mechanize'
|
12
13
|
|
13
14
|
module Fluent
|
14
15
|
include Platforms
|
@@ -19,7 +20,7 @@ module Fluent
|
|
19
20
|
# [Watir::Browser] or [Selenium::WebDriver::Driver]
|
20
21
|
#
|
21
22
|
# @return [Object] browser driver reference
|
22
|
-
attr_reader :
|
23
|
+
attr_reader :driver
|
23
24
|
|
24
25
|
# Platform references will be:
|
25
26
|
# [Fluent::Platforms::WatirWebDriver::PlatformObject]
|
@@ -51,15 +52,13 @@ module Fluent
|
|
51
52
|
# (1) A browser instance is being created.
|
52
53
|
# (2) A platform object is created for that browser.
|
53
54
|
#
|
54
|
-
# @param
|
55
|
-
def initialize(
|
56
|
-
@
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
Fluent::trace("Fluent attached to browser: #{@browser}")
|
55
|
+
# @param driver [Object] a tool driver instance
|
56
|
+
def initialize(driver=nil, visit=nil)
|
57
|
+
@driver = driver
|
58
|
+
|
59
|
+
Fluent::trace("Fluent attached to driver: #{@driver}")
|
61
60
|
|
62
|
-
establish_platform_object_for @
|
61
|
+
establish_platform_object_for @driver
|
63
62
|
|
64
63
|
view if visit && respond_to?(:view)
|
65
64
|
end
|
data/lib/fluent/evaluators.rb
CHANGED
@@ -55,7 +55,7 @@ module Fluent
|
|
55
55
|
def wait_for_pending_requests(time_limit=30, message_if_timeout=nil)
|
56
56
|
end_time = ::Time.now + time_limit
|
57
57
|
until ::Time.now > end_time
|
58
|
-
return if
|
58
|
+
return if driver.execute_script('return jQuery.active') == 0
|
59
59
|
wait_for_app 0.5
|
60
60
|
end
|
61
61
|
message = 'Pending jQuery requests never indicated completion.' unless message_if_timeout
|
data/lib/fluent/factory.rb
CHANGED
@@ -10,7 +10,7 @@ module Fluent
|
|
10
10
|
definition = get_object_for(definition) if definition.is_a? String
|
11
11
|
|
12
12
|
return @active if @active.kind_of?(definition)
|
13
|
-
@active = definition.new(@
|
13
|
+
@active = definition.new(@driver, visit)
|
14
14
|
block.call @active if block
|
15
15
|
|
16
16
|
@active
|
data/lib/fluent/generators.rb
CHANGED
@@ -10,8 +10,8 @@ module Fluent
|
|
10
10
|
end
|
11
11
|
|
12
12
|
define_method('check_url') do
|
13
|
-
msg = "Expected url: '#{url}'; Actual url: '#{
|
14
|
-
valid_url = url ==
|
13
|
+
msg = "Expected url: '#{url}'; Actual url: '#{driver.url}'"
|
14
|
+
valid_url = url == driver.url
|
15
15
|
raise Fluent::Errors::UrlNotMatched, msg unless valid_url
|
16
16
|
end
|
17
17
|
end
|
@@ -21,9 +21,9 @@ module Fluent
|
|
21
21
|
raise Fluent::Errors::NoTitleForDefinition, msg if title.nil?
|
22
22
|
|
23
23
|
define_method('check_title') do
|
24
|
-
msg = "Expected title: '#{title}'; Actual title: '#{
|
25
|
-
valid_title = title ==
|
26
|
-
valid_title = title =~
|
24
|
+
msg = "Expected title: '#{title}'; Actual title: '#{driver.title}'"
|
25
|
+
valid_title = title == driver.title if title.kind_of?(String)
|
26
|
+
valid_title = title =~ driver.title if title.kind_of?(Regexp)
|
27
27
|
raise Fluent::Errors::TitleNotMatched, msg unless valid_title
|
28
28
|
valid_title
|
29
29
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module MechanizeDriver
|
4
|
+
|
5
|
+
def self.create_platform_object_for(driver)
|
6
|
+
require 'fluent/platform_mechanize/platform_object'
|
7
|
+
return MechanizeDriver::PlatformObject.new(driver)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.works_with?(driver)
|
11
|
+
driver.is_a?(::Mechanize)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Fluent::Platforms.register(:mechanize, Fluent::Platforms::MechanizeDriver)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fluent
|
2
|
+
module Platforms
|
3
|
+
module MechanizeDriver
|
4
|
+
class PlatformObject
|
5
|
+
|
6
|
+
attr_reader :driver
|
7
|
+
|
8
|
+
def initialize(driver)
|
9
|
+
@driver = driver
|
10
|
+
end
|
11
|
+
|
12
|
+
## Browser-Level Actions ##
|
13
|
+
|
14
|
+
def visit(url)
|
15
|
+
driver.get(url)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -2,13 +2,13 @@ module Fluent
|
|
2
2
|
module Platforms
|
3
3
|
module SeleniumWebDriver
|
4
4
|
|
5
|
-
def self.create_platform_object_for(
|
5
|
+
def self.create_platform_object_for(driver)
|
6
6
|
require 'fluent/platform_selenium/platform_object'
|
7
|
-
return SeleniumWebDriver::PlatformObject.new(
|
7
|
+
return SeleniumWebDriver::PlatformObject.new(driver)
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.works_with?(
|
11
|
-
|
10
|
+
def self.works_with?(driver)
|
11
|
+
driver.is_a?(::Selenium::WebDriver::Driver)
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -3,16 +3,16 @@ module Fluent
|
|
3
3
|
module SeleniumWebDriver
|
4
4
|
class PlatformObject
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :driver
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(driver)
|
9
|
+
@driver = driver
|
10
10
|
end
|
11
11
|
|
12
12
|
## Browser-Level Actions ##
|
13
13
|
|
14
14
|
def visit(url)
|
15
|
-
|
15
|
+
driver.navigate.to(url)
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
@@ -2,13 +2,13 @@ module Fluent
|
|
2
2
|
module Platforms
|
3
3
|
module WatirWebDriver
|
4
4
|
|
5
|
-
def self.create_platform_object_for(
|
5
|
+
def self.create_platform_object_for(driver)
|
6
6
|
require 'fluent/platform_watir/platform_object'
|
7
|
-
return WatirWebDriver::PlatformObject.new(
|
7
|
+
return WatirWebDriver::PlatformObject.new(driver)
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.works_with?(
|
11
|
-
|
10
|
+
def self.works_with?(driver)
|
11
|
+
driver.is_a?(::Watir::Browser)
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -3,54 +3,54 @@ module Fluent
|
|
3
3
|
module WatirWebDriver
|
4
4
|
class PlatformObject
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :driver
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(driver)
|
9
|
+
@driver = driver
|
10
10
|
end
|
11
11
|
|
12
12
|
## Browser-Level Actions ##
|
13
13
|
|
14
14
|
def visit(url)
|
15
|
-
|
15
|
+
driver.goto(url)
|
16
16
|
end
|
17
17
|
|
18
18
|
def url
|
19
|
-
|
19
|
+
driver.url
|
20
20
|
end
|
21
21
|
|
22
22
|
def remove_cookies
|
23
|
-
|
23
|
+
driver.cookies.clear
|
24
24
|
end
|
25
25
|
|
26
26
|
def refresh
|
27
|
-
|
27
|
+
driver.refresh
|
28
28
|
end
|
29
29
|
|
30
30
|
def run_script(script)
|
31
|
-
|
31
|
+
driver.execute_script(script)
|
32
32
|
end
|
33
33
|
|
34
34
|
def screenshot(file)
|
35
|
-
|
35
|
+
driver.wd.save_screenshot(file)
|
36
36
|
end
|
37
37
|
|
38
38
|
## Page-Level Actions ##
|
39
39
|
|
40
40
|
def markup
|
41
|
-
|
41
|
+
driver.html
|
42
42
|
end
|
43
43
|
|
44
44
|
def title
|
45
|
-
|
45
|
+
driver.title
|
46
46
|
end
|
47
47
|
|
48
48
|
def text
|
49
|
-
|
49
|
+
driver.text
|
50
50
|
end
|
51
51
|
|
52
52
|
def wait_until(timeout, message='wait condition was not found', &block)
|
53
|
-
|
53
|
+
driver.wait_until(timeout, message, &block)
|
54
54
|
end
|
55
55
|
|
56
56
|
## Encloser Actions ##
|
@@ -58,9 +58,9 @@ module Fluent
|
|
58
58
|
def will_alert(&block)
|
59
59
|
yield
|
60
60
|
value = nil
|
61
|
-
if
|
62
|
-
value =
|
63
|
-
|
61
|
+
if driver.alert.exists?
|
62
|
+
value = driver.alert.text
|
63
|
+
driver.alert.ok
|
64
64
|
end
|
65
65
|
value
|
66
66
|
end
|
@@ -68,18 +68,18 @@ module Fluent
|
|
68
68
|
def will_confirm(response, &block)
|
69
69
|
yield
|
70
70
|
value = nil
|
71
|
-
if
|
72
|
-
value =
|
73
|
-
response ?
|
71
|
+
if driver.alert.exists?
|
72
|
+
value = driver.alert.text
|
73
|
+
response ? driver.alert.ok : driver.alert.close
|
74
74
|
end
|
75
75
|
value
|
76
76
|
end
|
77
77
|
|
78
78
|
def will_prompt(response, &block)
|
79
|
-
cmd = "window.prompt = function(text, value) {window.__lastWatirPrompt = {message: text, default_value: value}; return #{
|
80
|
-
|
79
|
+
cmd = "window.prompt = function(text, value) {window.__lastWatirPrompt = {message: text, default_value: value}; return '#{response}';}"
|
80
|
+
driver.wd.execute_script(cmd)
|
81
81
|
yield
|
82
|
-
result =
|
82
|
+
result = driver.wd.execute_script('return window.__lastWatirPrompt')
|
83
83
|
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
|
84
84
|
result
|
85
85
|
end
|
@@ -326,7 +326,7 @@ module Fluent
|
|
326
326
|
# @return [Object] the web object identified by the action
|
327
327
|
def reference_web_element(action, object, locator)
|
328
328
|
encloser = locator.delete(:frame)
|
329
|
-
element_object =
|
329
|
+
element_object = driver.instance_eval("#{enclosed_by(encloser)}#{action}")
|
330
330
|
object.new(element_object, :platform => :watir_webdriver)
|
331
331
|
end
|
332
332
|
|
@@ -340,7 +340,7 @@ module Fluent
|
|
340
340
|
# @return [Any] the information or object returned by the action
|
341
341
|
def access_web_element(action, locator, value=nil)
|
342
342
|
encloser = locator.delete(:frame)
|
343
|
-
|
343
|
+
driver.instance_eval("#{enclosed_by(encloser)}#{action}")
|
344
344
|
end
|
345
345
|
|
346
346
|
def enclosed_by(encloser)
|
data/lib/fluent/platforms.rb
CHANGED
@@ -15,13 +15,13 @@ module Fluent
|
|
15
15
|
# decision is based on the browser that has been established for the
|
16
16
|
# execution profile.
|
17
17
|
#
|
18
|
-
# @param
|
18
|
+
# @param driver [Object] the browser to establish the platform for
|
19
19
|
# @return [Object] a platform object to execute tests against
|
20
|
-
def get_platform_for(
|
21
|
-
Fluent::Platforms.list.each_value do |
|
22
|
-
return
|
20
|
+
def get_platform_for(driver)
|
21
|
+
Fluent::Platforms.list.each_value do |drv|
|
22
|
+
return drv.create_platform_object_for(driver) if drv.works_with?(driver)
|
23
23
|
end
|
24
|
-
msg = "Unable to create a platform object for #{
|
24
|
+
msg = "Unable to create a platform object for #{driver}."
|
25
25
|
raise Fluent::Errors::UnableToCreatePlatform, msg
|
26
26
|
end
|
27
27
|
|
@@ -29,4 +29,5 @@ module Fluent
|
|
29
29
|
end
|
30
30
|
|
31
31
|
require 'fluent/platform_watir'
|
32
|
-
require 'fluent/platform_selenium'
|
32
|
+
require 'fluent/platform_selenium'
|
33
|
+
require 'fluent/platform_mechanize'
|
data/lib/fluent/version.rb
CHANGED
data/spec/factory_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'mock_app'
|
|
4
4
|
class TestFactory
|
5
5
|
include Fluent::Factory
|
6
6
|
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :driver
|
8
8
|
end
|
9
9
|
|
10
10
|
class DefinitionTest
|
@@ -16,18 +16,18 @@ end
|
|
16
16
|
describe Fluent::Factory do
|
17
17
|
before(:each) do
|
18
18
|
@factory = TestFactory.new
|
19
|
-
@factory.
|
19
|
+
@factory.driver = mock_browser_for_watir
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should create a new definition object and view it, using on_view' do
|
23
|
-
@factory.
|
23
|
+
@factory.driver.should_receive(:goto)
|
24
24
|
@factory.on_view DefinitionTest do |page|
|
25
25
|
page.should be_instance_of DefinitionTest
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should create a new definition object, using on' do
|
30
|
-
@factory.
|
30
|
+
@factory.driver.should_not_receive(:goto)
|
31
31
|
@factory.on DefinitionTest do |page|
|
32
32
|
page.should be_instance_of DefinitionTest
|
33
33
|
end
|
@@ -40,7 +40,7 @@ describe Fluent::Factory do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should create a new definition based on a string' do
|
43
|
-
@factory.
|
43
|
+
@factory.driver.should_receive(:goto)
|
44
44
|
@factory.on_view "DefinitionTest" do |page|
|
45
45
|
page.should be_instance_of DefinitionTest
|
46
46
|
end
|
data/spec/generators_spec.rb
CHANGED
@@ -17,12 +17,7 @@ describe Fluent::Generators do
|
|
17
17
|
selenium_browser.should_receive(:title).twice.and_return('Test App')
|
18
18
|
selenium_definition.check_title
|
19
19
|
end
|
20
|
-
|
21
|
-
it 'should specify and verify the page url' do
|
22
|
-
watir_browser.should_receive(:url).twice.and_return('http://localhost:4567')
|
23
|
-
watir_definition.check_url
|
24
|
-
end
|
25
|
-
|
20
|
+
|
26
21
|
it 'should raise an error if the page title is not verified' do
|
27
22
|
msg = "Expected title: 'Test App'; Actual title: 'Testing'"
|
28
23
|
watir_browser.should_receive(:title).twice.and_return('Testing')
|
@@ -38,29 +33,34 @@ describe Fluent::Generators do
|
|
38
33
|
watir_browser.should_receive(:title).twice.and_return('Symbiote')
|
39
34
|
QuickDefinition.new(watir_browser).check_title
|
40
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should specify and verify the page url' do
|
39
|
+
watir_browser.should_receive(:url).twice.and_return('http://localhost:4567')
|
40
|
+
watir_definition.check_url
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
context 'automatically looking for an element' do
|
51
|
-
it 'should specify and verify an expected elements' do
|
52
|
-
watir_definition.should_receive(:name_object).and_return(watir_browser)
|
53
|
-
watir_browser.should_receive(:when_present).with(5).and_return(watir_browser)
|
54
|
-
watir_definition.check_objects
|
55
|
-
end
|
43
|
+
it 'should allow frames to act as a context' do
|
44
|
+
watir_browser.should_receive(:frame).with(id: 'frame').and_return(watir_browser)
|
45
|
+
watir_browser.should_receive(:text_field).and_return(watir_browser)
|
46
|
+
web_element = watir_definition.framedName_text_field
|
47
|
+
web_element.should_not be_nil
|
48
|
+
web_element.should be_instance_of Fluent::WebElements::TextField
|
49
|
+
end
|
56
50
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
context 'automatically looking for an element' do
|
52
|
+
it 'should specify and verify an expected elements' do
|
53
|
+
watir_definition.should_receive(:name_object).and_return(watir_browser)
|
54
|
+
watir_browser.should_receive(:when_present).with(5).and_return(watir_browser)
|
55
|
+
watir_definition.check_objects
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should raise an error if an expected elements are not verified' do
|
59
|
+
class QuickDefinition
|
60
|
+
include Fluent
|
61
|
+
look_for :fakeLink
|
63
62
|
end
|
63
|
+
expect { QuickDefinition.new(watir_browser).check_objects }.to raise_error
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -82,6 +82,6 @@ describe Fluent::Generators do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
end
|
87
87
|
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.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.37.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mechanize
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.7.2
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.7.2
|
97
111
|
description: Provides a semantic DSL to construct a fluent interface for test execution
|
98
112
|
libraries.
|
99
113
|
email: jeffnyman@gmail.com
|
@@ -116,6 +130,8 @@ files:
|
|
116
130
|
- lib/fluent/factory.rb
|
117
131
|
- lib/fluent/generators.rb
|
118
132
|
- lib/fluent/logger.rb
|
133
|
+
- lib/fluent/platform_mechanize.rb
|
134
|
+
- lib/fluent/platform_mechanize/platform_object.rb
|
119
135
|
- lib/fluent/platform_selenium.rb
|
120
136
|
- lib/fluent/platform_selenium/platform_object.rb
|
121
137
|
- lib/fluent/platform_watir.rb
|