Sha256: f8f6968f66e72a28c7ac498459ee7576c2b0f0c83689d7f6b22b19476f03a9d4

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH << "./lib"

require "rspec"
include RSpec::Matchers

require "testable"
include Testable::Context

Capybara.configure do |config|
  config.run_server = false
  config.default_driver = :selenium
  config.app_host = "https://veilus.herokuapp.com"
end

class HomePage < Testable::Page
  element :login_form, "#open"
  element :username,   "#username"
  element :password,   "#password"
  element :login,      "#login-button"

  def path
    "/"
  end

  def login_as_admin
    login_form.click
    username.set "admin"
    password.set "admin"
    login.click
  end
end

class Navigation < Testable::Node
  elements :items, "a"

  element :page_list, "#navlist"
  element :overlord,  "#overlord"
  element :planets,   "#planets"
  element :warp,      "#warp"
  element :stardate,  "#stardate"
end

class MenuItem < Testable::Node
  components :items, Navigation, "#areas"
end

class LandingPage < Testable::Page
  component :navigation, Navigation, "#areas"
  element :logo, "#site-image"
end

on_visit(HomePage).login_as_admin

on(LandingPage) do |action|
  action.navigation.page_list.click
  puts action.navigation.overlord.text
  puts action.navigation.items
  puts action.navigation.items[0].text
  expect(action.navigation).to have_items
  expect(action.navigation.items[0].text).to eq("Home")
  expect(action.navigation.items.count).to be(8)
  action.navigation.overlord.click
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
testable-0.10.0 examples/testable-capybara-context.rb
testable-0.9.0 examples/testable-capybara-context.rb
testable-0.8.0 examples/testable-capybara-context.rb
testable-0.7.0 examples/testable-capybara-context.rb
testable-0.6.0 examples/testable-capybara-context.rb
testable-0.5.0 examples/testable-capybara-context.rb