diddy 0.10.3 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjEyNWQ5MWFkNWVjNDkxYWRjNTQ3ZWZlMmU3YTg4ZmNiMjIyOTg1Zg==
4
+ MWUwMzQ0ZmM4MGE2MWRhYTAzMjk0M2UwNWJjMWUxZGVmZTk5Y2U3Mw==
5
5
  data.tar.gz: !binary |-
6
- ZTBjYmJhMTE4YjY2OTYzMmE3YTkyZjg3YmQ2NjE1YTYzMmRjODg2Mg==
6
+ ODllZWZjYjEyN2UzODgzNGU5OTE5OTk2ODY1MmQwMDA4ZWU3MTkzMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzA0ODZlNmE3YWEzNzg3Mzk4NzQ3ODc4NmQzZDcyYjBlYzc2MTMzYmFiNjA2
10
- ODBlMTcwYzhhNzY3ZmIwOGFjZDg1MjVmNjc0NDQzYWM1ZWYzYWJjN2Q2MTg3
11
- N2Q1M2FiODAzN2RlNzE1OTc4NDJhZGUxNTI1MjUyM2Q2ZTJjODM=
9
+ ZGNjNDNmZWE4ZGY0NzE0NWY0MTlmNDM2YTYwZjhjZTg1ODNkNzgyMjQ0NTNi
10
+ NzFlOGQxOTg2ZTk2ODk5Njg5YTk1OWY2ZThmMzU1MzE2ZTQ0ZDhkYjJhNmJj
11
+ NmNmNzNlZDUxMjRjZjYwOWQxZDcxYmUwNDQ5Mjc3Yjk4MTY0OGM=
12
12
  data.tar.gz: !binary |-
13
- NTgwNDJhNzk4MDYwOGEwMzRmZjUwY2I4ZDg2ZDQyYTIzNGFkZGRjMzM1ZTg1
14
- YTk5MzI4YjY3MTdjOGQ4OGQyYzYzNTMzMjIzMDMzNGJkZDlkZDcxOWU0NTI5
15
- NTYyOTA1ZDBhMmJjZDZlYmFlYTk5NjAyNWEzMjdkODM2YzNlOWQ=
13
+ NzQ2MzU2YmUxYzM5ZjRlMzBhM2E2MWE0MzQ0MGE5YzIxMjhmYjJkZjQ4NTQ3
14
+ NWVjZTFmOWI4NWNkN2QwM2MzZDgxZjNlMWQ1Y2U5MjJkNWMyMDNkODY3YWM2
15
+ YjcyOGQ0NmIzMjRjNmNjZTkxMDkyMGMyN2Q4OGQwNTY0OWYzOTA=
data/README.md CHANGED
@@ -7,21 +7,23 @@ with the awesome Mechanize gem.
7
7
 
8
8
  ## How it works
9
9
 
10
- First define a script:
10
+ First define a script and some scenario's:
11
11
 
12
12
 
13
- Diddy::Script.define('Test full server stack') do
14
- uses AdminSteps
15
- uses FrontendSteps
16
- uses ApiSteps
13
+ Diddy::Script.define('Test product X') do
17
14
 
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
15
+ scenario "Checking if app works" do
16
+ uses AdminSteps
17
+ uses FrontendSteps
18
+ uses ApiSteps
24
19
 
20
+ step "Login to backend"
21
+ step "Create fake user"
22
+ step "Login to frontend with fake user"
23
+ step "Do some stuff"
24
+ step "Check if API works"
25
+ end
26
+ end
25
27
 
26
28
  Then, define your steps:
27
29
 
@@ -37,6 +39,20 @@ Then, define your steps:
37
39
 
38
40
  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
41
 
42
+ ## Dynamic/sub steps
43
+
44
+ class AdminSteps < Diddy::Steps
45
+ step "Test if site works" do
46
+ sub_step "Visit root page" do
47
+ end
48
+
49
+ sub_step "Download assets" do
50
+ end
51
+
52
+ sub_step "Check if texts are correct" do
53
+ end
54
+ end
55
+
40
56
  ## Scoping
41
57
 
42
58
  Every step definition class, has it own scope. To share variables between step definitions, use the shared object:
@@ -44,13 +60,13 @@ Every step definition class, has it own scope. To share variables between step d
44
60
 
45
61
  class AdminSteps < Diddy::Steps
46
62
  step "Create fake user" do
