page_magic 1.0.0.alpha2 → 1.0.0.alpha3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f197806fbf5357bdcf84663abfbf87902c89f835
4
- data.tar.gz: da30e148aa6cc6782c0d0c399fc45c43d00ee3d2
3
+ metadata.gz: 0527b24c83ab8ec283c1fac457d76771126f434a
4
+ data.tar.gz: 89f1a07fd4c975c82105eb551d8e2b6013cec794
5
5
  SHA512:
6
- metadata.gz: 8c3b3277416e23f0767b0e0f4b63879882fd9c1872fedb290fb727be512d91b06b53056dac552c539a65cec17f20e831e4d17cd7e97ef1bdfeee941eb528e6a9
7
- data.tar.gz: 8d953ec0f7af0749bedca9396caf556098b7b74b5d09f2c82a4b904bbb41fc604bc7e3b0bae87e10d367e2496546342ac31f07652be996b799ddea4b7c71ec3a
6
+ metadata.gz: 15099e5bb4c4f7432b0eaa82366809fc81b931581b2d3a4a14254fd0cfc35dfe5c7a5ce2357f9a2fd6d0ce7c207e1feaf54223758671baa7b3776334e011b6c2
7
+ data.tar.gz: 01328446a136c0254f8a1f41dff01d1675be9919e27ceb0cf70a365e8f0449131e7e2f5e7feb27363b642d9907f74f06bd8cd782e530e5180698abd1879e86d6
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'capybara'
4
+ gem 'activesupport'
4
5
  gem 'wait'
5
6
 
6
7
  group :test do
data/Gemfile.lock CHANGED
@@ -1,6 +1,12 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ activesupport (4.2.3)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
4
10
  addressable (2.3.6)
5
11
  builder (3.2.2)
6
12
  capybara (2.1.0)
@@ -38,6 +44,7 @@ GEM
38
44
  guard (~> 2.0)
39
45
  hashie (2.0.5)
40
46
  highline (1.6.21)
47
+ i18n (0.7.0)
41
48
  jeweler (2.0.1)
42
49
  builder
43
50
  bundler (>= 1.0)
@@ -58,6 +65,7 @@ GEM
58
65
  method_source (0.8.2)
59
66
  mime-types (1.25)
60
67
  mini_portile (0.5.1)
68
+ minitest (5.7.0)
61
69
  multi_json (1.7.3)
62
70
  multi_xml (0.5.5)
63
71
  multipart-post (1.2.0)
@@ -113,8 +121,11 @@ GEM
113
121
  tilt (~> 1.3, >= 1.3.4)
114
122
  slop (3.5.0)
115
123
  thor (0.19.1)
124
+ thread_safe (0.3.5)
116
125
  tilt (1.4.1)
117
126
  timers (1.1.0)
127
+ tzinfo (1.2.2)
128
+ thread_safe (~> 0.1)
118
129
  wait (0.5.1)
119
130
  watir-webdriver (0.6.4)
120
131
  selenium-webdriver (>= 2.18.0)
@@ -127,6 +138,7 @@ PLATFORMS
127
138
  ruby
128
139
 
129
140
  DEPENDENCIES
141
+ activesupport
130
142
  capybara
131
143
  guard
