require 'rubygems'
require 'spec'
require 'watir'
Watir::Browser.default = 'safari'
browser = Watir::Browser.new
browser.goto("http://localhost:8888/")
describe "My WordPress home page" do
it "should find the header" do
browser.div(:id, "header").exist?.should == true
end
it "should find the default entry" do
browser.div(:id, "post-1").exists?.should == true
browser.div(:id, "post-1").text.include?("Hello world!").should == true
end
end
describe "Write a post" do
if browser.link(:text, "Log out").exists? == false
it "should go to login page" do
browser.link(:text, "Log in").exists?.should == true
browser.link(:text, "Log in").click
end
it "should log in" do
browser.text_field(:id, "user_login").set("admin")
browser.text_field(:id, "user_pass").set("lVm8R52!0W1O")
browser.button(:id, "wp-submit").click
end
else
it "should go to admin page" do
browser.goto("http://localhost:8888/wp-admin/")
end
end
it "should write a quick post" do
browser.div(:id, "dashboard_quick_press").exists?.should == true
browser.text_field(:id, "title").set("This is a test post")
browser.text_field(:id, "content").set("I have lots of great things to say.")
browser.text_field(:id, "tags-input").set("testing")
browser.button(:id, "publish").click
end
it "should log out" do
browser.link(:text, "Log Out").exists?.should == true
browser.link(:text, "Log Out").click
end
end