spex 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/README.md +30 -12
  2. data/VERSION +1 -1
  3. data/examples/chgrp.rb +1 -1
  4. data/examples/chmod.rb +1 -1
  5. data/examples/chown.rb +1 -1
  6. data/examples/postfix.rb +4 -4
  7. data/examples/puppet.rb +1 -1
  8. data/examples/touch.rb +1 -1
  9. data/examples/writing.rb +1 -1
  10. data/lib/spex.rb +2 -2
  11. data/lib/spex/{assertion.rb → check.rb} +4 -4
  12. data/lib/spex/{assertions/changed_group_assertion.rb → checks/changed_group_check.rb} +7 -7
  13. data/lib/spex/{assertions/changed_mode_assertion.rb → checks/changed_mode_check.rb} +5 -5
  14. data/lib/spex/{assertions/changed_owner_assertion.rb → checks/changed_owner_check.rb} +7 -7
  15. data/lib/spex/{assertions/created_assertion.rb → checks/created_check.rb} +5 -5
  16. data/lib/spex/{assertions/file_assertion.rb → checks/file_check.rb} +1 -1
  17. data/lib/spex/{assertions/modified_assertion.rb → checks/modified_check.rb} +7 -7
  18. data/lib/spex/{assertions/process_assertion.rb → checks/process_check.rb} +1 -1
  19. data/lib/spex/{assertions/removed_assertion.rb → checks/removed_check.rb} +5 -5
  20. data/lib/spex/{assertions/restarted_assertion.rb → checks/restarted_check.rb} +3 -3
  21. data/lib/spex/{assertions/started_assertion.rb → checks/started_check.rb} +3 -3
  22. data/lib/spex/{assertions/stopped_assertion.rb → checks/stopped_check.rb} +3 -3
  23. data/lib/spex/cli.rb +7 -7
  24. data/lib/spex/execution.rb +8 -8
  25. data/lib/spex/runner.rb +13 -13
  26. data/test/helper.rb +13 -13
  27. data/test/{test_assertion.rb → test_check.rb} +7 -7
  28. data/test/{test_modified_assertion.rb → test_modified_check.rb} +23 -23
  29. data/test/{test_restarted_assertion.rb → test_restarted_check.rb} +14 -14
  30. data/test/test_script.rb +9 -9
  31. data/test/{test_started_assertion.rb → test_started_check.rb} +12 -12
  32. data/test/{test_stopped_assertion.rb → test_stopped_check.rb} +12 -12
  33. metadata +25 -25
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
1
  Spex
2
2
  ====
3
3
 
4
- A quick and dirty test harness for testing assertions before and after
4
+ A quick and dirty harness for running system state checks before and after
5
5
  an executable is run.
6
6
 
7
+ It can be used:
8
+ * When developing an executable/configuration, to check real-world
9
+ results.
10
+ * In production, to ensure the system is in a known state before an
11
+ executable is run.
12
+ * In production, to provide independent logging/reporting of
13
+ executable status.
14
+
7
15
  Synopsis
8
16
  --------
9
17
 
@@ -16,7 +24,7 @@ be used to verify running `touch /tmp/foo` will create a new file:
16
24
 
17
25
  scenario "Creates a file" do
18
26
  executing 'touch /tmp/foo' do
19
- assert '/tmp/foo', :created => true
27
+ check '/tmp/foo', :created => true
20
28
  end
21
29
  end
22
30
 
@@ -25,7 +33,7 @@ If this was in `run_touch.rb`, you could run this with spex:
25
33
  $ spex run_touch.rb
26
34
 
27
35
  You'll notice that this should pass the first time and fail on
28
- subsequent invocations -- because the assertion added by `:created => true` fails in the
36
+ subsequent invocations -- because the check added by `:created => true` fails in the
29
37
  event a file exists *before* the command is run.
30
38
 
31
39
  If you want to see what command and scenarios are defined in a file,
@@ -45,20 +53,30 @@ Examples
45
53
 
46
54
  See the `examples/` directory.
47
55
 
48
- Assertions
49
- ----------
56
+ Checks
57
+ ------
58
+
59
+ You can see the checks that are available with the following command:
50
60
 
