remove test dependency on resource created before script run (#68)

diff --git a/test/integration/README.md b/test/integration/README.md
index 54fec55..c7f3e2a 100644
--- a/test/integration/README.md
+++ b/test/integration/README.md
@@ -10,39 +10,6 @@
 
 You can retrieve these settings from the `.wskprops` file.
 
-Further, you need to create the following seed artifacts.
+*Note:* If the tests fail, you might need to remove the created artifacts manually.
 
-Action
----
-* Name: hello 
-
-```
-function main() {
-   return {payload: 'Hello world'};
-}
-```
-
-Action
----
-* Name: tests 
-
-```
-function main() {
-   return {payload: 'Hello world'};
-}
-```
-
-Trigger
----
-* Name: sample
-
-
-If you have the `wsk` CLI installed, you may create the required actions and trigger as follows:
-
-    wsk action  create hello action.js
-    wsk action  create tests action.js
-    wsk trigger create sample
-
-where `action.js` contains the `main` function shown above.
-
-*Note:* If the tests fail, the cleanup code does not currently run. You will need to remove the created artifacts manually.
+[Alternatively](https://github.com/apache/incubator-openwhisk-client-js#integration-tests), you can run the `prepIntegrationTests.sh` script using guest credentials or by specifying specific credentials.  
diff --git a/test/integration/prepIntegrationTests.sh b/test/integration/prepIntegrationTests.sh
index 32cd582..3a2e648 100755
--- a/test/integration/prepIntegrationTests.sh
+++ b/test/integration/prepIntegrationTests.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 #set -e
-#Usage: ./test/integration/prepIntegrationTests.sh <yourapikeyintheformofABCD:EFGH> <openwhis hostname> <openwhisk namespace> <api gatewaytoken> <optional "insecure">
+#Usage: ./test/integration/prepIntegrationTests.sh <apikeyintheformofABCD:EFGH> <openwhisk hostname> <openwhisk namespace> <api gatewaytoken> <optional "insecure">
 # Run from the incubator-openwhisk-client-js
 
 # Assert NODEJS6/NPM3 or greater is default node/npm version
@@ -48,19 +48,6 @@
   exit 1;
 fi
 
-
-# make temporary files so that we can use the wsk cli to create actions and triggers.
-# in the instructions the contests of hello and tests are identical so we only make 1 version of the file, and then just create two actions from it.
-echo "Make temporary resource files"
-mkdir temp
-touch temp/tests.js
-echo "function main() {return {payload: 'Hello world'};}" > temp/tests.js
-
-echo "Create wsk actions and triggers for use by tests"
-curl -s --output /dev/null $kflag -u $__OW_API_KEY  -d '{"namespace":"'"$__OW_NAMESPACE"'","name":"hello","exec":{"kind":"nodejs:6","code":"function main() { return {payload:\"Hello world\"}}"}}' -X PUT -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/hello?overwrite=true
-curl -s --output /dev/null $kflag -u $__OW_API_KEY  -d '{"namespace":"'"$__OW_NAMESPACE"'","name":"tests","exec":{"kind":"nodejs:6","code":"function main() { return {payload:\"Hello world\"}}"}}' -X PUT -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/tests?overwrite=true
-curl -s --output /dev/null $kflag -u $__OW_API_KEY -d '{"name":"sample"}' -X PUT -H "Content-Type: application/json"  https://192.168.99.100/api/v1/namespaces/_/triggers/sample?overwrite=true
-
 #run tests
 echo "running tests"
 npm run test-integration $iflag
@@ -81,6 +68,8 @@
 
 #clean up artifacts generated during a bad-testRun
 echo "clean resources"
+cleanresources actions hello
+cleanresources actions tests
 cleanresources actions routeAction
 cleanresources actions random_package_action_test
 cleanresources actions random_action_test
@@ -91,12 +80,6 @@
 cleanresources triggers random_trigger_test
 cleanresources rules random_rule_test
 
-#cleanup workspace
-rm -rf temp
-curl -s --output /dev/null $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/hello
-curl -s --output /dev/null $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/tests
-curl -s --output /dev/null $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/triggers/sample
-
 echo "script finished"
 
 exit $RUNSTAT
diff --git a/test/integration/rules.test.js b/test/integration/rules.test.js
index ac7a156..b1e5f84 100644
--- a/test/integration/rules.test.js
+++ b/test/integration/rules.test.js
@@ -6,6 +6,7 @@
 const test = require('ava')
 const Rules = require('../../lib/rules.js')
 const Triggers = require('../../lib/triggers.js')
+const Actions = require('../../lib/actions.js')
 const Client = require('../../lib/client.js')
 const Utils = require('./utils.js')
 const options = Utils.autoOptions();
@@ -59,19 +60,23 @@
 
   const rules = new Rules(new Client(options))
   const triggers = new Triggers(new Client(options))
-  return triggers.create({triggerName: 'sample_rule_trigger'}).then(() => {
-    return rules.create({ruleName: 'random_rule_test', action: `/${NAMESPACE}/hello`, trigger: `/${NAMESPACE}/sample_rule_trigger`}).then(result => {
-      t.is(result.name, 'random_rule_test')
-      t.is(result.namespace, NAMESPACE)
-      t.deepEqual(result.action, {path: NAMESPACE, name: 'hello'})
-      t.deepEqual(result.trigger, {path: NAMESPACE, name: 'sample_rule_trigger'})
-      return rules.get({ruleName: result.name}).then(rule_result => {
-        t.is(rule_result.name, result.name)
-        t.is(rule_result.namespace, NAMESPACE)
-        t.pass()
-        return rules.disable({ruleName: 'random_rule_test'})
-          .then(() => rules.delete({ruleName: 'random_rule_test'}))
-          .then(() => triggers.delete({triggerName: 'sample_rule_trigger'}))
+  const actions = new Actions(new Client(options))
+  return actions.create({actionName: 'hello', action: 'function main() {return {payload:"Hello world"}}'}).then(() => {
+    return triggers.create({triggerName: 'sample_rule_trigger'}).then(() => {
+      return rules.create({ruleName: 'random_rule_test', action: `/${NAMESPACE}/hello`, trigger: `/${NAMESPACE}/sample_rule_trigger`}).then(result => {
+        t.is(result.name, 'random_rule_test')
+        t.is(result.namespace, NAMESPACE)
+        t.deepEqual(result.action, {path: NAMESPACE, name: 'hello'})
+        t.deepEqual(result.trigger, {path: NAMESPACE, name: 'sample_rule_trigger'})
+        return rules.get({ruleName: result.name}).then(rule_result => {
+          t.is(rule_result.name, result.name)
+          t.is(rule_result.namespace, NAMESPACE)
+          t.pass()
+          return rules.disable({ruleName: 'random_rule_test'})
+            .then(() => rules.delete({ruleName: 'random_rule_test'}))
+            .then(() => triggers.delete({triggerName: 'sample_rule_trigger'}))
+            .then(() => actions.delete({actionName: 'hello'}))
+        })
       })
     })
   }).catch(errors)
@@ -85,21 +90,29 @@
 
   const rules = new Rules(new Client(options))
   const triggers = new Triggers(new Client(options))
-  return triggers.create({triggerName: 'sample_rule_trigger'}).then(() => {
-    return rules.create({ruleName: 'random_update_test', action: `/${NAMESPACE}/hello`, trigger: `/${NAMESPACE}/sample_rule_trigger`}).then(result => {
-      t.is(result.name, 'random_update_test')
-      t.is(result.namespace, NAMESPACE)
-      t.deepEqual(result.action, {path: NAMESPACE, name: 'hello'})
-      t.deepEqual(result.trigger, {path: NAMESPACE, name: 'sample_rule_trigger'})
-      return rules.disable({ruleName: 'random_update_test'}).then(() => {
-        return rules.update({ruleName: 'random_update_test', action: 'tests', trigger: 'sample_rule_trigger'}).then(update_result => {
-          t.deepEqual(update_result.action, {path: NAMESPACE, name: 'tests'})
-          t.pass()
-          return rules.delete({ruleName: 'random_update_test'})
-            .then(() => triggers.delete({triggerName: 'sample_rule_trigger'}))
-            .catch(errors)
-        })
+  const actions = new Actions(new Client(options))
+  return actions.create({actionName: 'hello', action: 'function main() {return {payload:"Hello world"}}'}).then(() => {
+
+    return actions.create({actionName: 'tests', action: 'function main() {return {payload:"Hello world"}}' }).then(() => {
+      return triggers.create({triggerName: 'sample_rule_trigger'}).then(() => {
+        return rules.create({ruleName: 'random_update_test', action: `/${NAMESPACE}/hello`, trigger: `/${NAMESPACE}/sample_rule_trigger`}).then(result => {
+          t.is(result.name, 'random_update_test')
+          t.is(result.namespace, NAMESPACE)
+          t.deepEqual(result.action, {path: NAMESPACE, name: 'hello'})
+          t.deepEqual(result.trigger, {path: NAMESPACE, name: 'sample_rule_trigger'})
+          return rules.disable({ruleName: 'random_update_test'}).then(() => {
+            return rules.update({ruleName: 'random_update_test', action: 'tests', trigger: 'sample_rule_trigger'}).then(update_result => {
+              t.deepEqual(update_result.action, {path: NAMESPACE, name: 'tests'})
+              t.pass()
+              return rules.delete({ruleName: 'random_update_test'})
+                .then(() => triggers.delete({triggerName: 'sample_rule_trigger'}))
+                .then(() => actions.delete({actionName: 'hello'}))
+                .then(() => actions.delete({actionName: 'tests'}))
+                .catch(errors)
+            })
+          })
+        }).catch(errors)
       })
-    }).catch(errors)
-  }).catch(errors)
+    })
+  }).catch(errors);
 })