Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A gem to make it inexcusably easy to move behaviour and assertions out of your acceptance tests or cucumber steps and into reusable page models.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.txt
Octocat-spinner-32 Rakefile
Octocat-spinner-32 pagemodels.gemspec
README.txt
Page Models move complex and copy-pasted code out of your acceptance tests and into easily managed Ruby classes with (optional) integration for Rails, Cucumber, and RSpec.


~~~~~~~~
# env.rb
require 'pagemodels'

PageModels.configure do |config|
  config.driver = :capybara  # Or :celerity, :firefox, :chrome, :ie (browsers will use watir-webdriver)
  config.base_url = "https://www.github.com"
  config.integrate :rspec
  config.integrate :cucumber
  config.integrate :rails
end


~~~~~~~~~~~~~~~~~~~~~~~~~~
# my_cucumber_test.feature
Given I open the GitHub project page for the user "rickgrundy" and the repo "page-models"
When I look at the commit history
Then I should see at least 3 commits


~~~~~~~~~~~~~~~~~~~~~~
# my_cucumber_steps.rb
When /I look at the commit history/ do
  navigate_to_commits
end

Then /I should see at least (\d+) commits/ do |count|
  verify_commit_count(count)
end


~~~~~~~~~~~~~~~~~~~~~~
# GitHubProjectPage.rb
class GitHubProjectPage < PageModels::Base
  def initialize(user, repo)
    @user, @repo = user, repo
  end
  
  def url
    "/#{@user}/#{@repo}/"
  end
  
  def verify!
    should have_content "#{@user} / #{@repo}"
    should have_content "Source"
    should have_content "Commits"
  end
  
  def navigate_to_commits
    click_link "Commits"
  end
  
  def verify_commit_count(count)
    all(".commit").should have_at_least(count).things
  end
end
Something went wrong with that request. Please try again.