symbiont 0.5.0 → 0.6.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: 40e70be6d5318a81169b82ff6883cb2c11326241
4
- data.tar.gz: fc9316c0a36b95ffc727d4c3910a02e2d1ba2671
3
+ metadata.gz: ae39ecb1d2f038bed55793424d0eb7d00cf5fa44
4
+ data.tar.gz: 97e1fe74cc798c76e1eee44c75d008e3fd3498be
5
5
  SHA512:
6
- metadata.gz: 633679d53faa74a76051840a800b94ae380a80282b9870d73bb5ae02f5154d8ecadfe7fbabdf022ce1f27b1dc59d9cac7326f2bb4f51ed1cbd8e92fa3acc6db3
7
- data.tar.gz: 577844356cd9cf54fbf29f60d3884716f23c3da2379c1006ac5cb25e87d03fbf8ee8dd0263a9cb668f4ca5d13d75263b51adf61fa9ea5a4d64a98468a1cab08e
6
+ metadata.gz: a30e010e67f0afb4dbc9a2db2fb089e136d5cab838cb663306372ef7415c767f57e35cf81b637eeb76235d92724f403a793f5b4e67a622e21466d0af01a6769e
7
+ data.tar.gz: 1f9f7c9c31b0b8e84e1c102e636504e162d05fa9d02eef9cf7d1b044411bbee0f413ba8f3fb3354fcb3a50e05d807e504b03a5858d00e242e9a4a77da11efd0c
@@ -0,0 +1,35 @@
1
+ module Symbiont
2
+ module DataBuilder
3
+ extend DataReader
4
+
5
+ class << self
6
+ attr_accessor :data_source
7
+
8
+ def default_data_path
9
+ 'data'
10
+ end
11
+ end
12
+
13
+ def data_about(key, specified={})
14
+ if key.is_a?(String) && key.match(%r{/})
15
+ file, record = key.split('/')
16
+ DataBuilder.load("#{file}.yml")
17
+ else
18
+ record = key.to_s
19
+ DataBuilder.load('default.yml')
20
+ end
21
+
22
+ Symbiont::trace("DataBuilder.data_source = #{DataBuilder.data_source}")
23
+
24
+ data = DataBuilder.data_source[record]
25
+ raise ArgumentError, "Undefined key for data: #{key}" unless data
26
+
27
+ data.merge(specified)
28
+ end
29
+
30
+ alias_method :data_from, :data_about
31
+ alias_method :data_for, :data_about
32
+ alias_method :using_data_for, :data_about
33
+ alias_method :using_data_from, :data_about
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ module Symbiont
2
+ module DataReader
3
+
4
+ def data_path=(path)
5
+ @data_path = path
6
+ end
7
+
8
+ def data_path
9
+ return @data_path if @data_path
10
+ return default_data_path if self.respond_to? :default_data_path
11
+ end
12
+
13
+ # The data_source name here must match the name used for the
14
+ # class accessor in the data builder. It is this data_source
15
+ # variable that connects the reader and the builder.
16
+ def load(file)
17
+ @data_source = YAML.load_file "#{data_path}/#{file}"
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ module Symbiont
2
+ module DataSetter
3
+ # @param data [Hash] the data to use
4
+ def using(data)
5
+ data.each do |key, value|
6
+ use_data_with(key, value) if object_enabled_for(key)
7
+ end
8
+ end
9
+
10
+ alias_method :using_data, :using
11
+ alias_method :use_data, :using
12
+ alias_method :using_values, :using
13
+ alias_method :use_values, :using
14
+
15
+ def use_data_with(key, value)
16
+ element = self.send("#{key}")
17
+ self.call_method_chain("#{key}.set", value) if element.class == Watir::TextField
18
+ self.call_method_chain("#{key}.set") if element.class == Watir::Radio
19
+ self.call_method_chain("#{key}.select", value) if element.class == Watir::Select
20
+
21
+ return self.call_method_chain("#{key}.check") if element.class == Watir::CheckBox and value
22
+ return self.call_method_chain("#{key}.uncheck") if element.class == Watir::CheckBox
23
+ end
24
+
25
+ private
26
+
27
+ def object_enabled_for(key)
28
+ web_element = self.send("#{key}")
29
+ web_element.enabled? and web_element.visible?
30
+ end
31
+ end
32
+ end
@@ -6,6 +6,7 @@ module Symbiont
6
6
  def self.elements
