diddy 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p194
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Diddy
2
+
3
+ Diddy is a simple script/scenario runner that is a mix between Spinach, Cucumber and/or Steak. Diddy is not specificly targeted for testing frameworks.
4
+
5
+ At this moment we use Diddy to full integration tests on our various production servers to check if everything works nicely together. We use this in combination
6
+ with the awesome Mechanize gem.
7
+
8
+ ## How it works
9
+
10
+ First define a script:
11
+
12
+
13
+ Diddy::Script.define('Test full server stack') do
14
+ uses AdminSteps
15
+ uses FrontendSteps
16
+ uses ApiSteps
17
+
18
+ step "Login to backend"
19
+ step "Create fake user"
20
+ step "Login to frontend with fake user"
21
+ step "Do some stuff"
22
+ step "Check if API works"
23
+ end
24
+
25
+
26
+ Then, define your steps:
27
+
28
+
29
+ class AdminSteps < Diddy::Steps
30
+ step "Login to backend" do
31
+ # do some stuff
32
+ end
33
+
34
+ step "Create fake user" do
35
+ end
36
+ end
37
+
38
+ Note: every step, needs to return true. If not: the step fails. Make sure you define your steps so that they always return a true or false depending on it's action.
39
+
40
+ ## Scoping
41
+
42
+ Every step definition class, has it own scope. To share variables between step definitions, use the shared object:
43
+
44
+
45
+ class AdminSteps < Diddy::Steps
46
+ step "Create fake user" do
47
+ shared.user_id = HttpParty.post("http://admin.example.com/users", { name: 'Har' }).body.to_i
48
+ end
49
+ end
50
+
51
+ class FrontendSteps < Diddy::Steps
52
+ step "Do some stuff" do
53
+ HttpParty.get("http://www.example.com/api/#{shared.user_id}")
54
+ end
55
+ end
56
+
57
+ This "shared" state (the state of the steps class and the shared vars), lives until a script is finished.
58
+
59
+ ## Run the whole thing
60
+
61
+ After defining your scripts, run the damn monkey!
62
+
63
+
64
+ Diddy::Script.run_all
65
+
66
+ Or, only one script:
67
+
68
+
69
+ Diddy::Script.only_run('Full server stack test')
data/diddy-0.1.0.gem ADDED
Binary file
data/diddy.gemspec CHANGED
@@ -4,9 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "diddy"
7
- gem.version = '0.1.0'
8
- gem.authors = ["Diederick Lawson:"]
9
- gem.email = ["diederick@altovista.nl"]
7
+ gem.version = '0.2.0'
8
+ gem.authors = ["Diederick Lawson", "Marcel de Graaf"]
9
+ gem.email = ["diederick@altovista.nl", "mail@marceldegraaf.net"]
10
10
  gem.description = %q{Diddy script runner}
11
11
  gem.summary = %q{}
12
12
  gem.homepage = "http://github.com/wakoopa/diddy"
data/lib/diddy/script.rb CHANGED
@@ -29,8 +29,8 @@ module Diddy
29
29
  # check if step exists
30
30
  if steps_instance.class.has_step?(description)
31
31
  @steps << Diddy::Step.new(
32
- description: description,
33
- steps_instance: steps_instance,
32
+ description: description,
33
+ steps_instance: steps_instance,
34
34
  definition: steps_instance.class.definition(description)
35
35
  )
36
36
  else
@@ -48,15 +48,19 @@ module Diddy
48
48
  @steps.each do |step|
49
49
  run_step(step)
50
50
  end
51
+ return true
52
+
51
53
  rescue ScriptAborted
52
54
  puts "Aborted"
55
+ return false
56
+
53
57
  end
54
58
  end
55
59
 
56
60
  #
57
61
  # Defines a script
58
- #
59
- # Diddy::Script.define('Test API') do
62
+ #
63
+ # Diddy::Script.define('Test API') do
60
64
  # uses ApiSteps
61
65
  # uses LoginSteps
62
66
  #
@@ -74,10 +78,20 @@ module Diddy
74
78
  end
75
79
 
76
80
  #
77
- # Runs all defined scripts
81
+ # Runs all defined scripts. Returns true if and only if all indivudial
82
+ # scripts returned true. Otherwise returns false.
78
83
  #
79
84
  def self.run_all
80
- @scripts.each { |script| script.run }
85
+ puts "[#{Time.now}] Diddy starting to run #{@scripts.size} scripts"
86
+
87
+ # Run all scripts and remember their return status
88
+ script_statuses = @scripts.map { |script| script.run }
89
+
90
+ puts "[#{Time.now}] Diddy finished running #{@scripts.size} scripts"
91
+
92
+ # If one of the scripts returned with "false"; make the entire run
93
+ # return false as well
94
+ script_statuses.include?(false) ? false : true
81
95
  end
82
96
 
83
97
  #
@@ -87,6 +101,10 @@ module Diddy
87
101
  @scripts.select { |script| script.scenario == scenario }.first.run
88
102
  end
89
103
 
104
+ def self.scripts
105
+ @scripts
106
+ end
107
+
90
108
  private
91
109
 
92
110
  #
data/lib/diddy/step.rb CHANGED
@@ -14,7 +14,7 @@ module Diddy
14
14
  attrs.each { |k,v| send("#{k}=", v) }
15
15
  end
16
16
 
17
- #
17
+ #
18
18
  # Runs the step
19
19
  #
20
20
  def run
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - ! 'Diederick Lawson:'
8
+ - Diederick Lawson
9
+ - Marcel de Graaf
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-11-22 00:00:00.000000000 Z
13
+ date: 2012-11-23 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: term/aniscolor
@@ -30,11 +31,15 @@ dependencies:
30
31
  description: Diddy script runner
31
32
  email:
32
33
  - diederick@altovista.nl
34
+ - mail@marceldegraaf.net
33
35
  executables: []
34
36
  extensions: []
35
37
  extra_rdoc_files: []
36
38
  files:
39
+ - .rbenv-version
37
40
  - .rvmrc
41
+ - README.md
42
+ - diddy-0.1.0.gem
38
43
  - diddy.gemspec
39
44
  - lib/diddy.rb
40
45
  - lib/diddy/helpers.rb