-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jdenen/enable-multiple-contexts
Enable multiple contexts per page-object instance
- Loading branch information
Showing
16 changed files
with
145 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Mobilify | ||
VERSION = "1.1.1" | ||
VERSION = "1.2.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
describe Mobilify do | ||
after :each do | ||
@browser.close | ||
end | ||
|
||
describe "uses default method when given contexts do not apply" do | ||
Given(:desktop) { KhanAcademy.new(desktop_browser, { :visit => true, :context => [:no_match, :wrong] }) } | ||
Then { desktop.login_element.inspect.should include("log-in-link ellipsis highlight") } | ||
end | ||
|
||
describe "uses only applicable context given" do | ||
context "when applicable context is first in the array" do | ||
Given(:mobile) { KhanAcademy.new(mobile_browser, { :visit => true, :context => [:mobile, :wrong] }) } | ||
Then { mobile.login_element.inspect.should include("simple-button big-button") } | ||
end | ||
|
||
context "when applicable context is second in the array" do | ||
Given(:mobile) { KhanAcademy.new(mobile_browser, { :visit => true, :context => [:wrong, :mobile] }) } | ||
Then { mobile.login_element.inspect.should include("simple-button big-button") } | ||
end | ||
end | ||
|
||
describe "uses first context given when multiple applicable contexts are given" do | ||
Given(:mobile) { KhanAcademy.new(mobile_browser, { :visit => true, :context => [:mobile, :ignored] }) } | ||
Then { mobile.login_element.inspect.should include("simple-button big-button") } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'spec_helper' | ||
|
||
describe Mobilify do | ||
|
||
describe "includes PageObject when included" do | ||
Given { class Page; end } | ||
When { Page.send :include, Mobilify } | ||
Then { Page.included_modules[1].should == PageObject } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'spec_helper' | ||
|
||
describe Mobilify do | ||
after :each do | ||
@browser.close | ||
end | ||
|
||
describe "uses default method when no context is given" do | ||
Given(:desktop) { KhanAcademy.new(desktop_browser, { :visit => true }) } | ||
Then { desktop.login_element.inspect.should include("log-in-link ellipsis highlight") } | ||
end | ||
|
||
describe "uses default method when non-applicable context is given" do | ||
Given(:desktop) { KhanAcademy.new(desktop_browser, { :visit => true, :context => :wrong }) } | ||
Then { desktop.login_element.inspect.should include("log-in-link ellipsis highlight") } | ||
end | ||
|
||
describe "uses contextual method for the given context" do | ||
Given(:mobile) { KhanAcademy.new(mobile_browser, { :context => :mobile, :visit => true }) } | ||
Then { mobile.login_element.inspect.should include("simple-button big-button") } | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'rspec' | ||
require 'rspec-given' | ||
require 'watir-webdriver' | ||
require 'webdriver-user-agent' | ||
require './lib/mobilify' | ||
require 'support/khan_academy' | ||
|
||
def desktop_browser | ||
@browser = Watir::Browser.new :firefox | ||
end | ||
|
||
def mobile_browser | ||
device = Webdriver::UserAgent.driver(:browser => :firefox, :agent => :iphone) | ||
@browser = Watir::Browser.new device | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "./lib/mobilify" | ||
|
||
class KhanAcademy | ||
include Mobilify | ||
|
||
page_url "http://www.khanacademy.org" | ||
|
||
link(:login, :class => "log-in-link ellipsis highlight") | ||
link(:mobile_login, :class => "simple-button big-button") | ||
link(:ignored_login, :class => "simple-button primary big-button") | ||
end | ||
|