7
7
  unless @elements
8
8
  @elements = Watir::Container.instance_methods
9
+ #@elements.delete(:extract_selector)
9
10
  end
10
11
  @elements
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
data/lib/symbiont.rb CHANGED
@@ -12,8 +12,11 @@ require 'symbiont/elements'
12
12
  require 'symbiont/accessor'
13
13
  require 'symbiont/factory'
14
14
 
15
+ require 'symbiont/data_reader'
16
+ require 'symbiont/data_setter'
17
+ require 'symbiont/data_builder'
18
+
15
19
  module Symbiont
16
-
17
20
  # The included callback is used to provide the core functionality of the
18
21
  # library to any class or module that includes the Symbiont library. The
19
22
  # calling class or module is extended with logic that the library makes
@@ -29,6 +32,9 @@ module Symbiont
29
32
  caller.send :include, Symbiont::Page
30
33
  caller.send :include, Symbiont::Accessor
31
34
 
35
+ caller.send :include, Symbiont::DataSetter
36
+ caller.send :include, Symbiont::DataBuilder
37
+
32
38
  Symbiont.trace("#{caller.class} #{caller} has attached the Symbiont.")
33
39
  end
34
40
 
@@ -58,3 +64,22 @@ def symbiont_browser(browser=:firefox)
58
64
  end
59
65
 
60
66
  alias :symbiont_browser_for :symbiont_browser
67
+
68
+ class Object
69
+ def call_method_chain(method_chain, arg=nil)
70
+ return self if method_chain.empty?
71
+ method_chain.split('.').inject(self) { |o,m|
72
+ if arg.nil?
73
+ o.send(m.intern)
74
+ else
75
+ o.send(m.intern, arg)
76
+ end
77
+ }
78
+ end
79
+ end
80
+
81
+ class Watir::CheckBox
82
+ alias_method :check, :set
83
+ alias_method :uncheck, :clear
84
+ alias_method :checked?, :set?
85
+ end
@@ -0,0 +1,3 @@
1
+ valid:
2
+ bank: BankCo
3
+ name: Jeff
@@ -0,0 +1,3 @@
1
+ valid:
2
+ bank: BankCo
3
+ name: Jeff
@@ -19,7 +19,7 @@ class ValidPage
19
19
  url_matches /:\d{4}/
20
20
  title_is 'Dialogic'
21
21
 
22
- %w(text_field button file_field textarea select_list).each do |element|
22
+ %w(text_field button file_field textarea select_list checkbox).each do |element|
23
23
  send element, :"#{element}", id: element
24
24
 
25
25
  send element, :"#{element}_proc", proc { driver.send(element, id: element) }
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::DataBuilder do
4
+ include_context :page
5
+
6
+ context 'when configuring the data path' do
7
+ it 'will default to a directory named data' do
8
+ expect(Symbiont::DataBuilder.data_path).to eq('data')
9
+ end
10
+
11
+ it 'will store a data source directory' do
12
+ Symbiont::DataBuilder.data_path = 'config/data'
13
+ expect(Symbiont::DataBuilder.data_path).to eq('config/data')
14
+ end
15
+ end
16
+
17
+ context 'when reading data files' do
18
+ it 'will read files from the data path directory' do
19
+ Symbiont::DataBuilder.data_path = 'config/data'
20
+ expect(YAML).to receive(:load_file).with('config/data/test_data_file').and_return({})
21
+ Symbiont::DataBuilder.load('test_data_file')
22
+ end
23
+
24
+ it 'will load the correct data file from the default' do
25
+ Symbiont::DataBuilder.data_path = 'spec/fixtures'
26
+ data = watir_definition.data_about 'valid'
27
+ expect(data.keys.sort).to eq(['bank','name'])
28
+ end
29
+ end
30
+
31
+ context 'when provided a file' do
32
+ it 'will load the correct data file and retrieve data' do
33
+ Symbiont::DataBuilder.data_path = 'spec/fixtures'
34
+ data = watir_definition.data_about 'mock_data/valid'
35
+ expect(data.keys.sort).to eq(['bank','name'])
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Symbiont::DataSetter do
4
+ include_context :page
5
+ include_context :element
6
+
7
+ it 'will attempt to utilize data' do
8
+ expect(watir_element).to receive(:visible?).and_return(true)
9
+ expect(watir_element).to receive(:enabled?).and_return(true)
10
+ expect(watir_browser).to receive(:text_field).with({:id => 'text_field'}).exactly(2).times.and_return(watir_element)
11
+ watir_definition.using(:text_field => 'works')
12
+ end
13
+
14
+ it 'allows methods to be chained' do
15
+ expect('testing'.call_method_chain("reverse.capitalize")).to eq('Gnitset')
16
+ expect('testing'.call_method_chain("start_with?", 't')).to be_truthy
17
+ end
18
+
19
+ end
data/symbiont.gemspec CHANGED
@@ -40,13 +40,13 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency 'rspec', '>= 3.0'
41
41
 
