page_magic 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,13 +1,14 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "watir-webdriver"
4
3
  gem 'capybara'
5
4
  gem 'wait'
6
5
 
7
6
  group :test do
7
+ gem "watir-webdriver"
8
8
  gem 'sinatra'
9
9
  gem "rspec", require: 'rspec/core/rake_task'
10
10
  gem "simplecov", require: false
11
+ gem 'poltergeist'
11
12
  end
12
13
 
13
14
  group :development do
data/Gemfile.lock CHANGED
@@ -9,8 +9,9 @@ GEM
9
9
  xpath (~> 2.0)
10
10
  childprocess (0.3.9)
11
11
  ffi (~> 1.0, >= 1.0.11)
12
+ cliver (0.2.2)
12
13
  diff-lcs (1.2.4)
13
- ffi (1.8.1)
14
+ ffi (1.9.3)
14
15
  git (1.2.5)
15
16
  jeweler (1.8.4)
16
17
  bundler (~> 1.0)
@@ -23,6 +24,11 @@ GEM
23
24
  multi_json (1.7.3)
24
25
  nokogiri (1.6.0)
25
26
  mini_portile (~> 0.5.0)
27
+ poltergeist (1.4.1)
28
+ capybara (~> 2.1.0)
29
+ cliver (~> 0.2.1)
30
+ multi_json (~> 1.0)
31
+ websocket-driver (>= 0.2.0)
26
32
  rack (1.5.2)
27
33
  rack-protection (1.5.0)
28
34
  rack
@@ -40,10 +46,10 @@ GEM
40
46
  diff-lcs (>= 1.1.3, < 2.0)
41
47
  rspec-mocks (2.14.4)
42
48
  rubyzip (0.9.9)
43
- selenium-webdriver (2.32.1)
49
+ selenium-webdriver (2.35.1)
44
50
  childprocess (>= 0.2.5)
45
51
  multi_json (~> 1.0)
46
- rubyzip
52
+ rubyzip (< 1.0.0)
47
53
  websocket (~> 1.0.4)
48
54
  simplecov (0.7.1)
49
55
  multi_json (~> 1.0)
@@ -58,6 +64,7 @@ GEM
58
64
  watir-webdriver (0.6.4)
59
65
  selenium-webdriver (>= 2.18.0)
60
66
  websocket (1.0.7)
67
+ websocket-driver (0.3.0)
61
68
  xpath (2.0.0)
62
69
  nokogiri (~> 1.3)
63
70
 
@@ -67,6 +74,7 @@ PLATFORMS
67
74
  DEPENDENCIES
68
75
  capybara
69
76
  jeweler (~> 1.8.4)
77
+ poltergeist
70
78
  rspec
71
79
  simplecov
72
80
  sinatra
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.8
1
+ 0.8.9
data/lib/page_magic.rb CHANGED
@@ -14,16 +14,34 @@ require 'page_magic/page_section'
14
14
  module PageMagic
15
15
  class << self
16
16
  def session browser=nil, options = {}
17
- if browser
18
- Capybara.register_driver browser do |app|
19
- options[:browser] = browser
20
- Capybara::Selenium::Driver.new(app, options)
21
- end
22
- Session.new(Capybara::Session.new(browser, nil))
17
+ if browser.is_a?(Hash)
18
+ Session.new(Capybara::Session.new(:rack_test, browser[:application]))
23
19
  else
24
- Capybara.reset!
25
- Session.new(Capybara.current_session)
20
+ if browser
21
+ application = options.delete(:application)
22
+
23
+ Capybara.register_driver browser do |app|
24
+ options[:browser] = browser
25
+ case browser
26
+ when :poltergeist
27
+ require 'capybara/poltergeist'
28
+ Capybara::Poltergeist::Driver.new(app)
29
+ when :rack_test
30
+ Capybara::RackTest::Driver.new(app, options)
31
+ else
32
+ require 'watir-webdriver'
33
+ Capybara::Selenium::Driver.new(app, options)
34
+ end
35
+
36
+ end
37
+
38
+ Session.new(Capybara::Session.new(browser, application))
39
+ else
40
+ Capybara.reset!
41
+ Session.new(Capybara.current_session)
42
+ end
26
43
  end
44
+
27
45
  end
28
46
 
29
47
  def included clazz
data/page_magic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "page_magic"
8
- s.version = "0.8.8"
8
+ s.version = "0.8.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leon Davis"]
12
- s.date = "2013-11-10"
12
+ s.date = "2013-11-13"
13
13
  s.description = "Framework for modeling and interacting with webpages which wraps capybara"
14
14
  s.email = "info@lad-tech.com"
15
15
  s.extra_rdoc_files = [
@@ -50,27 +50,24 @@ Gem::Specification.new do |s|
50
50
  s.homepage = "https://github.com/ladtech/page_magic"
51
51
  s.licenses = ["ruby"]
52
52
  s.require_paths = ["lib"]
53
- s.rubygems_version = "1.8.25"
53
+ s.rubygems_version = "1.8.10"
54
54
  s.summary = "Framework for modeling and interacting with webpages"
55
55
 
56
56
  if s.respond_to? :specification_version then
57
57
  s.specification_version = 3
58
58
 
59
59
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<watir-webdriver>, [">= 0"])
61
60
  s.add_runtime_dependency(%q<capybara>, [">= 0"])
