Ejemplo n.º 1
0
func TestSpec(t *testing.T) {
	Convey("UserRegister", t, func() {
		var agoutiDriver *agouti.WebDriver
		var page *agouti.Page

		session, _ := mgo.Dial("localhost")

		session.DB("TESTGoNuts").DropDatabase()

		agoutiDriver = agouti.PhantomJS()

		So(agoutiDriver.Start(), ShouldBeNil)

		log.Println("Starting")

		go StartMyApp(3232, "TESTGoNuts")

		var err error
		page, err = agoutiDriver.NewPage(agouti.Browser("chrome"))
		So(err, ShouldBeNil)

		Convey("User Registration page", func() {
			Convey("when the user registration is reached", func() {
				Convey("should see the page", func() {
					So(page.Navigate("http://localhost:3232"), ShouldBeNil)

					url, _ := page.URL()
					So(url, ShouldEqual, "http://localhost:3232/")
				})
			})
		})

		Reset(func() {
			So(page.Destroy(), ShouldBeNil)
			So(agoutiDriver.Stop(), ShouldBeNil)
		})
	})
}
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gexec"
	"github.com/sclevine/agouti"

	"testing"
)

func TestIntegration(t *testing.T) {
	RegisterFailHandler(Fail)
	SetDefaultEventuallyTimeout(time.Second * 5)
	RunSpecs(t, "Integration Suite")
}

var (
	executablePath    string
	runningExecutable *gexec.Session
	buildsDir         string
	agoutiDriver      *agouti.WebDriver
)

var _ = BeforeSuite(func() {
	var err error
	executablePath, err = gexec.Build("github.com/craigfurman/woodhouse-ci")
	Expect(err).NotTo(HaveOccurred())

	if os.Getenv("HEADLESS") == "true" {
		agoutiDriver = agouti.PhantomJS()
	} else {
		agoutiDriver = agouti.ChromeDriver()
	}
	Expect(agoutiDriver.Start()).To(Succeed())
})