42
42
  spec.add_runtime_dependency 'colorize', '>= 0.7.2'
43
- spec.add_runtime_dependency 'watir-webdriver', '>= 0.6.9'
43
+ spec.add_runtime_dependency 'watir-webdriver', '>= 0.6.10'
44
44
 
45
45
  spec.post_install_message = %{
46
- (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
46
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
47
47
 
48
- Symbiont #{Symbiont::VERSION} has been installed.
48
+ Symbiont #{Symbiont::VERSION} has been installed.
49
49
 
50
- (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
50
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
51
51
  }
52
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symbiont
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.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: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.6.9
75
+ version: 0.6.10
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.6.9
82
+ version: 0.6.10
83
83
  description: "\n Symbiont is a framework that allows you to describe your application
84
84
  in\n terms of activity and page definitions. Those definitions can then be\n
85
85
  \ referenced by test libraries using the DSL that Symbiont provides. The\n DSL
@@ -105,17 +105,24 @@ files:
105
105
  - lib/symbiont.rb
106
106
  - lib/symbiont/accessor.rb
107
107
  - lib/symbiont/assertions.rb
108
+ - lib/symbiont/data_builder.rb
109
+ - lib/symbiont/data_reader.rb
110
+ - lib/symbiont/data_setter.rb
108
111
  - lib/symbiont/elements.rb
109
112
  - lib/symbiont/errors.rb
110
113
  - lib/symbiont/factory.rb
111
114
  - lib/symbiont/helpers.rb
112
115
  - lib/symbiont/pages.rb
113
116
  - lib/symbiont/version.rb
117
+ - spec/fixtures/default.yml
114
118
  - spec/fixtures/element_definitions.rb
119
+ - spec/fixtures/mock_data.yml
115
120
  - spec/fixtures/mock_drivers.rb
116
121
  - spec/fixtures/page_definitions.rb
117
122
  - spec/spec_helper.rb
118
123
  - spec/symbiont/assertion_spec.rb
124
+ - spec/symbiont/data_builder_spec.rb
125
+ - spec/symbiont/data_setter_spec.rb
119
126
  - spec/symbiont/driver_spec.rb
120
127
  - spec/symbiont/element_spec.rb
121
128
  - spec/symbiont/factory_spec.rb
@@ -126,9 +133,9 @@ homepage: https://github.com/jnyman/symbiont
126
133
  licenses:
127
134
  - MIT
128
135
  metadata: {}
129
- post_install_message: "\n (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
130
- (::)\n\n Symbiont 0.5.0 has been installed.\n\n (::) (::) (::) (::) (::)
131
- (::) (::) (::) (::) (::) (::) (::)\n "
136
+ post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n
137
+ \ Symbiont 0.6.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::)
138
+ (::) (::) (::) (::)\n "
132
139
  rdoc_options: []
133
140
  require_paths:
134
141
  - lib
@@ -150,11 +157,15 @@ signing_key:
150
157
  specification_version: 4
151
158
  summary: An Endosymbiotic Facultative Semantically Clean Fluent Interface Test Framework
152
159
  test_files:
160
+ - spec/fixtures/default.yml
153
161
  - spec/fixtures/element_definitions.rb
162
+ - spec/fixtures/mock_data.yml
154
163
  - spec/fixtures/mock_drivers.rb
155
164
  - spec/fixtures/page_definitions.rb
156
165
  - spec/spec_helper.rb
157
166
  - spec/symbiont/assertion_spec.rb
167
+ - spec/symbiont/data_builder_spec.rb
168
+ - spec/symbiont/data_setter_spec.rb
158
169
  - spec/symbiont/driver_spec.rb
159
170
  - spec/symbiont/element_spec.rb
160
171
  - spec/symbiont/factory_spec.rb