selenium-webdriver-viewers 0.0.1 → 0.0.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,5 +1,4 @@
1
1
  require 'selenium-webdriver'
2
- require 'selenium/webdriver/navigation'
3
2
 
4
3
  module BrowserInstance
5
4
 
@@ -40,8 +40,7 @@ module WebViewer
40
40
 
41
41
  def element_as_viewer(*arguments)
42
42
  viewer = @output_type.new
43
- base_element_proc = lambda { @element_reader.get(*arguments) }
44
- viewer.instance_variable_set(:@base_element_proc, base_element_proc)
43
+ viewer.base_element = lambda { @element_reader.get(*arguments) }
45
44
  viewer
46
45
  end
47
46
 
data/lib/viewer.rb CHANGED
@@ -15,7 +15,8 @@ module WebViewer
15
15
  :enabled?, :find_element, :find_elements, :first, :hover, :location, :ref, :select, :selected?,
16
16
  :send_key, :send_keys, :size, :style, :submit, :tag_name, :text, :toggle, :value,
17
17
  :element_present?, :wait_for_element_present
18
-
18
+
19
+ attr_writer :base_element
19
20
 
20
21
  def self.included(target)
21
22
  super
@@ -23,8 +24,8 @@ module WebViewer
23
24
  end
24
25
 
25
26
  def base_element
26
- return @base_element_proc.call if @base_element_proc
27
- browser.find_element(:tag_name, 'html')
27
+ return @base_element.call if @base_element.respond_to?(:call)
28
+ return @base_element || browser.find_element(:tag_name, 'html')
28
29
  end
29
30
 
30
31
  def showing?
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{selenium-webdriver-viewers}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Collas"]
12
- s.date = %q{2010-12-16}
12
+ s.date = %q{2010-12-20}
13
13
  s.description = %q{ This gem makes it easy to create page and web viewer objects for use by tests that use selenium-webdriver. By
14
14
  using page and viewer objects, you can decouple your tests from the html details so that they can focus
15
15
  instead on describing the behaviour of your application.
@@ -46,27 +46,27 @@ describe WebViewer::ElementValueReader do
46
46
 
47
47
  end
48
48
 
49
- describe ('and the type is :auto', :output_type => :auto) { it_should_behave_like UnimplementedOutputType }
50
- describe ('and the type is :link', :output_type => :link) { it_should_behave_like UnimplementedOutputType }
51
- describe ('and the type is :select_by_text', :output_type => :select_by_text) { it_should_behave_like UnimplementedOutputType }
52
- describe ('and the type is :select_by_value', :output_type => :select_by_value) { it_should_behave_like UnimplementedOutputType }
49
+ describe('and the type is :auto', :output_type => :auto) { it_should_behave_like UnimplementedOutputType }
50
+ describe('and the type is :link', :output_type => :link) { it_should_behave_like UnimplementedOutputType }
51
+ describe('and the type is :select_by_text', :output_type => :select_by_text) { it_should_behave_like UnimplementedOutputType }
52
+ describe('and the type is :select_by_value', :output_type => :select_by_value) { it_should_behave_like UnimplementedOutputType }
53
53
 
54
54
  describe 'and the output type is a class' do
55
55
 
56
- class FakeViewer
57
- attr :base_element_proc
58
- end
59
-
60
56
  before do
61
- @value_reader = WebViewer::ElementValueReader.new(@element_reader, FakeViewer)
57
+ output_viewer_class = Class.new(Object)
58
+ @output_viewer = stub('a different viewer', :base_element= => nil)
59
+ output_viewer_class.stub(:new).and_return(@output_viewer)
60
+ @value_reader = WebViewer::ElementValueReader.new(@element_reader, output_viewer_class)
62
61
  end
63
62
 
64
63
  it 'should return an instance of the specified class' do
65
- @value_reader.get.should be_instance_of(FakeViewer)
64
+ @value_reader.get.should == @output_viewer
66
65
  end
67
66
 
68
- it 'should put a base_element_proc instance value into the returned object' do
69
- @value_reader.get.base_element_proc.should_not be_nil
67
+ it 'should put a base_element proc into the returned object' do
68
+ @output_viewer.should_receive(:base_element=).with(a_kind_of(Proc))
69
+ @value_reader.get
70
70
  end
71
71
 
72
72
  end
@@ -134,24 +134,28 @@ describe WebViewer::ElementValueReader do
134
134
 
135
135
  end
136
136
 
137
- describe ('and the type is :auto', :output_type => :auto) { it_should_behave_like UnimplementedOutputType }
138
- describe ('and the type is :link', :output_type => :link) { it_should_behave_like UnimplementedOutputType }
139
- describe ('and the type is :select_by_text', :output_type => :select_by_text) { it_should_behave_like UnimplementedOutputType }
140
- describe ('and the type is :select_by_value', :output_type => :select_by_value) { it_should_behave_like UnimplementedOutputType }
137
+ describe('and the type is :auto', :output_type => :auto) { it_should_behave_like UnimplementedOutputType }
138
+ describe('and the type is :link', :output_type => :link) { it_should_behave_like UnimplementedOutputType }
139
+ describe('and the type is :select_by_text', :output_type => :select_by_text) { it_should_behave_like UnimplementedOutputType }
140
+ describe('and the type is :select_by_value', :output_type => :select_by_value) { it_should_behave_like UnimplementedOutputType }
141
141
 
142
142
  describe 'and the output type is a class' do
143
143
 
144
144
  before do
145
- @value_reader = WebViewer::ElementValueReader.new(@element_reader, FakeViewer)
145
+ output_viewer_class = Class.new(Object)
146
+ @output_viewer = stub('a different viewer', :base_element= => nil)
147
+ output_viewer_class.stub(:new).and_return(@output_viewer)
148
+ @value_reader = WebViewer::ElementValueReader.new(@element_reader, output_viewer_class)
146
149
  end
147
150
 
148
151
  it 'should return an instance of the specified class' do
149
- @value_reader[1, 2].should be_instance_of(FakeViewer)
152
+ @value_reader[1, 2].should == @output_viewer
150
153
  end
151
154
 
152
- it 'should put a base_element_proc instance value that gets the element from the reader into the returned object' do
155
+ it 'should put a base_element proc that gets the element from the reader into the returned object' do
156
+ @output_viewer.stub(:base_element=) { |assigned_base_element_proc| assigned_base_element_proc.call }
153
157
  @element_reader.should_receive(:get).with(1, 2)
154
- @value_reader[1, 2].base_element_proc.call
158
+ @value_reader[1, 2]
155
159
  end
156
160
 
157
161
  end
data/spec/viewer_spec.rb CHANGED
@@ -4,6 +4,20 @@ describe WebViewer, 'included in a class' do
4
4
 
5
5
  before do
6
6
  @viewer_class = Class.new(Object).extend(WebViewer)
7
+ @viewer = @viewer_class.new
8
+ @fake_browser = stub
9
+ @viewer.stub(:browser).and_return(@fake_browser)
10
+ end
11
+
12
+ describe '#base_element' do
13
+
14
+ it 'should return the base element if one has been assigned' do
15
+ pending
16
+ fake_element = stub('fake element')
17
+ @viewer.base_element = fake_element
18
+ @viewer.base_element.should == fake_element
19
+ end
20
+
7
21
  end
8
22
 
9
23
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver-viewers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Collas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-16 00:00:00 +11:00
18
+ date: 2010-12-20 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency