fluent 0.6.0 → 0.7.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 +4 -4
- data/HISTORY.md +11 -0
- data/README.md +1 -0
- data/lib/fluent.rb +3 -0
- data/lib/fluent/data_config.rb +49 -0
- data/lib/fluent/enclosers.rb +31 -0
- data/lib/fluent/errors.rb +2 -0
- data/lib/fluent/evaluators.rb +12 -0
- data/lib/fluent/factory.rb +9 -2
- data/lib/fluent/platform_watir/platform_object.rb +12 -0
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/workflows.rb +75 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7b289657c5c2713886307bdc023c6fdcaf9bbcb
|
4
|
+
data.tar.gz: 38bb9627501b8de39e237a5394075f2777160098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a092ca78215b22f6b0b62918db49bf3adf109133dc3552df6c0c05cddc52b86863b06121a0a2403c5e62a399a5532cac4f8feee00b215f02fdcb7c9f0cebdd08
|
7
|
+
data.tar.gz: a640ce119c147c73d3acf21f50b5e6ad1bbef349de59b3d9b9ec7dcbcb9a7ad4568d3c8df4394b641ac6218de7574bd3c6dc93a3825429a1ffa0250201e5f952
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
Change Log and History
|
2
2
|
======================
|
3
3
|
|
4
|
+
Version 0.7.0 / 2013-12-06
|
5
|
+
--------------------------
|
6
|
+
|
7
|
+
This release adds some key new features:
|
8
|
+
|
9
|
+
* The ability to create workflows and have those workflows automatically executed. The workflow mechanism relies entirely on the factory module in order to create the context by which a set of actions can be taken against a page definition or activity definition.
|
10
|
+
|
11
|
+
* Two new enclosers have been added: "within_modal" and "within_window". These allow you to work within the context of a modal box or a different browser window.
|
12
|
+
|
13
|
+
* A data configuration module has been added that allows you to more easily call upon environment or configuration data as part of your test execution.
|
14
|
+
|
4
15
|
Version 0.6.0 / 2013-11-26
|
5
16
|
--------------------------
|
6
17
|
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@ Fluent
|
|
5
5
|
[](https://gemnasium.com/jnyman/fluent)
|
6
6
|
[](http://badge.fury.io/rb/fluent)
|
7
7
|
[](https://coveralls.io/r/jnyman/fluent)
|
8
|
+
[](https://codeclimate.com/github/jnyman/fluent)
|
8
9
|
|
9
10
|
Fluent provides a semantic domain-specific language that can be used to construct a fluent interface for test execution libraries.
|
10
11
|
|
data/lib/fluent.rb
CHANGED
@@ -7,8 +7,10 @@ require 'fluent/enclosers'
|
|
7
7
|
require 'fluent/evaluators'
|
8
8
|
require 'fluent/generators'
|
9
9
|
require 'fluent/locators'
|
10
|
+
require 'fluent/workflows'
|
10
11
|
require 'fluent/data_setter'
|
11
12
|
require 'fluent/data_builder'
|
13
|
+
require 'fluent/data_config'
|
12
14
|
|
13
15
|
require 'watir-webdriver'
|
14
16
|
require 'selenium-webdriver'
|
@@ -21,6 +23,7 @@ module Fluent
|
|
21
23
|
include Locators
|
22
24
|
include DataSetter
|
23
25
|
include DataBuilder
|
26
|
+
include DataConfig
|
24
27
|
|
25
28
|
# Browser drivers will be:
|
26
29
|
# [Watir::Browser] or [Selenium::WebDriver::Driver]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'fluent/data_reader'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
module DataConfigHelper
|
5
|
+
|
6
|
+
# This is being used in order to allow a call to any key in a config
|
7
|
+
# file. The key will be treated as a method. Since no such method
|
8
|
+
# will exist, the method_missing call will handle finding the key
|
9
|
+
# in a file.
|
10
|
+
def method_missing(*args, &block)
|
11
|
+
determine_data_source unless @data_source
|
12
|
+
|
13
|
+
key = args.first
|
14
|
+
|
15
|
+
value = @data_source[key.to_s]
|
16
|
+
value = args[1] unless value
|
17
|
+
|
18
|
+
value
|
19
|
+
end
|
20
|
+
|
21
|
+
# Determines what data source to use. If this is being called, it
|
22
|
+
# means no data source was specified. If an environment variable
|
23
|
+
# has been set, that will be used. If no data source can be
|
24
|
+
# established, a default data file will be referenced.
|
25
|
+
def determine_data_source
|
26
|
+
@data_source = nil
|
27
|
+
@data_source = YAML.load_file "#{data_path}/#{ENV['FLUENT_CONFIG_FILE']}" if ENV['FLUENT_CONFIG_FILE']
|
28
|
+
|
29
|
+
Fluent::DataConfig.load 'config-data.yml' if @data_source.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
module DataConfig
|
35
|
+
extend DataReader
|
36
|
+
extend DataConfigHelper
|
37
|
+
|
38
|
+
class << self
|
39
|
+
attr_accessor :data_source
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.default_data_path
|
43
|
+
'common/data'
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
data/lib/fluent/enclosers.rb
CHANGED
@@ -31,5 +31,36 @@ module Fluent
|
|
31
31
|
def will_prompt(response, &block)
|
32
32
|
platform.will_prompt(response, &block)
|
33
33
|
end
|
34
|
+
|
35
|
+
# Used to identify a web element or action on a web element as existing
|
36
|
+
# within an enclosing window object. The window can be referenced using
|
37
|
+
# either the title attribute of the window or a direct URL. The URL does
|
38
|
+
# not have to be the entire URL; it can just be a page name.
|
39
|
+
#
|
40
|
+
# @param locator [Hash] the :title or :url of the window
|
41
|
+
# @param block [Proc] any code that should be executed as an
|
42
|
+
# action on or within the window
|
43
|
+
def within_window(locator, &block)
|
44
|
+
platform.within_window(locator, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
alias_method :select_window, :within_window
|
48
|
+
alias_method :attach_to, :within_window
|
49
|
+
|
50
|
+
# Used to identify a web element as existing within an enclosing object
|
51
|
+
# like a modal dialog box. What this does is override the normal call to
|
52
|
+
# showModalDialog and opens a window instead. In order to use this new
|
53
|
+
# window, you have to attach to it.
|
54
|
+
def within_modal(&block)
|
55
|
+
convert_modal_to_window = %Q{
|
56
|
+
window.showModalDialog = function(sURL, vArguments, sFeatures) {
|
57
|
+
window.dialogArguments = vArguments;
|
58
|
+
modalWin = window.open(sURL, 'modal', sFeatures);
|
59
|
+
return modalWin;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
driver.execute_script(convert_modal_to_window)
|
63
|
+
yield if block_given?
|
64
|
+
end
|
34
65
|
end
|
35
66
|
end
|
data/lib/fluent/errors.rb
CHANGED
data/lib/fluent/evaluators.rb
CHANGED
@@ -2,6 +2,12 @@ module Fluent
|
|
2
2
|
module Evaluators
|
3
3
|
|
4
4
|
## Browser-Level Actions ##
|
5
|
+
|
6
|
+
def visit(url)
|
7
|
+
platform.visit(url)
|
8
|
+
end
|
9
|
+
|
10
|
+
alias_method :navigate_to, :visit
|
5
11
|
|
6
12
|
def url
|
7
13
|
platform.url
|
@@ -47,6 +53,12 @@ module Fluent
|
|
47
53
|
sleep value
|
48
54
|
end
|
49
55
|
|
56
|
+
def focused
|
57
|
+
platform.focused
|
58
|
+
end
|
59
|
+
|
60
|
+
alias_method :what_has_focus?, :focused
|
61
|
+
|
50
62
|
# Attempts to wait for pending jQuery requests and indicate if the
|
51
63
|
# requests did not occur in a given time period.
|
52
64
|
#
|
data/lib/fluent/factory.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'fluent/workflows'
|
2
|
+
|
1
3
|
module Fluent
|
2
4
|
module Factory
|
3
|
-
|
5
|
+
include Workflow
|
6
|
+
|
4
7
|
# Creates a definition context for actions. If an existing context
|
5
8
|
# exists, that context will be re-used.
|
6
9
|
#
|
@@ -11,7 +14,11 @@ module Fluent
|
|
11
14
|
def on(definition, visit=false, &block)
|
12
15
|
definition = get_object_for(definition) if definition.is_a? String
|
13
16
|
|
14
|
-
|
17
|
+
if @active.kind_of?(definition)
|
18
|
+
block.call @active if block
|
19
|
+
return @active
|
20
|
+
end
|
21
|
+
|
15
22
|
@active = definition.new(@driver, visit)
|
16
23
|
block.call @active if block
|
17
24
|
|
@@ -53,6 +53,13 @@ module Fluent
|
|
53
53
|
driver.wait_until(timeout, message, &block)
|
54
54
|
end
|
55
55
|
|
56
|
+
def focused
|
57
|
+
web_element = driver.execute_script('return document.activeElement')
|
58
|
+
type = web_element.type.to_sym if web_element.tag_name.to_sym == :input
|
59
|
+
object_class = ::Fluent::WebElements.get_class_for(web_element.tag_name, type)
|
60
|
+
object_class.new(web_element, :platform => :watir_webdriver)
|
61
|
+
end
|
62
|
+
|
56
63
|
## Encloser Actions ##
|
57
64
|
|
58
65
|
def will_alert(&block)
|
@@ -84,6 +91,11 @@ module Fluent
|
|
84
91
|
result
|
85
92
|
end
|
86
93
|
|
94
|
+
def within_window(locator, &block)
|
95
|
+
identifier = {locator.keys.first => /#{Regexp.escape(locator.values.first)}/}
|
96
|
+
driver.window(identifier).use(&block)
|
97
|
+
end
|
98
|
+
|
87
99
|
## Generator Actions ##
|
88
100
|
|
89
101
|
def link(locator)
|
data/lib/fluent/version.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
module Fluent
|
2
|
+
module WorkflowPaths
|
3
|
+
def paths
|
4
|
+
@paths
|
5
|
+
end
|
6
|
+
|
7
|
+
def paths=(workflow_path)
|
8
|
+
@paths = workflow_path
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Workflow
|
13
|
+
|
14
|
+
def self.included(caller)
|
15
|
+
Fluent.trace("#{caller.class} #{caller} is using workflows.")
|
16
|
+
caller.extend WorkflowPaths
|
17
|
+
@def_caller = caller
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.def_caller
|
21
|
+
@def_caller
|
22
|
+
end
|
23
|
+
|
24
|
+
# This provides a workflow for a given workflow path, using a
|
25
|
+
# specific definition that is part of that workflow path.
|
26
|
+
#
|
27
|
+
# @param definition [Object] definition object using the workflow
|
28
|
+
# @param path_name [Hash] the name of the path to be used
|
29
|
+
# @param block [Proc] a block to be executed as part of the workflow
|
30
|
+
# @return [Object] the definition being interacted with
|
31
|
+
def workflow_for(definition, path_name = {:using => :default}, &block)
|
32
|
+
path_name[:using] = :default unless path_name[:using]
|
33
|
+
|
34
|
+
path_workflow = workflow_path_for(path_name)
|
35
|
+
|
36
|
+
workflow_goal = work_item_index_for(path_workflow, definition)
|
37
|
+
|
38
|
+
workflow_start = path_name[:from] ? path_workflow.find_index { |item| item[0] == path_name[:from]} : 0
|
39
|
+
|
40
|
+
perform_workflow(path_workflow[workflow_start..workflow_goal])
|
41
|
+
|
42
|
+
on(definition, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def workflow_path_for(path_name)
|
46
|
+
# Since I am dealing with an array that contains a hash that, in
|
47
|
+
# turn, contains an array of arrays, below I need to make sure I
|
48
|
+
# index into the array before keying into the hash. That's the
|
49
|
+
# purpose of the [0].
|
50
|
+
path = Workflow.def_caller.paths[0][path_name[:using]]
|
51
|
+
|
52
|
+
raise Fluent::Errors::WorkflowPathNotFound,
|
53
|
+
"Workflow path '#{path_name[:using].to_s}' not found." unless path
|
54
|
+
|
55
|
+
path
|
56
|
+
end
|
57
|
+
|
58
|
+
def work_item_index_for(path_workflow, definition)
|
59
|
+
path_workflow.find_index { |item| item[0] == definition }
|
60
|
+
end
|
61
|
+
|
62
|
+
def perform_workflow(definitions)
|
63
|
+
definitions.each do |definition, action, *args|
|
64
|
+
active = on(definition)
|
65
|
+
|
66
|
+
raise Fluent::Errors::WorkflowActionNotFound,
|
67
|
+
"Workflow action '#{action}' not defined on #{definition}." unless active.respond_to? action
|
68
|
+
|
69
|
+
active.send action unless args
|
70
|
+
active.send action, *args if args
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
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.7.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-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: require_all
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: watir-webdriver
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +116,7 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- lib/fluent/data_builder.rb
|
119
|
+
- lib/fluent/data_config.rb
|
119
120
|
- lib/fluent/data_reader.rb
|
120
121
|
- lib/fluent/data_setter.rb
|
121
122
|
- lib/fluent/enclosers.rb
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- lib/fluent/web_elements/unordered_list.rb
|
169
170
|
- lib/fluent/web_elements/web_element.rb
|
170
171
|
- lib/fluent/web_elements.rb
|
172
|
+
- lib/fluent/workflows.rb
|
171
173
|
- lib/fluent.rb
|
172
174
|
- LICENSE.txt
|
173
175
|
- README.md
|