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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53bf5738dcf39690dc07ba2dddb31c18a6258738
4
- data.tar.gz: 6d0786f388d7317f0b973da560f9acb1e9fb72e6
3
+ metadata.gz: 83879b044030a03d6874a004d81a15013eb36507
4
+ data.tar.gz: 8d373bac702368bb6b66af1f762a0e95d527ceb9
5
5
  SHA512:
6
- metadata.gz: 44341db669c208f238ee6ea76845f7de15d441a116bfd7865c51d0bcf1230acc7d260416c254f1c543b9bf2af5bb83f93a7d368466a7748d7ddb9e508db9b879
7
- data.tar.gz: 9153f09f1b8a7b31e847ae69e3de19281dd5543f4dbd51da2a77f479e2b387f5f8182760bdc5209ceff11fc5938e068fe42a379f65f2c28ca0c7363d1ecc7fc0
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
 
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_runtime_dependency 'watir-webdriver', '0.6.4'
31
31
  spec.add_runtime_dependency 'selenium-webdriver', '2.37.0'
32
+ spec.add_runtime_dependency 'mechanize', '2.7.2'
32
33
  end
@@ -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 :browser
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 browser [Object] a browser instance with a tool driver
55
- def initialize(browser=nil, visit=nil)
56
- @browser = browser
57
- @browser = Watir::Browser.new if browser.nil? or browser == :watir
58
- @browser = Selenium::WebDriver.for :firefox if browser == :selenium
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 @browser
61
+ establish_platform_object_for @driver
63
62
 
64
63
  view if visit && respond_to?(:view)
65
64
  end
@@ -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 browser.execute_script('return jQuery.active') == 0
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
@@ -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(@browser, visit)
13
+ @active = definition.new(@driver, visit)
14
14
  block.call @active if block
15
15
 
16
16
  @active
@@ -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: '#{browser.url}'"
14
- valid_url = url == browser.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: '#{browser.title}'"
25
- valid_title = title == browser.title if title.kind_of?(String)
26
- valid_title = title =~ browser.title if title.kind_of?(Regexp)
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(browser)
5
+ def self.create_platform_object_for(driver)
6
6
  require 'fluent/platform_selenium/platform_object'
7
- return SeleniumWebDriver::PlatformObject.new(browser)
7
+ return SeleniumWebDriver::PlatformObject.new(driver)
8
8
  end
9
9
 
10
- def self.works_with?(browser)
11
- browser.is_a?(::Selenium::WebDriver::Driver)
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 :browser
6
+ attr_reader :driver
7
7
 
8
- def initialize(browser)
9
- @browser = browser
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
- browser.navigate.to(url)
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(browser)
5
+ def self.create_platform_object_for(driver)
6
6
  require 'fluent/platform_watir/platform_object'
7
- return WatirWebDriver::PlatformObject.new(browser)
7
+ return WatirWebDriver::PlatformObject.new(driver)
8
8
  end
9
9
 
10
- def self.works_with?(browser)
11
- browser.is_a?(::Watir::Browser)
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 :browser
6
+ attr_reader :driver
7
7
 
8
- def initialize(browser)
9
- @browser = browser
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
- browser.goto(url)
15
+ driver.goto(url)
16
16
  end
17
17
 
18
18
  def url
19
- browser.url
19
+ driver.url
20
20
  end
21
21
 
22
22
  def remove_cookies
23
- browser.cookies.clear
23
+ driver.cookies.clear
24
24
  end
25
25
 
26
26
  def refresh
27
- browser.refresh
27
+ driver.refresh
28
28
  end
29
29
 
30
30
  def run_script(script)
31
- browser.execute_script(script)
31
+ driver.execute_script(script)
32
32
  end
33
33
 
34
34
  def screenshot(file)
35
- browser.wd.save_screenshot(file)
35
+ driver.wd.save_screenshot(file)
36
36
  end
37
37
 
38
38
  ## Page-Level Actions ##
39
39
 
40
40
  def markup
41
- browser.html
41
+ driver.html
42
42
  end
43
43
 
44
44
  def title
45
- browser.title
45
+ driver.title
46
46
  end
47
47
 
48
48
  def text
49
- browser.text
49
+ driver.text
50
50
  end
51
51
 
52
52
  def wait_until(timeout, message='wait condition was not found', &block)
53
- browser.wait_until(timeout, message, &block)
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 browser.alert.exists?
62
- value = browser.alert.text
63
- browser.alert.ok
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 browser.alert.exists?
72
- value = browser.alert.text
73
- response ? browser.alert.ok : browser.alert.close
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 #{!!response};}"
80
- browser.wd.execute_script(cmd)
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 = browser.wd.execute_script('return window.__lastWatirPrompt')
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 = browser.instance_eval("#{enclosed_by(encloser)}#{action}")
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
- browser.instance_eval("#{enclosed_by(encloser)}#{action}")
343
+ driver.instance_eval("#{enclosed_by(encloser)}#{action}")
344
344
  end
345
345
 
346
346
  def enclosed_by(encloser)
@@ -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 browser [Object] the browser to establish the platform for
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(browser)
21
- Fluent::Platforms.list.each_value do |driver|
22
- return driver.create_platform_object_for(browser) if driver.works_with?(browser)
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 #{browser}."
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'
@@ -1,3 +1,3 @@
1
1
  module Fluent
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -4,7 +4,7 @@ require 'mock_app'
4
4
  class TestFactory
5
5
  include Fluent::Factory
6
6
 
7
- attr_accessor :browser
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.browser = mock_browser_for_watir
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.browser.should_receive(:goto)
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.browser.should_not_receive(:goto)
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.browser.should_receive(:goto)
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
@@ -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
- it 'should allow frames to act as a context' do
43
- watir_browser.should_receive(:frame).with(id: 'frame').and_return(watir_browser)
44
- watir_browser.should_receive(:text_field).and_return(watir_browser)
45
- web_element = watir_definition.framedName_text_field
46
- web_element.should_not be_nil
47
- web_element.should be_instance_of Fluent::WebElements::TextField
48
- end
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
- it 'should raise an error if an expected elements are not verified' do
58
- class QuickDefinition
59
- include Fluent
60
- look_for :fakeLink
61
- end
62
- expect { QuickDefinition.new(watir_browser).check_objects }.to raise_error
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.3.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-10-29 00:00:00.000000000 Z
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