132
144
  guard-ctags-bundler
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- [![Build Status](https://travis-ci.org/Ladtech/page_magic.png)](https://travis-ci.org/Ladtech/page_magic)
2
- #PageMagic
1
+ #PageMagic
3
2
  PageMagic is an API for testing web applications.
4
3
 
5
4
  It has a simple but powerful DSL which makes modelling and interacting with your pages easy.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha2
1
+ 1.0.0.alpha3
@@ -0,0 +1,19 @@
1
+ module PageMagic
2
+ class Driver
3
+ attr_reader :supported_browsers, :handler
4
+ def initialize(*supported_browsers, &block)
5
+ @handler = block
6
+ @supported_browsers = supported_browsers
7
+ end
8
+
9
+ def support? browser
10
+ supported_browsers.include?(browser)
11
+ end
12
+
13
+ def build(app, browser:, options:{})
14
+ options[:browser] = browser
15
+ driver_clazz = handler.call
16
+ driver_clazz.new(app, options)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module PageMagic
2
+ class Drivers
3
+ Poltergeist = Driver.new(:poltergeist) do
4
+ require 'capybara/poltergeist'
5
+ Capybara::Poltergeist::Driver
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ module PageMagic
2
+ class Drivers
3
+ RackTest = Driver.new(:rack_test) do
4
+ Capybara::RackTest::Driver
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ module PageMagic
2
+ class Drivers
3
+ Selenium = Driver.new(:chrome, :firefox) do
4
+ require 'watir-webdriver'
5
+ Capybara::Selenium::Driver
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ require 'page_magic/driver'
2
+ module PageMagic
3
+ class Drivers
4
+ def all
5
+ @all ||=[]
6
+ end
7
+
8
+ def register(driver)
9
+ all << driver
10
+ end
11
+
12
+
13
+ def find browser
14
+ all.find{|driver|driver.support?(browser)}
15
+ end
16
+
17
+ def load path="#{__dir__}/drivers"
18
+ require 'active_support/inflector'
19
+
20
+ Dir["#{path}/*.rb"].each do |driver_file|
21
+ require driver_file
22
+ driver_name = File.basename(driver_file)[/(.*)\.rb$/, 1]
23
+ register eval(driver_name.classify)
24
+ end
25
+ end
26
+
27
+ def == other
28
+ other.is_a?(Drivers) && other.all == other.all
29
+ end
30
+ end
31
+ end
@@ -28,19 +28,15 @@ module PageMagic
28
28
  element_locator = element_locator_factory.call(@page_element, *args)
29
29
  end
30
30
 
31
- result = element_locator.browser_element
32
-
33
- return element_locator if element_locator.section?
34
-
35
31
  [:set, :select_option, :unselect_option, :click].each do |action_method|
36
- apply_hooks(page_element: result,
32
+ apply_hooks(page_element: element_locator.browser_element,
37
33
  capybara_method: action_method,
38
34
  before_hook: element_locator.before,
39
35
  after_hook: element_locator.after,
40
36
  )
41
37
  end
42
38
 
43
- result
39
+ element_locator.section? ? element_locator : element_locator.browser_element
44
40
  end
45
41
 
46
42
  def apply_hooks(options)
@@ -36,8 +36,8 @@ module PageMagic
36
36
  end
37
37
  end
38
38
 
39
- def visit page
40
- raw_session.visit page.url
39
+ def visit(page, url: nil)
40
+ raw_session.visit url || page.url
41
41
  @current_page = page.new self
42
42
  self
43
43
  end
data/lib/page_magic.rb CHANGED
@@ -1,41 +1,33 @@
1
1
  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}")
2
2
  require 'capybara'
3
3
  require 'page_magic/exceptions'
4
- require 'page_magic/browser'
5
4
  require 'page_magic/session'
6
5
  require 'page_magic/elements'
7
6
  require 'page_magic/element_context'
8
7
  require 'page_magic/element'
9
8
  require 'page_magic/page_magic'
9
+ require 'page_magic/drivers'
10
10
 
11
11
  module PageMagic
12
+ class UnspportedBrowserException < Exception;end
13
+
12
14
  class << self
13
- def session browser=nil, options = {}
14
- if browser.is_a?(Symbol)
15
- application = options.delete(:application)
16
-
17
- Capybara.register_driver browser do |app|
18
- options[:browser] = browser
19
- case browser
20
- when :poltergeist
21
- require 'capybara/poltergeist'
22
- Capybara::Poltergeist::Driver.new(app)
23
- when :rack_test
24
- Capybara::RackTest::Driver.new(app, options)
25
- else
26
- require 'watir-webdriver'
27
- Capybara::Selenium::Driver.new(app, options)
28
- end
29
-
30
- end
31
-
32
- Session.new(Capybara::Session.new(browser, application))
33
- else
34
- Capybara.reset!
35
- Capybara.app = browser[:application] if browser.is_a?(Hash) && browser[:application]
36
- Session.new(Capybara.current_session)
37
- end
38
15
 
16
+ def drivers
17
+ @drivers ||= Drivers.new.tap do |drivers|
18
+ drivers.load
19
+ end
20
+ end
21
+
22
+ def session(application: nil, browser: :rack_test, options: {})
23
+ driver = drivers.find(browser)
24
+ raise UnspportedBrowserException unless driver
25
+
26
+ Capybara.register_driver browser do |app|
27
+ driver.build(app, browser: browser, options: options)
28
+ end
29
+
30
+ Session.new(Capybara::Session.new(browser, application))
39
31
  end
40
32
 
41
33
  def included clazz
@@ -53,11 +45,10 @@ module PageMagic
53
45
  PageMagic.pages << clazz
54
46
  end
55
47
  end
56
-
57
48
  end
58
49
 
59
50
  def pages
60
51
  @pages||=[]
61
52
  end
62
53
  end
63
- end
54
+ end
@@ -0,0 +1,47 @@
1
+ require 'page_magic/driver'
2
+
3
+ module PageMagic
4
+ describe Driver do
5
+
6
+ let(:driver_class) do
7
+ Class.new do
8
+ attr_reader :rack_app, :options
9
+ def initialize rack_app, options
10
+ @rack_app = rack_app
11
+ @options = options
12
+ end
13
+ def == driver
14
+ driver.rack_app == rack_app && driver.options == options
15
+ end
16
+ end
17
+ end
18
+ subject do
19
+ described_class.new :custom_browser do
20
+ driver_class
21
+ end
22
+ end
23
+
24
+ describe '#supports?' do
25
+ context 'browser is in supported browsers' do
26
+ it 'returns true' do
27
+ expect(subject.support?(:custom_browser)).to eq(true)
28
+ end
29
+ end
30
+
31
+ context 'browser is not in supported browsers' do
32
+ it 'returns false' do
33
+ expect(subject.support?(:unsupported_browser)).to eq(false)
34
+ end
35
+ end
36
+ end
37
+ describe '#build' do
38
+ it 'adds the browser to the options supplied to the driver' do
39
+ expect(subject.build(:rack_app, browser: :custom_browser, options: {}).options).to eq(browser: :custom_browser)
40
+ end
41
+
42
+ it 'creates an instance of the supplied driver' do
43
+ expect(subject.build(:rack_app,browser: :custom_browser, options: {})).to eq(driver_class.new(:rack_app, {browser: :custom_browser}))
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ require 'page_magic/drivers/poltergeist'
2
+ module PageMagic
3
+ class Drivers
4
+ describe Poltergeist do
5
+ it %q{is capybara's poltergeist driver} do
6
+ expect(described_class.build(:app, browser: :poltergeist, options:{})).to be_a(Capybara::Poltergeist::Driver)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'page_magic/drivers/rack_test'
2
+ module PageMagic
3
+ class Drivers
4
+ describe RackTest do
5
+ it %q{is capybara's rack test driver} do
6
+ expect(described_class.build(:app, browser: :rack_test, options:{})).to be_a(Capybara::RackTest::Driver)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'page_magic/drivers/selenium'
2
+ module PageMagic
3
+ class Drivers
4
+ describe Selenium do
5
+ it 'is selenium' do
6
+ expect(described_class.build(:app, browser: :selenium, options:{})).to be_a(Capybara::Selenium::Driver)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,41 @@
1
+ require 'page_magic/drivers'
2
+
3
+ module PageMagic
4
+
5
+ describe Drivers do
6
+ subject { described_class.new }
7
+ let(:expected_driver) { Driver.new(:browser_driver) }
8
+ describe '#register' do
9
+ it 'stores the driver' do
10
+ subject.register expected_driver
11
+ expect(subject.all).to eq([expected_driver])
12
+ end
13
+ end
14
+
15
+ describe '#find' do
16
+ it 'returns the registered driver' do
17
+ subject.register expected_driver
18
+ expect(subject.find(:browser_driver)).to eq(expected_driver)
19
+ end
20
+ end
21
+
22
+ describe '#load' do
23
+ include_context :files
24
+ it 'loads the drivers in the specified path' do
25
+
26
+ class_definition=<<-RUBY
27
+ class CustomDriver;
28
+ def self.support? browser
29
+ true
30
+ end
31
+ end
32
+ RUBY
33
+
34
+ File.write("#{scratch_dir}/custom_driver.rb", class_definition )
35
+
36
+ subject.load(scratch_dir)
37
+ expect(subject.find(:custom_browser)).to be(::CustomDriver)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -87,23 +87,40 @@ describe PageMagic::ElementContext do
87
87
 
88
88
  describe 'hooks' do
89
89
 
90
+ subject(:page) do
91
+ elements_page.new.tap do|p|
92
+ p.visit
93
+ end
94
+ end
90
95
 
91
- #it 'only applies them if browser element supports event' do
92
- # page = elements_page.new
93
- #end
94
-
95
- it 'should execute a before and after action that gives access to the browser' do
96
-
97
- page = elements_page.new
98
- page.visit
99
-
100
- selector = {text: 'a link'}
96
+ before do
101
97
  browser = page.browser
102
98
  browser.should_receive(:call_in_before_hook)
103
99
  browser.should_receive(:call_in_after_before_hook)
100
+ end
104
101
 
105
102
 
106
- elements_page.link(:create, selector) do
103
+ context 'section' do
104
+ it 'applies the hooks' do
105
+
106
+ elements_page.section(:form, id: 'form') do
107
+ link :form_link, id: 'form_link'
108
+
109
+ before do |page_browser|
110
+ page_browser.call_in_before_hook
111
+ end
112
+
113
+ after do |page_browser|
114
+ page_browser.call_in_after_before_hook
115
+ end
116
+ end
117
+
118
+ described_class.new(page, page.browser, self).form.click
119
+ end
120
+ end
121
+
122
+ it 'should execute a before and after action that gives access to the browser' do
123
+ elements_page.link(:create, text: 'a link') do
107
124
  before do |page_browser|
108
125
  page_browser.call_in_before_hook
109
126
  end
@@ -70,10 +70,20 @@ describe PageMagic::Session do
70
70
  end
71
71
  end
72
72
 
73
- it 'should visit the given url' do
74
- browser.should_receive(:visit).with(page.url)
75
- session = PageMagic::Session.new(browser).visit(page)
76
- session.current_page.should be_a(page)
73
+ describe '#visit' do
74
+ context 'url supplied' do
75
+ it 'uses this url instead of the one defined on the page class' do
76
+ expect(browser).to receive(:visit).with(:custom_url)
77
+ session = PageMagic::Session.new(browser).visit(page, url: :custom_url)
78
+ session.current_page.should be_a(page)
79
+ end
80
+ end
81
+
82
+ it 'visits the url on defined on the page class' do
83
+ browser.should_receive(:visit).with(page.url)
84
+ session = PageMagic::Session.new(browser).visit(page)
85
+ session.current_page.should be_a(page)
86
+ end
77
87
  end
78
88
 
79
89
  it 'should return the current url' do
@@ -1,4 +1,5 @@
1
1
  describe 'PageMagic.session' do
2
+
2
3
  let(:app_class) do
3
4
  Class.new do
4
5
  def call env
@@ -11,35 +12,10 @@ describe 'PageMagic.session' do
11
12
  Capybara.drivers[browser].call(nil)
12
13
  end
13
14
 
14
- context 'using a symbol as a parameter' do
15
- it 'sets up a session using the specified browser' do
16
- Capybara::Session.should_receive(:new).with(:chrome, nil).and_return(:chrome_session)
17
-
18
- session = PageMagic.session(:chrome)
19
-
20
- registered_driver(:chrome).should == Capybara::Selenium::Driver.new(nil, browser: :chrome)
21
-
22
- session.raw_session.should == :chrome_session
23
- end
24
-
25
- context 'browsers' do
26
- it 'supports poltergeist' do
27
- session = PageMagic.session(:poltergeist, application: app_class.new)
28
- session.raw_session.driver.is_a?(Capybara::Poltergeist::Driver).should be_true
29
- end
30
-
31
- it 'supports selenium' do
32
- session = PageMagic.session(:firefox, application: app_class.new)
33
- session.raw_session.driver.is_a?(Capybara::Selenium::Driver).should be_true
34
- end
35
- end
36
- end
37
-
38
- context 'defaulting the browser used from PageMagic sessions' do
39
- it "uses what ever Capybara's default_driver is set to" do
40
- Capybara.default_driver = :rack_test
41
- session = PageMagic.session
42
- session.raw_session.mode.should == :rack_test
15
+ context 'specificying a browser' do
16
+ it 'loads the driver for the specified browser' do
17
+ session = PageMagic.session(browser: :firefox)
18
+ session.raw_session.driver.is_a?(Capybara::Selenium::Driver).should be_true
43
19
  end
44
20
  end
45
21
 
@@ -52,7 +28,7 @@ describe 'PageMagic.session' do
52
28
  end
53
29
 
54
30
  it 'can run against an rack application using a particular browser' do
55
- session = PageMagic.session(:rack_test, application: app_class.new)
31
+ session = PageMagic.session(browser: :rack_test, application: app_class.new)
56
32
  session.raw_session.mode.should == :rack_test
57
33
  session.raw_session.visit('/')
58
34
  session.raw_session.text.should == 'hello world!!'
@@ -0,0 +1,44 @@
1
+ require 'page_magic'
2
+
3
+ describe PageMagic do
4
+ describe '::drivers' do
5
+ it 'returns loaded drivers' do
6
+ expected_drivers = described_class::Drivers.new.tap do |drivers|
7
+ drivers.load
8
+ end
9
+
10
+ expect(described_class.drivers).to eq(expected_drivers)
11
+ end
12
+ end
13
+
14
+ describe '::session' do
15
+ context 'specifying the browser' do
16
+ it 'loads the correct driver' do
17
+ session = described_class.session(browser: :firefox)
18
+ session.raw_session.driver.is_a?(Capybara::Selenium::Driver).should be_true
19
+ end
20
+ end
21
+
22
+ context 'specifying a rack application' do
23
+ it 'configures capybara to run against the app' do
24
+ session = described_class.session(application: :rack_application)
25
+ expect(session.raw_session.app).to be(:rack_application)
26
+ end
27
+ end
28
+
29
+ context 'specifying options' do
30
+ it 'passes the options to the browser driver' do
31
+ options = {option: :config}
32
+ session = described_class.session(options: options, browser: :chrome)
33
+
34
+ expect(session.raw_session.driver.options).to include(options)
35
+ end
36
+ end
37
+
38
+ context 'driver for browser not found' do
39
+ it 'raises an error' do
40
+ expect{described_class.session(browser: :invalid)}.to raise_exception described_class::UnspportedBrowserException
41
+ end
42
+ end
43
+ end
44
+ end
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,22 @@ require 'page_magic'
11
11
  require 'capybara/rspec'
12
12
  require 'helpers/capybara'
13
13
 
14
+ shared_context :files do
15
+ require 'tmpdir'
16
+ def scratch_dir
17
+ @dir ||= Dir.mktmpdir
18
+ end
19
+ end
14
20
 
21
+ shared_context :rack_application do
22
+ let(:rack_application) do
23
+ Class.new do
24
+ def call env
25
+ [200, {}, ["hello world!!"]]
26
+ end
27
+ end
28
+ end
29
+ end
15
30
 
16
31
  RSpec.configure do
17
32
 
metadata CHANGED
@@ -1,83 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha2
4
+ version: 1.0.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: wait
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: jeweler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: guard
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: guard-ctags-bundler
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  description: Framework for modeling and interacting with webpages which wraps capybara
@@ -87,10 +101,9 @@ extensions: []
87
101
  extra_rdoc_files:
88
102
  - README.md
89
103
  files:
90
- - .rspec
91
- - .ruby-gemset
92
- - .ruby-version
93
- - .travis.yml
104
+ - ".rspec"
105
+ - ".ruby-gemset"
106
+ - ".ruby-version"
94
107
  - Gemfile
95
108
  - Gemfile.lock
96
109
  - Guardfile
@@ -99,7 +112,11 @@ files:
99
112
  - VERSION
100
113
  - lib/ext/string.rb
101
114
  - lib/page_magic.rb
102
- - lib/page_magic/browser.rb
115
+ - lib/page_magic/driver.rb
116
+ - lib/page_magic/drivers.rb
117
+ - lib/page_magic/drivers/poltergeist.rb
118
+ - lib/page_magic/drivers/rack_test.rb
119
+ - lib/page_magic/drivers/selenium.rb
103
120
  - lib/page_magic/element.rb
104
121
  - lib/page_magic/element_context.rb
105
122
  - lib/page_magic/elements.rb
@@ -110,7 +127,11 @@ files:
110
127
  - spec/element_spec.rb
111
128
  - spec/helpers/capybara.rb
112
129
  - spec/member_methods_spec.rb
113
- - spec/page_magic/browser_spec.rb
130
+ - spec/page_magic/driver_spec.rb
131
+ - spec/page_magic/drivers/poltergeist_spec.rb
132
+ - spec/page_magic/drivers/rack_test_spec.rb
133
+ - spec/page_magic/drivers/selenium_spec.rb
134
+ - spec/page_magic/drivers_spec.rb
114
135
  - spec/page_magic/element_context_spec.rb
115
136
  - spec/page_magic/elements_spec.rb
116
137
  - spec/page_magic/session_spec.rb
@@ -119,6 +140,7 @@ files:
119
140
  - spec/page_magic/usage/include_page_magic_spec.rb
120
141
  - spec/page_magic/usage/interacting_with_pages_spec.rb
121
142
  - spec/page_magic/usage/starting_a_session_spec.rb
143
+ - spec/page_magic_spec.rb
122
144
  - spec/spec_helper.rb
123
145
  homepage: https://github.com/ladtech/page_magic
124
146
  licenses:
@@ -130,12 +152,12 @@ require_paths:
130
152
  - lib
131
153
  required_ruby_version: !ruby/object:Gem::Requirement
132
154
  requirements:
133
- - - '>='
155
+ - - ">="
134
156
  - !ruby/object:Gem::Version
135
157
  version: '0'
136
158
  required_rubygems_version: !ruby/object:Gem::Requirement
137
159
  requirements:
138
- - - '>'
160
+ - - ">"
139
161
  - !ruby/object:Gem::Version
140
162
  version: 1.3.1
141
163
  requirements: []
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- rvm:
2
- - '1.9.3'
3
- - '2.0.0'
4
-
@@ -1,19 +0,0 @@
1
- module PageMagic
2
- module Browser
3
-
4
- class << self
5
- attr_writer :default
6
- def session
7
- @session ||= PageMagic.session(default)
8
- end
9
-
10
- def default
11
- @default || :firefox
12
- end
13
- end
14
-
15
- def browser
16
- Browser.session
17
- end
18
- end
19
- end
@@ -1,35 +0,0 @@
1
- describe PageMagic::Browser do
2
- let(:app) { Object.new }
3
-
4
- before do
5
- PageMagic::Browser.instance_variable_set(:@session, nil)
6
- app.extend PageMagic::Browser
7
- end
8
-
9
- describe 'default' do
10
- it 'should be firefox' do
11
- PageMagic::Browser.default.should == :firefox
12
- end
13
- end
14
-
15
- describe 'browser' do
16
- it 'should return the existing session' do
17
- session_instance = app.browser
18
- app.browser.should == session_instance
19
- end
20
-
21
- it 'should create a session if not already set' do
22
- new_session = double(:new_session)
23
-
24
- PageMagic.should_receive(:session).with(:firefox).and_return new_session
25
- app.browser.should == new_session
26
- end
27
-
28
- it 'should use custom browser' do
29
- PageMagic.should_receive(:session).with(:custom_browser)
30
-
31
- PageMagic::Browser.default = :custom_browser
32
- app.browser
33
- end
34
- end
35
- end