47
- shared.user_id = HttpParty.post("http://admin.example.com/users", { name: 'Har' }).body.to_i
63
+ shared[:user_id] = HttpParty.post("http://admin.example.com/users", { name: 'Har' }).body.to_i
48
64
  end
49
65
  end
50
66
 
51
67
  class FrontendSteps < Diddy::Steps
52
68
  step "Do some stuff" do
53
- HttpParty.get("http://www.example.com/api/#{shared.user_id}")
69
+ HttpParty.get("http://www.example.com/api/#{shared[:user_id]}")
54
70
  end
55
71
  end
56
72
 
@@ -58,12 +74,27 @@ This "shared" state (the state of the steps class and the shared vars), lives un
58
74
 
59
75
  ## Run the whole thing
60
76
 
61
- After defining your scripts, run the damn monkey!
77
+ After defining your scripts, instantiate a result logger and let the monkey do it's work:
78
+
79
+ run_log = Diddy::RunResult.new
80
+ Diddy::Script.run(run_log, 'Script name')
62
81
 
82
+ Or, only one scenario:
63
83
 
64
- Diddy::Script.run_all
84
+ ...
85
+ some_script = Diddy::Script.scripts.first
86
+ Diddy::Script.run(run_log, some_script)
65
87
 
66
- Or, only one script:
88
+ ## Context
67
89
 
90
+ It could be usefull to run the same script in another context. In that case you can pass variables around that you can use in your script/scenario:
68
91
 
69
- Diddy::Script.only_run('Full server stack test')
92
+ Diddy::Script.run(run_log, 'Product X', { country: 'us' })
93
+ Diddy::Script.run(run_log, 'Product X', { country: 'uk' })
94
+
95
+ ...
96
+
97
+ step "Fetch current configuration" do
98
+ grab_config "http://api.example.com/#{context[:country]}"
99
+ ...
100
+ end
data/diddy.gemspec CHANGED
@@ -4,7 +4,7 @@ $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.10.3'
7
+ gem.version = '0.11.0'
8
8
  gem.authors = ["Diederick Lawson", "Marcel de Graaf"]
9
9
  gem.email = ["diederick@altovista.nl", "mail@marceldegraaf.net"]
10
10
  gem.description = %q{Diddy script runner}
@@ -16,5 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
+ gem.license = 'MIT'
20
+
19
21
  gem.add_development_dependency "term/ansicolor"
20
22
  end
@@ -65,10 +65,10 @@ module Diddy
65
65
  script.scenarios.each do |scenario|
66
66
  # result was ok? than only log the scenario itself
67
67
  if scenario.result
68
- html << "<h3 class='ok'>#{scenario.description}</h3>"
68
+ html << "<h3 class='ok' style='color: green;'>#{scenario.description}</h3>"
69
69
  else
70
70
  # log the error and it's steps
71
- html << "<h3 class='error'>#{scenario.description}</h3>"
71
+ html << "<h3 class='error' style='color: red;'>#{scenario.description}</h3>"
72
72
  html << "<ul>"
73
73
 
74
74
  # walk over the steps
@@ -77,7 +77,7 @@ module Diddy
77
77
  if step.result
78
78
  html << "<li>#{step.description}"
79
79
  else
80
- html << "<li class='error'>#{step.description}"
80
+ html << "<li class='error' style='color: red;'>#{step.description}"
81
81
  end
82
82
 
83
83
 
@@ -95,7 +95,7 @@ module Diddy
95
95
  if sub_step.result
96
96
  html << "<li>#{sub_step.description}</li>"
97
97
  else
98
- html << "<li class='error'>#{sub_step.description}</li>"
98
+ html << "<li class='error' style='color: red;'>#{sub_step.description}</li>"
99
99
  end
100
100
  end
101
101
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diederick Lawson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-05 00:00:00.000000000 Z
12
+ date: 2013-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term/ansicolor
@@ -51,7 +51,8 @@ files:
51
51
  - lib/diddy/step.rb
52
52
  - lib/diddy/steps.rb
53
53
  homepage: http://github.com/wakoopa/diddy
54
- licenses: []
54
+ licenses:
55
+ - MIT
55
56
  metadata: {}
56
57
  post_install_message:
57
58
  rdoc_options: []
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  version: '0'
70
71
  requirements: []
71
72
  rubyforge_project:
72
- rubygems_version: 2.1.9
73
+ rubygems_version: 2.1.11
73
74
  signing_key:
74
75
  specification_version: 4
75
76
  summary: ''