Skip to content

Commit

Permalink
Added support for Rspec and Cucumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Bert Hajee authored and Bert Hajee committed Jun 13, 2013
1 parent 742c34b commit f81bcd1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
12 changes: 7 additions & 5 deletions lib/page_record/class_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def self.method_missing(action)
raw_action = /(.*)\?/.match(action)
begin
if raw_action
raw_action_for(raw_action[0])
action_for?(raw_action[1])
else
action_for(action)
end
Expand All @@ -21,12 +21,14 @@ def self.method_missing(action)


def self.action_for(action)
element = raw_action_for(action)
element.native.click
element = action_for?(action)
element.click
element
end

def self.raw_action_for(action)
@page.find("[data-action-for='#{action}']")

def self.action_for?(action)
page.find("[data-action-for='#{action}']")
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/page_record/cucumber.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'page_record'

Before do
PageRecord::PageRecord.page = page
end
9 changes: 5 additions & 4 deletions lib/page_record/instance_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def method_missing(action)
raw_action = /(.*)\?/.match(action)
begin
if raw_action
raw_action_for(raw_action[0])
action_for?(raw_action[1])
else
action_for(action)
end
Expand All @@ -16,13 +16,14 @@ def method_missing(action)

private


def action_for(action)
element = raw_action_for(action)
element.native.click
element = action_for?(action)
element.click
element
end

def raw_action_for(action)
def action_for?(action)
@record.find("[data-action-for='#{action}']")
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/page_record/rspec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'page_record'

RSpec.configure do |config|
config.before(:each) do
PageRecord::PageRecord.page = session
end
end

0 comments on commit f81bcd1

Please sign in to comment.