62
61
  s.add_runtime_dependency(%q<wait>, [">= 0"])
63
62
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
64
63
  s.add_runtime_dependency(%q<watir-webdriver>, [">= 0"])
65
64
  else
66
- s.add_dependency(%q<watir-webdriver>, [">= 0"])
67
65
  s.add_dependency(%q<capybara>, [">= 0"])
68
66
  s.add_dependency(%q<wait>, [">= 0"])
69
67
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
70
68
  s.add_dependency(%q<watir-webdriver>, [">= 0"])
71
69
  end
72
70
  else
73
- s.add_dependency(%q<watir-webdriver>, [">= 0"])
74
71
  s.add_dependency(%q<capybara>, [">= 0"])
75
72
  s.add_dependency(%q<wait>, [">= 0"])
76
73
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
@@ -1,9 +1,21 @@
1
1
  require 'spec_helper'
2
+ require 'capybara/rspec'
3
+ require 'sinatra/base'
2
4
 
3
5
  describe 'page magic' do
6
+ include Capybara::DSL
4
7
 
5
8
  describe 'class level' do
9
+ let(:app_class) do
10
+ Class.new do
11
+ def call env
12
+ [200, {}, ["hello world!!"]]
13
+ end
14
+ end
15
+ end
16
+
6
17
  context 'session' do
18
+
7
19
  it 'should setup a session using the specified browser' do
8
20
  Capybara::Session.should_receive(:new).with(:chrome, nil).and_return(:chrome_session)
9
21
 
@@ -18,6 +30,31 @@ describe 'page magic' do
18
30
  session = PageMagic.session
19
31
  session.browser.mode.should == :rack_test
20
32
  end
33
+
34
+ it 'should use the supplied Rack application' do
35
+ session = PageMagic.session(application: app_class.new)
36
+ session.browser.visit('/')
37
+ session.browser.text.should == 'hello world!!'
38
+ end
39
+
40
+ it 'should use the rack app with a given browser' do
41
+ session = PageMagic.session(:rack_test, application: app_class.new)
42
+ session.browser.mode.should == :rack_test
43
+ session.browser.visit('/')
44
+ session.browser.text.should == 'hello world!!'
45
+ end
46
+
47
+ context 'supported browsers' do
48
+ it 'should support the poltergeist browser' do
49
+ session = PageMagic.session(:poltergeist, application: app_class.new)
50
+ session.browser.driver.is_a?(Capybara::Poltergeist::Driver).should be_true
51
+ end
52
+
53
+ it 'should support the selenium browser' do
54
+ session = PageMagic.session(:firefox, application: app_class.new)
55
+ session.browser.driver.is_a?(Capybara::Selenium::Driver).should be_true
56
+ end
57
+ end
21
58
  end
22
59
  end
23
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,27 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-10 00:00:00.000000000 Z
12
+ date: 2013-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: watir-webdriver
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
14
  - !ruby/object:Gem::Dependency
31
15
  name: capybara
32
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &10020580 !ruby/object:Gem::Requirement
33
17
  none: false
34
18
  requirements:
35
19
  - - ! '>='
@@ -37,15 +21,10 @@ dependencies:
37
21
  version: '0'
38
22
  type: :runtime
39
23
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
24
+ version_requirements: *10020580
46
25
  - !ruby/object:Gem::Dependency
47
26
  name: wait
48
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &10019480 !ruby/object:Gem::Requirement
49
28
  none: false
50
29
  requirements:
51
30
  - - ! '>='
@@ -53,15 +32,10 @@ dependencies:
53
32
  version: '0'
54
33
  type: :runtime
55
34
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
35
+ version_requirements: *10019480
62
36
  - !ruby/object:Gem::Dependency
63
37
  name: jeweler
64
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &10018320 !ruby/object:Gem::Requirement
65
39
  none: false
66
40
  requirements:
67
41
  - - ~>
@@ -69,15 +43,10 @@ dependencies:
69
43
  version: 1.8.4
70
44
  type: :development
71
45
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.8.4
46
+ version_requirements: *10018320
78
47
  - !ruby/object:Gem::Dependency
79
48
  name: watir-webdriver
80
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &10033700 !ruby/object:Gem::Requirement
81
50
  none: false
82
51
  requirements:
83
52
  - - ! '>='
@@ -85,12 +54,7 @@ dependencies:
85
54
  version: '0'
86
55
  type: :runtime
87
56
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
57
+ version_requirements: *10033700
94
58
  description: Framework for modeling and interacting with webpages which wraps capybara
95
59
  email: info@lad-tech.com
96
60
  executables: []
@@ -143,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
107
  version: '0'
144
108
  segments:
145
109
  - 0
146
- hash: 4130538887016609819
110
+ hash: 1067897609518748407
147
111
  required_rubygems_version: !ruby/object:Gem::Requirement
148
112
  none: false
149
113
  requirements:
@@ -152,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
116
  version: '0'
153
117
  requirements: []
154
118
  rubyforge_project:
155
- rubygems_version: 1.8.25
119
+ rubygems_version: 1.8.10
156
120
  signing_key:
157
121
  specification_version: 3
158
122
  summary: Framework for modeling and interacting with webpages