From 47d1f9a78eb7f42cfdafaeaa9fa45359234d198e Mon Sep 17 00:00:00 2001 From: "Daniel E. Renfer" Date: Thu, 3 Mar 2016 23:07:50 -0500 Subject: [PATCH] protractor cucumber --- Gemfile | 1 + Gemfile.lock | 5 +++++ Guardfile | 15 +++++++++++++++ package.json | 2 ++ project.clj | 1 + protractor.config.js | 18 ++++++++++++++++-- specs/jiksnu/core_spec.cljs | 22 ++++++++++++---------- 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 6587f5177..de0809852 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,5 @@ source "https://rubygems.org" group :development do gem 'guard' gem 'guard-livereload', '~> 2.4', require: false + gem 'guard-shell' end diff --git a/Gemfile.lock b/Gemfile.lock index e7013bc64..b47e58e34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,10 +17,14 @@ GEM pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) + guard-compat (1.2.1) guard-livereload (2.4.0) em-websocket (~> 0.5) guard (~> 2.8) multi_json (~> 1.8) + guard-shell (0.7.1) + guard (>= 2.0.0) + guard-compat (~> 1.0) http_parser.rb (0.6.0) listen (3.0.3) rb-fsevent (>= 0.9.3) @@ -49,6 +53,7 @@ PLATFORMS DEPENDENCIES guard guard-livereload (~> 2.4) + guard-shell BUNDLED WITH 1.10.6 diff --git a/Guardfile b/Guardfile index 166ec7c53..ccdae0e0f 100644 --- a/Guardfile +++ b/Guardfile @@ -26,3 +26,18 @@ guard 'livereload' do # Rails Assets Pipeline # watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" } end + +def run_protractor + `lein protractor` +end + +guard :shell do + watch(%r{specs/.+\.cljs}) do + `lein with-profile e2e cljsbuild once` + end +end + +guard :shell do + watch(%r{target/protractor-tests.js}) {run_protractor} + watch(%r{features/.+\.feature}) {run_protractor} +end diff --git a/package.json b/package.json index c455b2b0b..3f51c87e9 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "angular": "1.4.7", "angular-mocks": "1.4.7", "bower": "1.7.7", + "cucumber": "0.9.5", "es6-promise": "3.0.2", "karma-angular": "0.0.6", "karma-coverage": "0.5.2", @@ -13,6 +14,7 @@ "karma-phantomjs-launcher": "0.2.1", "moment" : "2.11.1", "protractor" : "3.1.1", + "protractor-cucumber-framework": "0.3.4", "wscat": "1.0.1" } } diff --git a/project.clj b/project.clj index f502b4ae8..6d54ceef8 100644 --- a/project.clj +++ b/project.clj @@ -145,6 +145,7 @@ :notify-command ["notify-send"] :compiler {:output-to "target/protractor-tests.js" :optimizations :simple + :target :nodejs :pretty-print true}}}}} :production {:aot :all :hooks [leiningen.cljsbuild leiningen.less] diff --git a/protractor.config.js b/protractor.config.js index 39f655000..f67f20462 100644 --- a/protractor.config.js +++ b/protractor.config.js @@ -1,7 +1,21 @@ exports.config = { // Uncomment this line if running with a separate webdriver server // seleniumAddress: "http://localhost:4444/wd/hub", + // capabilities: { + // browserName: 'phantomjs', + // version: '', + // platform: 'ANY' + // }, + + framework: 'custom', + frameworkPath: require.resolve('protractor-cucumber-framework'), + specs: [ - "target/protractor-tests.js" - ] + 'features/*.feature' + ], + + cucumberOpts: { + require: 'target/protractor-tests.js', + format: 'pretty' + } }; diff --git a/specs/jiksnu/core_spec.cljs b/specs/jiksnu/core_spec.cljs index bd04d94b7..bc6ed9e91 100644 --- a/specs/jiksnu/core_spec.cljs +++ b/specs/jiksnu/core_spec.cljs @@ -1,17 +1,19 @@ (ns jiksnu.core-spec - (:require purnam.test) - (:use-macros [purnam.test :only [beforeEach describe it is is-not]])) + (:require [cljs.nodejs :as nodejs])) + +(nodejs/enable-util-print!) +(def -main (fn [] nil)) +(set! *main-cli-fn* -main) ;; this is required (def base-domain "localhost") (def base-port 8080) (def base-path (str "http://" base-domain ":" base-port)) -(js/describe "foo" - (fn [] - (js/it "FIX THIS: One Plus One Equals... " +(set! (.-exports js/module) (fn [] - (let [page (.get js/browser (str base-path "/"))] - (-> (js/expect (.getTitle js/browser)) - (.toBe "Jiksnu")) - (is (+ 1 1) 2) - (is (+ 2 2) 4)))))) + (this-as this + (.Given this #"^I am logged in$" + (fn [callback] + (.pending callback))) + + (js/console.log this))))