51
- See the [wiki](http://wiki.github.com/bruce/spex/supported-assertions)
52
- for the list of supported assertions.
61
+ $ spex --checks
53
62
 
54
- To add an assertion, create a class that inherits from
55
- `Spex::Assertion` and implements all the neccessary methods. See
56
- `Spex::Assertion` and the currently defined assertions for
63
+ To add an check, create a class that inherits from
64
+ `Spex::Check` and implements all the neccessary methods. See
65
+ `Spex::Check` and the currently defined checks for
57
66
  examples.
58
67
 
59
- Note: If you put your assertions in `~/.spex/assertions/*.rb`,
68
+ Note: If you put your checks in `~/.spex/checks/*.rb`,
60
69
  they'll automatically be loaded. If you create any interesting
61
- assertions, add them to the [wiki](http://wiki.github.com/bruce/spex/community-assertions)!
70
+ checks, add them to the
71
+ [wiki](http://wiki.github.com/bruce/spex/community-checks)!
72
+
73
+ Other Resources
74
+ ---------------
75
+
76
+ For more information, see the
77
+ [wiki](http://wiki.github.com/bruce/spex).
78
+
79
+ You can file bugs and features using the [issue tracker](http://github.com/bruce/spex/issues).
62
80
 
63
81
  Copyright
64
82
  ---------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
@@ -1,5 +1,5 @@
1
1
  scenario "Change group" do
2
2
  executing "sudo chgrp everyone /tmp/foo" do
3
- assert '/tmp/foo', :changed_group => {:to => 'everyone'}
3
+ check '/tmp/foo', :changed_group => {:to => 'everyone'}
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  scenario "Change mode" do
2
2
  executing "chmod 700 /tmp/foo" do
3
- assert '/tmp/foo', :changed_mode => {:to => 0700}
3
+ check '/tmp/foo', :changed_mode => {:to => 0700}
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  scenario "Change owner" do
2
2
  executing "sudo chown root /tmp/foo" do
3
- assert '/tmp/foo', :changed_owner => {:to => 'root'}
3
+ check '/tmp/foo', :changed_owner => {:to => 'root'}
4
4
  end
5
5
  end
@@ -2,15 +2,15 @@
2
2
  # we don't confused with spex running this file (postfix.rb)
3
3
  scenario "Postfix process management" do
4
4
  executing "sudo postfix start" do
5
- assert 'postfix/master', :started => true
5
+ check 'postfix/master', :started => true
6
6
  end
7
7
  executing "sudo postfix stop" do
8
- assert 'postfix/master', :stopped => true
8
+ check 'postfix/master', :stopped => true
9
9
  end
10
10
  executing "sudo postfix start" do
11
- assert 'postfix/master', :started => true
11
+ check 'postfix/master', :started => true
12
12
  end
13
13
  executing "sudo postfix stop && sudo postfix start" do
14
- assert 'postfix/master', :restarted => true
14
+ check 'postfix/master', :restarted => true
15
15
  end
16
16
  end
@@ -4,6 +4,6 @@ end
4
4
 
5
5
  scenario "Creates a file" do
6
6
  executing "puppet /tmp/spex-manifest.pp" do
7
- assert '/tmp/foo', :created => true
7
+ check '/tmp/foo', :created => true
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  scenario "Creates a file" do
2
2
  executing "touch /tmp/foo" do
3
- assert '/tmp/foo', :created => true
3
+ check '/tmp/foo', :created => true
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  scenario "Modifies a file" do
2
2
  executing "echo 'foo' >> /tmp/foo" do
3
- assert '/tmp/foo', :modified => true
3
+ check '/tmp/foo', :modified => true
4
4
  end
5
5
  end
@@ -5,10 +5,10 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  module Spex
8
- autoload :Assertion, 'spex/assertion'
8
+ autoload :Check, 'spex/check'
9
9
  autoload :CLI, 'spex/cli'
10
10
  autoload :Execution, 'spex/execution'
11
- autoload :FileAssertion, 'spex/assertions/file_assertion'
11
+ autoload :FileCheck, 'spex/checks/file_check'
12
12
  autoload :Runner, 'spex/runner'
13
13
  autoload :Scenario, 'spex/scenario'
14
14
  autoload :Script, 'spex/script'
@@ -1,7 +1,7 @@
1
1
  require 'test/unit/assertions'
2
2
 
3
3
  module Spex
4
- class Assertion
4
+ class Check
5
5
  include Test::Unit::Assertions
6
6
  extend Enumerable
7
7
 
@@ -22,7 +22,7 @@ module Spex
22
22
  def self.as(name, description)
23
23
  self.name = name
24
24
  self.description = description
25
- Assertion.registry[name.to_sym] = self
25
+ Check.registry[name.to_sym] = self
26
26
  end
27
27
 
28
28
  def self.example(description, text)
@@ -92,10 +92,10 @@ module Spex
92
92
  end
93
93
  end
94
94
 
95
- Dir.glob(File.join(File.dirname(__FILE__), 'assertions', '**/*.rb')) do |path|
95
+ Dir.glob(File.join(File.dirname(__FILE__), 'checks', '**/*.rb')) do |path|
96
96
  require path
97
97
  end
98
98
 
99
- Dir.glob(File.join(ENV['HOME'], '.spex', 'assertions', '**/*.rb')) do |path|
99
+ Dir.glob(File.join(ENV['HOME'], '.spex', 'checks', '**/*.rb')) do |path|
100
100
  require path
101
101
  end
@@ -1,17 +1,17 @@
1
1
  require 'etc'
2
2
 
3
3
  module Spex
4
- class ChangedGroupAssertion < FileAssertion
4
+ class ChangedGroupCheck < FileCheck
5
5
  as :changed_group, 'file group change'
6
6
  option :to, "To group name or gid"
7
7
  option :from, "From group name or gid"
8
8
 
9
- example "Changed the file group", "assert '/tmp/foo', :changed_group => true"
10
- example "Did not change the file group", "assert '/tmp/foo', :changed_group => false"
11
- example "Changed the file group from 'wheel' to 'www-users'", "assert '/tmp/foo', :changed_group => {:from => 'wheel', :to => 'www-users'}"
12
- example "Changed the file group from gid 210 to gid 288", "assert '/tmp/foo', :changed_group => {:from => 210, :to => 288}"
13
- example "Changed the file group to 'users'", "assert '/tmp/foo', :changed_group => {:to => 'users'}"
14
- example "Changed the file group to gid 203", "assert '/tmp/foo', :changed_group => {:to => 203}"
9
+ example "Changed the file group", "check '/tmp/foo', :changed_group => true"
10
+ example "Did not change the file group", "check '/tmp/foo', :changed_group => false"
11
+ example "Changed the file group from 'wheel' to 'www-users'", "check '/tmp/foo', :changed_group => {:from => 'wheel', :to => 'www-users'}"
12
+ example "Changed the file group from gid 210 to gid 288", "check '/tmp/foo', :changed_group => {:from => 210, :to => 288}"
13
+ example "Changed the file group to 'users'", "check '/tmp/foo', :changed_group => {:to => 'users'}"
14
+ example "Changed the file group to gid 203", "check '/tmp/foo', :changed_group => {:to => 203}"
15
15
 
16
16
  def before
17
17
  assert File.exist?(target), "File does not exist at #{target}"
@@ -1,13 +1,13 @@
1
1
  module Spex
2
- class ChangedModeAssertion < FileAssertion
2
+ class ChangedModeCheck < FileCheck
3
3
  as :changed_mode, "file mode change"
4
4
  option :from, "Mode changed from (octal, eg 0600)"
5
5
  option :to, "Mode changed to (octal, eg 0700)"
6
6
 
7
- example "Changed the file mode", "assert '/tmp/foo', :changed_mode => true"
8
- example "Did not change the file mode", "assert '/tmp/foo', :changed_mode => false"
9
- example "Changed the file mode from 0666 to 0755", "assert '/tmp/foo', :changed_mode => {:from => 0666, :to => 0755}"
10
- example "Changed the file mode to 0750", "assert '/tmp/foo', :changed_mode => {:to => 0750}"
7
+ example "Changed the file mode", "check '/tmp/foo', :changed_mode => true"
8
+ example "Did not change the file mode", "check '/tmp/foo', :changed_mode => false"
9
+ example "Changed the file mode from 0666 to 0755", "check '/tmp/foo', :changed_mode => {:from => 0666, :to => 0755}"
10
+ example "Changed the file mode to 0750", "check '/tmp/foo', :changed_mode => {:to => 0750}"
11
11
 
12
12
  def before
13
13
  assert File.exist?(target), "File does not exist at #{target}"
@@ -1,17 +1,17 @@
1
1
  require 'etc'
2
2
 
3
3
  module Spex
4
- class ChangedOwnerAssertion < FileAssertion
4
+ class ChangedOwnerCheck < FileCheck
5
5
  as :changed_owner, 'file owner change'
6
6
  option :from, "From username or uid"
7
7
  option :to, "To username or uid"
8
8
 
9
- example "Changed the file owner", "assert '/tmp/foo', :changed_owner => true"
10
- example "Did not change the file owner", "assert '/tmp/foo', :changed_owner => false"
11
- example "Changed the file owner from 'root' to 'bruce'", "assert '/tmp/foo', :changed_owner => {:from => 'root', :to => 'bruce'}"
12
- example "Changed the file owner from uid 501 to uid 503", "assert '/tmp/foo', :changed_owner => {:from => 501, :to => 503}"
13
- example "Changed the file owner to 'jim'", "assert '/tmp/foo', :changed_owner => {:to => 'jim'}"
14
- example "Changed the file owner to uid 506", "assert '/tmp/foo', :changed_owner => {:to => 506}"
9
+ example "Changed the file owner", "check '/tmp/foo', :changed_owner => true"
10
+ example "Did not change the file owner", "check '/tmp/foo', :changed_owner => false"
11
+ example "Changed the file owner from 'root' to 'bruce'", "check '/tmp/foo', :changed_owner => {:from => 'root', :to => 'bruce'}"
12
+ example "Changed the file owner from uid 501 to uid 503", "check '/tmp/foo', :changed_owner => {:from => 501, :to => 503}"
13
+ example "Changed the file owner to 'jim'", "check '/tmp/foo', :changed_owner => {:to => 'jim'}"
14
+ example "Changed the file owner to uid 506", "check '/tmp/foo', :changed_owner => {:to => 506}"
15
15
 
16
16
  def before
17
17
  assert File.exist?(target), "File does not exist at #{target}"
@@ -1,11 +1,11 @@
1
1
  module Spex
2
- class CreatedAssertion < FileAssertion
2
+ class CreatedCheck < FileCheck
3
3
  as :created, 'file creation'
4
4
  option :type, "Type ('file' or 'directory'), optional"
5
- example "File was created", "assert '/tmp/foo', :created => true"
6
- example "File was not created", "assert '/tmp/foo', :created => false"
7
- example "Regular file was created", "assert '/tmp/foo', :created => {:type => 'file'}"
8
- example "Directory was created", "assert '/tmp/foo', :created => {:type => 'directory'}"
5
+ example "File was created", "check '/tmp/foo', :created => true"
6
+ example "File was not created", "check '/tmp/foo', :created => false"
7
+ example "Regular file was created", "check '/tmp/foo', :created => {:type => 'file'}"
8
+ example "Directory was created", "check '/tmp/foo', :created => {:type => 'directory'}"
9
9
 
10
10
  def before
11
11
  assert !File.exist?(target), "File already exists at #{target}"
@@ -1,5 +1,5 @@
1
1
  module Spex
2
- class FileAssertion < Assertion
2
+ class FileCheck < Check
3
3
 
4
4
  def kind
5
5
  options[:type] ? options[:type].to_sym : :any
@@ -5,16 +5,16 @@ require 'diff/lcs/array'
5
5
  module Spex
6
6
 
7
7
  # With no option, just verifies a change occurs
8
- class ModifiedAssertion < FileAssertion
8
+ class ModifiedCheck < FileCheck
9
9
  as :modified, 'file modification'
10
10
  option :added, "Added content (string or regexp)"
11
11
  option :removed, "Removed content (string or regexp)"
12
- example "Modified a file", "assert '/tmp/foo', :modified => true"
13
- example "Did not modify a file", "assert '/tmp/foo', :modified => false"
14
- example "Added a line with 'a substring' in it", "assert '/tmp/foo', :modified => {:added => 'a substring'}"
15
- example "Added a line matching /a substring pattern/", "assert '/tmp/foo', :modified => {:added => /a substring pattern/}"
16
- example "Removed a line with 'a substring' in it", "assert '/tmp/foo', :modified => {:removed => 'a substring'}"
17
- example "Removed a line matching /a substring pattern/", "assert '/tmp/foo', :modified => {:removed => /a substring pattern/}"
12
+ example "Modified a file", "check '/tmp/foo', :modified => true"
13
+ example "Did not modify a file", "check '/tmp/foo', :modified => false"
14
+ example "Added a line with 'a substring' in it", "check '/tmp/foo', :modified => {:added => 'a substring'}"
15
+ example "Added a line matching /a substring pattern/", "check '/tmp/foo', :modified => {:added => /a substring pattern/}"
16
+ example "Removed a line with 'a substring' in it", "check '/tmp/foo', :modified => {:removed => 'a substring'}"
17
+ example "Removed a line matching /a substring pattern/", "check '/tmp/foo', :modified => {:removed => /a substring pattern/}"
18
18
 
19
19
  def prepare
20
20
  track_checksum!
@@ -1,5 +1,5 @@
1
1
  module Spex
2
- class ProcessAssertion < Assertion
2
+ class ProcessCheck < Check
3
3
 
4
4
  def pattern
5
5
  @pattern ||= target.is_a?(Regexp) ? target : Regexp.new(target)
@@ -1,11 +1,11 @@
1
1
  module Spex
2
- class RemovedAssertion < FileAssertion
2
+ class RemovedCheck < FileCheck
3
3
  as :removed, 'file removal'
4
4
  option :type, "Type (:file or :directory), optional"
5
- example "File was removed", "assert '/tmp/foo', :removed => true"
6
- example "File was not removed", "assert '/tmp/foo', :removed => false"
7
- example "Regular file was removed", "assert '/tmp/foo', :removed => {:type => 'file'}"
8
- example "Directory was removed", "assert '/tmp/foo', :removed => {:type => 'directory'}"
5
+ example "File was removed", "check '/tmp/foo', :removed => true"
6
+ example "File was not removed", "check '/tmp/foo', :removed => false"
7
+ example "Regular file was removed", "check '/tmp/foo', :removed => {:type => 'file'}"
8
+ example "Directory was removed", "check '/tmp/foo', :removed => {:type => 'directory'}"
9
9
 
10
10
  def before
11
11
  assert File.exist?(target), "File does not exist at #{target}"
@@ -1,8 +1,8 @@
1
1
  module Spex
2
- class RestartedAssertion < ProcessAssertion
2
+ class RestartedCheck < ProcessCheck
3
3
  as :restarted, 'process restart'
4
- example "Process was restarted", "assert 'postfix', :restarted => true"
5
- example "Process was not restarted", "assert 'postfix', :restarted => false"
4
+ example "Process was restarted", "check 'postfix', :restarted => true"
5
+ example "Process was not restarted", "check 'postfix', :restarted => false"
6
6
 
7
7
  def before
8
8
  @before_pid = current_pid
@@ -1,8 +1,8 @@
1
1
  module Spex
2
- class StartedAssertion < ProcessAssertion
2
+ class StartedCheck < ProcessCheck
3
3
  as :started, 'process start'
4
- example "Process was started", "assert 'postfix', :started => true"
5
- example "Process was not started", "assert 'postfix', :started => false"
4
+ example "Process was started", "check 'postfix', :started => true"
5
+ example "Process was not started", "check 'postfix', :started => false"
6
6
 
7
7
  def before
8
8
  pid = current_pid
@@ -1,8 +1,8 @@
1
1
  module Spex
2
- class StoppedAssertion < ProcessAssertion
2
+ class StoppedCheck < ProcessCheck
3
3
  as :stopped, 'process stop'
4
- example "Process was stopped", "assert 'postfix', :stopped => true"
5
- example "Process was not stopped", "assert 'postfix', :stopped => false"
4
+ example "Process was stopped", "check 'postfix', :stopped => true"
5
+ example "Process was not stopped", "check 'postfix', :stopped => false"
6
6
 
7
7
  def before
8
8
  assert current_pid, "Process '#{target}' is not running (will not be stopped)"
@@ -23,8 +23,8 @@ module Spex
23
23
  opts.on('--describe', '-d', 'Describe DEFINITION_FILE') do
24
24
  options.describe = true
25
25
  end
26
- opts.on('--assertions', '-a', "List supported assertions") do
27
- display_assertions
26
+ opts.on('--checks', '-c', "List supported checks") do
27
+ display_checks
28
28
  exit
29
29
  end
30
30
  end
@@ -53,9 +53,9 @@ module Spex
53
53
  end
54
54
  end
55
55
 
56
- def display_assertions
57
- Assertion.registry.each_value do |klass|
58
- line = "Assertion: :#{klass.name} (#{klass.description})"
56
+ def display_checks
57
+ Check.registry.each_value do |klass|
58
+ line = "Check: :#{klass.name} (#{klass.description})"
59
59
  puts line
60
60
  if klass.options.any? || klass.examples.any?
61
61
  puts('=' * line.size)
@@ -82,8 +82,8 @@ module Spex
82
82
  puts %(In scenario "#{scenario.name}")
83
83
  scenario.executions.each do |execution|
84
84
  puts " When executing `#{execution.command}`"
85
- execution.assertions.each do |assertion|
86
- puts " assert #{assertion}"
85
+ execution.checks.each do |check|
86
+ puts " assert #{check}"
87
87
  end
88
88
  end
89
89
  end
@@ -9,16 +9,16 @@ module Spex
9
9
  Builder.new(self, &block)
10
10
  end
11
11
 
12
- def assertions
13
- @assertions ||= []
12
+ def checks
13
+ @checks ||= []
14
14
  end
15
15
 
16
- def <<(assertion)
17
- assertions << assertion
16
+ def <<(check)
17
+ checks << check
18
18
  end
19
19
 
20
20
  def each(&block)
21
- assertions.each(&block)
21
+ checks.each(&block)
22
22
  end
23
23
 
24
24
  class Builder
@@ -27,9 +27,9 @@ module Spex
27
27
  instance_eval(&block) if block_given?
28
28
  end
29
29
 
30
- def assert(target, assertion_names = {})
31
- assertion_names.each do |name, options|
32
- @execution << Assertion[name].new(target, options)
30
+ def check(target, check_names = {})
31
+ check_names.each do |name, options|
32
+ @execution << Check[name].new(target, options)
33
33
  end
34
34
  end
35
35
  end
@@ -19,10 +19,10 @@ module Spex
19
19
  proceed = true
20
20
  scenario.each do |execution|
21
21
  puts %(Preparing to execute "#{execution.command}").bold
22
- execution.assertions.each do |assertion|
23
- print "Pre-assertions for #{assertion}: "
24
- assertion.prepare
25
- proceed = report { assertion.before }
22
+ execution.checks.each do |check|
23
+ print "Pre-checks for #{check}: "
24
+ check.prepare
25
+ proceed = report { check.before }
26
26
  break unless proceed
27
27
  end
28
28
  if proceed
@@ -32,13 +32,13 @@ module Spex
32
32
  elapsed = Time.now - start
33
33
  puts 'DONE (%.2fs)' % elapsed
34
34
  passed = true
35
- execution.assertions.reverse.each do |assertion|
36
- print "Post-assertions for #{assertion}: "
37
- passed = report { assertion.after }
35
+ execution.checks.reverse.each do |check|
36
+ print "Post-checks for #{check}: "
37
+ passed = report { check.after }
38
38
  break unless passed
39
39
  end
40
40
  unless passed
41
- abort "SCENARIO ASSERTIONS FAILED".red.bold
41
+ abort "SCENARIO CHECKS FAILED".red.bold
42
42
  end
43
43
  output_log(execution, log)
44
44
  else
@@ -96,13 +96,13 @@ module Spex
96
96
  setup do
97
97
  @executed ||= self.class.spex_runner.execute(self.class.execution)
98
98
  end
99
- order = parent.execution.assertions.reverse
99
+ order = parent.execution.checks.reverse
100
100
  when :before
101
- order = parent.execution.assertions
101
+ order = parent.execution.checks
102
102
  end
103
- order.each do |assertion|
104
- should "pass assertion #{assertion.inspect}" do
105
- assertion.__send__(event, self)
103
+ order.each do |check|
104
+ should "pass check #{check.inspect}" do
105
+ check.__send__(event, self)
106
106
  end
107
107
  end
108
108
  end
@@ -17,34 +17,34 @@ class Test::Unit::TestCase
17
17
  @script = Spex::Script.evaluate(&block)
18
18
  end
19
19
 
20
- def assertion_passes(&block)
21
- @assertion.prepare
22
- @assertion.before
20
+ def check_passes(&block)
21
+ @check.prepare
22
+ @check.before
23
23
  yield if block_given?
24
- @assertion.after
24
+ @check.after
25
25
  end
26
26
 
27
- def assertion_fails_before
27
+ def check_fails_before
28
28
  assert_raises Test::Unit::AssertionFailedError do
29
- @assertion.prepare
30
- @assertion.before
29
+ @check.prepare
30
+ @check.before
31
31
  end
32
32
  end
33
33
 
34
- def assertion_fails(&block)
34
+ def check_fails(&block)
35
35
  assert_raises Test::Unit::AssertionFailedError do
36
- assertion_passes(&block)
36
+ check_passes(&block)
37
37
  end
38
38
  end
39
39
 
40
40
  def start_process!(pid = '100')
41
- flexmock(@assertion).flexmock_teardown
42
- flexmock(@assertion).should_receive(:current_pid).and_return(pid)
41
+ flexmock(@check).flexmock_teardown
42
+ flexmock(@check).should_receive(:current_pid).and_return(pid)
43
43
  end
44
44
 
45
45
  def stop_process!
46
- flexmock(@assertion).flexmock_teardown
47
- flexmock(@assertion).should_receive(:current_pid).and_return(nil)
46
+ flexmock(@check).flexmock_teardown
47
+ flexmock(@check).should_receive(:current_pid).and_return(nil)
48
48
  end
49
49
 
50
50
  end
@@ -1,14 +1,14 @@
1
1
  require 'helper'
2
2
 
3
- class TestAssertion < Test::Unit::TestCase
4
- context "Assertion" do
3
+ class TestCheck < Test::Unit::TestCase
4
+ context "Check" do
5
5
  setup do
6
- @klass = Class.new(Spex::Assertion)
6
+ @klass = Class.new(Spex::Check)
7
7
  end
8
8
 
9
9
  context "instances" do
10
10
  should "raise an exception if instantiated with an unknown option" do
11
- assert_raises Spex::Assertion::UnknownOptionError do
11
+ assert_raises Spex::Check::UnknownOptionError do
12
12
  @klass.new('/tmp/foo', :unknown => 'option')
13
13
  end
14
14
  end
@@ -20,8 +20,8 @@ class TestAssertion < Test::Unit::TestCase
20
20
  @klass.as :something, "Something being added"
21
21
  end
22
22
 
23
- should "be added to the list of assertions" do
24
- assert_equal @klass, Spex::Assertion[:something]
23
+ should "be added to the list of checks" do
24
+ assert_equal @klass, Spex::Check[:something]
25
25
  end
26
26
  end
27
27
 
@@ -41,7 +41,7 @@ class TestAssertion < Test::Unit::TestCase
41
41
  end
42
42
 
43
43
  should "be of the correct class" do
44
- assert_kind_of Spex::Assertion::Option, @option
44
+ assert_kind_of Spex::Check::Option, @option
45
45
  end
46
46
 
47
47
  should "have a name" do
@@ -1,9 +1,9 @@
1
1
  require 'helper'
2
2
 
3
- class TestModifiedAssertion < Test::Unit::TestCase
3
+ class TestModifiedCheck < Test::Unit::TestCase
4
4
 
5
- def set_assertion(options = {})
6
- @assertion = Spex::ModifiedAssertion.new(@filename, options)
5
+ def set_check(options = {})
6
+ @check = Spex::ModifiedCheck.new(@filename, options)
7
7
  end
8
8
 
9
9
  def non_blank_file!(text = 'test')
@@ -14,7 +14,7 @@ class TestModifiedAssertion < Test::Unit::TestCase
14
14
  File.open(@filename, 'w') { |f| f.puts }
15
15
  end
16
16
 
17
- context "Modified Assertion" do
17
+ context "Modified Check" do
18
18
  setup do
19
19
  FakeFS.activate!
20
20
  @filename = '/tmp/modified-test'
@@ -27,56 +27,56 @@ class TestModifiedAssertion < Test::Unit::TestCase
27
27
  context "instances" do
28
28
  context "without options" do
29
29
  setup do
30
- set_assertion
30
+ set_check
31
31
  blank_file!
32
32
  end
33
33
  should "pass when modifications happen" do
34
- assertion_passes { non_blank_file! }
34
+ check_passes { non_blank_file! }
35
35
  end
36
36
  should "when modifications don't happen" do
37
- assertion_fails
37
+ check_fails
38
38
  end
39
39
  end
40
40
  context "with :added" do
41
41
  context "as a string" do
42
42
  setup do
43
- set_assertion(:added => 'test')
43
+ set_check(:added => 'test')
44
44
  blank_file!
45
45
  end
46
46
  context "when the text is added" do
47
47
  should "pass" do
48
- assertion_passes { non_blank_file! }
48
+ check_passes { non_blank_file! }
49
49
  end
50
50
  end
51
51
  context "when different text is added" do
52
52
  should "fail" do
53
- assertion_fails { non_blank_file!('other') }
53
+ check_fails { non_blank_file!('other') }
54
54
  end
55
55
  end
56
56
  context "when modifications don't happen" do
57
57
  should "fail when modifications don't happen" do
58
- assertion_fails
58
+ check_fails
59
59
  end
60
60
  end
61
61
  end
62
62
  context "as a regexp" do
63
63
  setup do
64
- set_assertion(:added => /t.st/)
64
+ set_check(:added => /t.st/)
65
65
  blank_file!
66
66
  end
67
67
  context "when the text is added" do
68
68
  should "pass" do
69
- assertion_passes { non_blank_file! }
69
+ check_passes { non_blank_file! }
70
70
  end
71
71
  end
72
72
  context "when different text is added" do
73
73
  should "fail" do
74
- assertion_fails { non_blank_file!('other') }
74
+ check_fails { non_blank_file!('other') }
75
75
  end
76
76
  end
77
77
  context "when modifications don't happen" do
78
78
  should "fail when modifications don't happen" do
79
- assertion_fails
79
+ check_fails
80
80
  end
81
81
  end
82
82
  end
@@ -84,14 +84,14 @@ class TestModifiedAssertion < Test::Unit::TestCase
84
84
  context "with :removed" do
85
85
  context "as a string" do
86
86
  setup do
87
- set_assertion(:removed => 'test')
87
+ set_check(:removed => 'test')
88
88
  end
89
89
  context "when the text is removed" do
90
90
  setup do
91
91
  non_blank_file!
92
92
  end
93
93
  should "pass" do
94
- assertion_passes { blank_file! }
94
+ check_passes { blank_file! }
95
95
  end
96
96
  end
97
97
  context "when different text is removed" do
@@ -99,25 +99,25 @@ class TestModifiedAssertion < Test::Unit::TestCase
99
99
  non_blank_file!('other')
100
100
  end
101
101
  should "fail" do
102
- assertion_fails { blank_file! }
102
+ check_fails { blank_file! }
103
103
  end
104
104
  end
105
105
  context "when modifications don't happen" do
106
106
  should "fail when modifications don't happen" do
107
- assertion_fails
107
+ check_fails
108
108
  end
109
109
  end
110
110
  end
111
111
  context "as a regexp" do
112
112
  setup do
113
- set_assertion(:removed => /t.st/)
113
+ set_check(:removed => /t.st/)
114
114
  end
115
115
  context "when the text is removed" do
116
116
  setup do
117
117
  non_blank_file!
118
118
  end
119
119
  should "pass" do
120
- assertion_passes { blank_file! }
120
+ check_passes { blank_file! }
121
121
  end
122
122
  end
123
123
  context "when different text is removed" do
@@ -125,12 +125,12 @@ class TestModifiedAssertion < Test::Unit::TestCase
125
125
  non_blank_file!('other')
126
126
  end
127
127
  should "fail" do
128
- assertion_fails { blank_file! }
128
+ check_fails { blank_file! }
129
129
  end
130
130
  end
131
131
  context "when modifications don't happen" do
132
132
  should "fail when modifications don't happen" do
133
- assertion_fails
133
+ check_fails
134
134
  end
135
135
  end
136
136
  end
@@ -1,16 +1,16 @@
1
1
  require 'helper'
2
2
 
3
- class TestRestartedAssertion < Test::Unit::TestCase
3
+ class TestRestartedCheck < Test::Unit::TestCase
4
4
 
5
- def set_assertion(options = {})
6
- @assertion = Spex::RestartedAssertion.new('testproc', options)
5
+ def set_check(options = {})
6
+ @check = Spex::RestartedCheck.new('testproc', options)
7
7
  end
8
8
 
9
- context "Restarted Assertion" do
9
+ context "Restarted Check" do
10
10
  context "instances" do
11
11
  context "set to true" do
12
12
  setup do
13
- set_assertion(true)
13
+ set_check(true)
14
14
  end
15
15
  context "process running before execution" do
16
16
  setup do
@@ -19,30 +19,30 @@ class TestRestartedAssertion < Test::Unit::TestCase
19
19
  context "and process running after execution" do
20
20
  context "with the same pid" do
21
21
  should 'fail' do
22
- assertion_fails
22
+ check_fails
23
23
  end
24
24
  end
25
25
  context "with a different pid" do
26
26
  should 'pass' do
27
- assertion_passes { start_process!('101') }
27
+ check_passes { start_process!('101') }
28
28
  end
29
29
  end
30
30
  end
31
31
  context "but process not running after execution" do
32
32
  should "fail" do
33
- assertion_fails
33
+ check_fails
34
34
  end
35
35
  end
36
36
  end
37
37
  context "process not running before execution" do
38
38
  should "fail" do
39
- assertion_fails_before
39
+ check_fails_before
40
40
  end
41
41
  end
42
42
  end
43
43
  context "set to false" do
44
44
  setup do
45
- set_assertion(false)
45
+ set_check(false)
46
46
  end
47
47
  context "process running before execution" do
48
48
  setup do
@@ -51,24 +51,24 @@ class TestRestartedAssertion < Test::Unit::TestCase
51
51
  context "and process running after execution" do
52
52
  context "with the same pid" do
53
53
  should 'pass' do
54
- assertion_passes
54
+ check_passes
55
55
  end
56
56
  end
57
57
  context "with a different pid" do
58
58
  should 'fail' do
59
- assertion_fails { start_process!('101') }
59
+ check_fails { start_process!('101') }
60
60
  end
61
61
  end
62
62
  end
63
63
  context "but process not running after execution" do
64
64
  should "fail" do
65
- assertion_fails { stop_process! }
65
+ check_fails { stop_process! }
66
66
  end
67
67
  end
68
68
  end
69
69
  context "process not running before execution" do
70
70
  should "fail" do
71
- assertion_fails_before
71
+ check_fails_before
72
72
  end
73
73
  end
74
74
  end
@@ -28,25 +28,25 @@ class TestScript < Test::Unit::TestCase
28
28
  end
29
29
  end
30
30
 
31
- context "a scenario and execution definition with an assertion" do
31
+ context "a scenario and execution definition with an check" do
32
32
  setup do
33
33
  script do
34
34
  scenario("name") do
35
35
  executing('foo') do
36
- assert '/tmp/foo', :created => true
36
+ check '/tmp/foo', :created => true
37
37
  end
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
- should "create an assertion instance" do
42
+ should "create an check instance" do
43
43
  execution = @script.scenarios.first.executions.first
44
- assert_equal 1, execution.assertions.size
45
- assertion = execution.assertions.first
46
- assert_kind_of Spex::Assertion, assertion
47
- assert_equal '/tmp/foo', assertion.target
48
- assert assertion.active?
49
- assert_equal({}, assertion.options)
44
+ assert_equal 1, execution.checks.size
45
+ check = execution.checks.first
46
+ assert_kind_of Spex::Check, check
47
+ assert_equal '/tmp/foo', check.target
48
+ assert check.active?
49
+ assert_equal({}, check.options)
50
50
  end
51
51
  end
52
52
 
@@ -1,59 +1,59 @@
1
1
  require 'helper'
2
2
 
3
- class TestStartedAssertion < Test::Unit::TestCase
3
+ class TestStartedCheck < Test::Unit::TestCase
4
4
 
5
- def set_assertion(options = {})
6
- @assertion = Spex::StartedAssertion.new('testproc', options)
5
+ def set_check(options = {})
6
+ @check = Spex::StartedCheck.new('testproc', options)
7
7
  end
8
8
 
9
- context "Started Assertion" do
9
+ context "Started Check" do
10
10
  context "instances" do
11
11
  context "set to true" do
12
12
  setup do
13
- set_assertion(true)
13
+ set_check(true)
14
14
  end
15
15
  context "process running before execution" do
16
16
  setup do
17
17
  start_process!
18
18
  end
19
19
  should "fail" do
20
- assertion_fails_before
20
+ check_fails_before
21
21
  end
22
22
  end
23
23
  context "process not running before execution" do
24
24
  context "process running after execution" do
25
25
  should "pass" do
26
- assertion_passes { start_process! }
26
+ check_passes { start_process! }
27
27
  end
28
28
  end
29
29
  context "process not running after execution" do
30
30
  should 'fail' do
31
- assertion_fails
31
+ check_fails
32
32
  end
33
33
  end
34
34
  end
35
35
  end
36
36
  context "set to false" do
37
37
  setup do
38
- set_assertion(false)
38
+ set_check(false)
39
39
  end
40
40
  context "process running before execution" do
41
41
  setup do
42
42
  start_process!
43
43
  end
44
44
  should "fail" do
45
- assertion_fails_before
45
+ check_fails_before
46
46
  end
47
47
  end
48
48
  context "process not running before execution" do
49
49
  context "but process running after execution" do
50
50
  should "fail" do
51
- assertion_fails { start_process! }
51
+ check_fails { start_process! }
52
52
  end
53
53
  end
54
54
  context "but process not running after execution" do
55
55
  should 'pass' do
56
- assertion_passes
56
+ check_passes
57
57
  end
58
58
  end
59
59
  end
@@ -1,16 +1,16 @@
1
1
  require 'helper'
2
2
 
3
- class TestStoppedAssertion < Test::Unit::TestCase
3
+ class TestStoppedCheck < Test::Unit::TestCase
4
4
 
5
- def set_assertion(options = {})
6
- @assertion = Spex::StoppedAssertion.new('testproc', options)
5
+ def set_check(options = {})
6
+ @check = Spex::StoppedCheck.new('testproc', options)
7
7
  end
8
8
 
9
- context "Stopped Assertion" do
9
+ context "Stopped Check" do
10
10
  context "instances" do
11
11
  context "set to true" do
12
12
  setup do
13
- set_assertion(true)
13
+ set_check(true)
14
14
  end
15
15
  context "process running before execution" do
16
16
  setup do
@@ -18,24 +18,24 @@ class TestStoppedAssertion < Test::Unit::TestCase
18
18
  end
19
19
  context "and process running after execution" do
20
20
  should 'fail' do
21
- assertion_fails
21
+ check_fails
22
22
  end
23
23
  end
24
24
  context "but process not running after execution" do
25
25
  should "pass" do
26
- assertion_passes { stop_process! }
26
+ check_passes { stop_process! }
27
27
  end
28
28
  end
29
29
  end
30
30
  context "process not running before execution" do
31
31
  should "fail" do
32
- assertion_fails_before
32
+ check_fails_before
33
33
  end
34
34
  end
35
35
  end
36
36
  context "set to false" do
37
37
  setup do
38
- set_assertion(false)
38
+ set_check(false)
39
39
  end
40
40
  context "process running before execution" do
41
41
  setup do
@@ -43,18 +43,18 @@ class TestStoppedAssertion < Test::Unit::TestCase
43
43
  end
44
44
  context "and process running after execution" do
45
45
  should 'pass' do
46
- assertion_passes
46
+ check_passes
47
47
  end
48
48
  end
49
49
  context "but process not running after execution" do
50
50
  should "fail" do
51
- assertion_fails { stop_process! }
51
+ check_fails { stop_process! }
52
52
  end
53
53
  end
54
54
  end
55
55
  context "process not running before execution" do
56
56
  should "fail" do
57
- assertion_fails_before
57
+ check_fails_before
58
58
  end
59
59
  end
60
60
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
7
+ - 7
8
8
  - 0
9
- version: 0.6.0
9
+ version: 0.7.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bruce Williams
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-15 00:00:00 -07:00
17
+ date: 2010-04-22 00:00:00 -07:00
18
18
  default_executable: spex
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -78,30 +78,30 @@ files:
78
78
  - examples/touch.rb
79
79
  - examples/writing.rb
80
80
  - lib/spex.rb
81
- - lib/spex/assertion.rb
82
- - lib/spex/assertions/changed_group_assertion.rb
83
- - lib/spex/assertions/changed_mode_assertion.rb
84
- - lib/spex/assertions/changed_owner_assertion.rb
85
- - lib/spex/assertions/created_assertion.rb
86
- - lib/spex/assertions/file_assertion.rb
87
- - lib/spex/assertions/modified_assertion.rb
88
- - lib/spex/assertions/process_assertion.rb
89
- - lib/spex/assertions/removed_assertion.rb
90
- - lib/spex/assertions/restarted_assertion.rb
91
- - lib/spex/assertions/started_assertion.rb
92
- - lib/spex/assertions/stopped_assertion.rb
81
+ - lib/spex/check.rb
82
+ - lib/spex/checks/changed_group_check.rb
83
+ - lib/spex/checks/changed_mode_check.rb
84
+ - lib/spex/checks/changed_owner_check.rb
85
+ - lib/spex/checks/created_check.rb
86
+ - lib/spex/checks/file_check.rb
87
+ - lib/spex/checks/modified_check.rb
88
+ - lib/spex/checks/process_check.rb
89
+ - lib/spex/checks/removed_check.rb
90
+ - lib/spex/checks/restarted_check.rb
91
+ - lib/spex/checks/started_check.rb
92
+ - lib/spex/checks/stopped_check.rb
93
93
  - lib/spex/cli.rb
94
94
  - lib/spex/execution.rb
95
95
  - lib/spex/runner.rb
96
96
  - lib/spex/scenario.rb
97
97
  - lib/spex/script.rb
98
98
  - test/helper.rb
99
- - test/test_assertion.rb
100
- - test/test_modified_assertion.rb
101
- - test/test_restarted_assertion.rb
99
+ - test/test_check.rb
100
+ - test/test_modified_check.rb
101
+ - test/test_restarted_check.rb
102
102
  - test/test_script.rb
103
- - test/test_started_assertion.rb
104
- - test/test_stopped_assertion.rb
103
+ - test/test_started_check.rb
104
+ - test/test_stopped_check.rb
105
105
  has_rdoc: true
106
106
  homepage: http://github.com/bruce/spex
107
107
  licenses: []
@@ -134,12 +134,12 @@ specification_version: 3
134
134
  summary: A test harness for executables
135
135
  test_files:
136
136
  - test/helper.rb
137
- - test/test_assertion.rb
138
- - test/test_modified_assertion.rb
139
- - test/test_restarted_assertion.rb
137
+ - test/test_check.rb
138
+ - test/test_modified_check.rb
139
+ - test/test_restarted_check.rb
140
140
  - test/test_script.rb
141
- - test/test_started_assertion.rb
142
- - test/test_stopped_assertion.rb
141
+ - test/test_started_check.rb
142
+ - test/test_stopped_check.rb
143
143
  - examples/chgrp.rb
144
144
  - examples/chmod.rb
145
145
  - examples/chown.rb