Browse files

Updated MSpec source to 5aff4a48.

  • Loading branch information...
1 parent 1d6d799 commit 29d025611f4ed222cd68e42f1de0a4c8fba9b037 @brixen brixen committed Jan 9, 2012
Showing with 446 additions and 503 deletions.
  1. +4 −0 mspec/Gemfile
  2. +36 −0 mspec/Gemfile.lock
  3. +39 −159 mspec/README
  4. +5 −51 mspec/Rakefile
  5. +22 −5 mspec/lib/mspec/helpers/ruby_exe.rb
  6. +2 −3 mspec/lib/mspec/matchers/be_computed_by.rb
  7. +33 −28 mspec/mspec.gemspec
  8. +2 −2 mspec/spec/commands/mkspec_spec.rb
  9. +1 −1 mspec/spec/commands/mspec_ci_spec.rb
  10. +1 −1 mspec/spec/commands/mspec_run_spec.rb
  11. +3 −3 mspec/spec/commands/mspec_spec.rb
  12. +28 −22 mspec/spec/commands/mspec_tag_spec.rb
  13. +1 −1 mspec/spec/expectations/expectations_spec.rb
  14. +2 −2 mspec/spec/expectations/should_spec.rb
  15. +2 −2 mspec/spec/guards/background_spec.rb
  16. +2 −3 mspec/spec/guards/bug_spec.rb
  17. +2 −2 mspec/spec/guards/compliance_spec.rb
  18. +2 −2 mspec/spec/guards/conflict_spec.rb
  19. +2 −2 mspec/spec/guards/endian_spec.rb
  20. +2 −2 mspec/spec/guards/extensions_spec.rb
  21. +2 −2 mspec/spec/guards/feature_spec.rb
  22. +4 −5 mspec/spec/guards/guard_spec.rb
  23. +2 −2 mspec/spec/guards/noncompliance_spec.rb
  24. +2 −2 mspec/spec/guards/platform_spec.rb
  25. +2 −2 mspec/spec/guards/quarantine_spec.rb
  26. +2 −2 mspec/spec/guards/runner_spec.rb
  27. +2 −2 mspec/spec/guards/specified_spec.rb
  28. +2 −2 mspec/spec/guards/superuser_spec.rb
  29. +2 −2 mspec/spec/guards/support_spec.rb
  30. +2 −2 mspec/spec/guards/tty_spec.rb
  31. +2 −2 mspec/spec/guards/user_spec.rb
  32. +2 −2 mspec/spec/guards/version_spec.rb
  33. +3 −2 mspec/spec/helpers/argv_spec.rb
  34. +3 −2 mspec/spec/helpers/const_lookup_spec.rb
  35. +3 −2 mspec/spec/helpers/datetime_spec.rb
  36. +3 −2 mspec/spec/helpers/ducktype_spec.rb
  37. +3 −2 mspec/spec/helpers/encode_spec.rb
  38. +2 −2 mspec/spec/helpers/enumerator_class_spec.rb
  39. +3 −3 mspec/spec/helpers/environment_spec.rb
  40. +3 −2 mspec/spec/helpers/fixture_spec.rb
  41. +4 −3 mspec/spec/helpers/flunk_spec.rb
  42. +3 −2 mspec/spec/helpers/fmode_spec.rb
  43. +2 −3 mspec/spec/helpers/fs_spec.rb
  44. +3 −2 mspec/spec/helpers/hash_spec.rb
  45. +3 −5 mspec/spec/helpers/io_spec.rb
  46. +3 −2 mspec/spec/helpers/language_version_spec.rb
  47. +3 −2 mspec/spec/helpers/mock_to_path_spec.rb
  48. +3 −2 mspec/spec/helpers/numeric_spec.rb
  49. +36 −2 mspec/spec/helpers/ruby_exe_spec.rb
  50. +3 −1 mspec/spec/helpers/scratch_spec.rb
  51. +3 −2 mspec/spec/helpers/stasy_spec.rb
  52. +3 −2 mspec/spec/helpers/tmp_spec.rb
  53. +2 −2 mspec/spec/matchers/base_spec.rb
  54. +2 −2 mspec/spec/matchers/be_an_instance_of_spec.rb
  55. +2 −2 mspec/spec/matchers/be_ancestor_of_spec.rb
  56. +2 −2 mspec/spec/matchers/be_close_spec.rb
  57. +2 −2 mspec/spec/matchers/be_computed_by_function_spec.rb
  58. +3 −3 mspec/spec/matchers/be_computed_by_spec.rb
  59. +2 −2 mspec/spec/matchers/be_empty_spec.rb
  60. +3 −3 mspec/spec/matchers/be_false_spec.rb
  61. +2 −2 mspec/spec/matchers/be_kind_of_spec.rb
  62. +4 −2 mspec/spec/matchers/be_nan_spec.rb
  63. +3 −3 mspec/spec/matchers/be_nil_spec.rb
  64. +3 −3 mspec/spec/matchers/be_true_spec.rb
  65. +2 −2 mspec/spec/matchers/be_valid_dns_name_spec.rb
  66. +2 −2 mspec/spec/matchers/complain_spec.rb
  67. +2 −2 mspec/spec/matchers/eql_spec.rb
  68. +2 −2 mspec/spec/matchers/equal_element_spec.rb
  69. +2 −2 mspec/spec/matchers/equal_spec.rb
  70. +2 −2 mspec/spec/matchers/equal_utf16_spec.rb
  71. +3 −3 mspec/spec/matchers/have_class_variable_spec.rb
  72. +2 −2 mspec/spec/matchers/have_constant_spec.rb
  73. +4 −4 mspec/spec/matchers/have_data_spec.rb
  74. +2 −2 mspec/spec/matchers/have_instance_method_spec.rb
  75. +3 −3 mspec/spec/matchers/have_instance_variable_spec.rb
  76. +2 −2 mspec/spec/matchers/have_method_spec.rb
  77. +2 −2 mspec/spec/matchers/have_private_instance_method_spec.rb
  78. +2 −2 mspec/spec/matchers/have_private_method_spec.rb
  79. +2 −2 mspec/spec/matchers/have_protected_instance_method_spec.rb
  80. +2 −2 mspec/spec/matchers/have_public_instance_method_spec.rb
  81. +2 −2 mspec/spec/matchers/have_singleton_method_spec.rb
  82. +2 −2 mspec/spec/matchers/include_spec.rb
  83. +4 −2 mspec/spec/matchers/infinity_spec.rb
  84. +3 −3 mspec/spec/matchers/match_yaml_spec.rb
  85. +2 −2 mspec/spec/matchers/output_spec.rb
  86. +2 −2 mspec/spec/matchers/output_to_fd_spec.rb
  87. +2 −2 mspec/spec/matchers/raise_error_spec.rb
  88. +2 −2 mspec/spec/matchers/respond_to_spec.rb
  89. +2 −2 mspec/spec/matchers/signed_zero_spec.rb
  90. +2 −2 mspec/spec/matchers/stringsymboladapter_spec.rb
  91. +12 −12 mspec/spec/mocks/mock_spec.rb
  92. +1 −1 mspec/spec/mocks/proxy_spec.rb
  93. +1 −1 mspec/spec/runner/actions/debug_spec.rb
  94. +1 −1 mspec/spec/runner/actions/gdb_spec.rb
  95. +1 −1 mspec/spec/runner/actions/tag_spec.rb
  96. +1 −1 mspec/spec/runner/actions/taglist_spec.rb
  97. +4 −4 mspec/spec/runner/context_spec.rb
  98. +1 −1 mspec/spec/runner/example_spec.rb
  99. +1 −1 mspec/spec/runner/exception_spec.rb
  100. +2 −2 mspec/spec/runner/filters/tag_spec.rb
  101. +1 −1 mspec/spec/runner/formatters/describe_spec.rb
  102. +2 −2 mspec/spec/runner/formatters/dotted_spec.rb
  103. +2 −2 mspec/spec/runner/formatters/html_spec.rb
  104. +3 −3 mspec/spec/runner/formatters/junit_spec.rb
  105. +2 −2 mspec/spec/runner/formatters/unit_spec.rb
  106. +3 −3 mspec/spec/runner/formatters/yaml_spec.rb
  107. +1 −1 mspec/spec/runner/mspec_spec.rb
  108. +1 −1 mspec/spec/runner/shared_spec.rb
  109. +1 −1 mspec/spec/runner/tag_spec.rb
  110. +0 −7 mspec/spec/spec_helper.rb
  111. +1 −1 mspec/spec/utils/name_map_spec.rb
  112. +1 −1 mspec/spec/utils/options_spec.rb
  113. +4 −4 mspec/spec/utils/script_spec.rb
  114. +1 −1 mspec/spec/utils/version_spec.rb
View
4 mspec/Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in mspec.gemspec
+gemspec
View
36 mspec/Gemfile.lock
@@ -0,0 +1,36 @@
+PATH
+ remote: .
+ specs:
+ mspec (1.5.17)
+
+GEM
+ remote: https://rubygems.org/
+ specs:
+ columnize (0.3.4)
+ diff-lcs (1.1.3)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ rake (0.9.2.2)
+ rbx-require-relative (0.0.5)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ mspec!
+ rake (~> 0.9)
+ rspec (~> 2.8)
+ ruby-debug (~> 0.10)
View
198 mspec/README
@@ -1,197 +1,77 @@
-= Overview
+1. Overview
MSpec is a specialized framework that is syntax-compatible with RSpec for
-basic things like +describe+, +it+ blocks and +before+, +after+ actions. MSpec
+basic things like 'describe', 'it' blocks and 'before', 'after' actions. MSpec
contains additional features that assist in writing the RubySpecs used by
multiple Ruby implementations.
MSpec attempts to use the simplest Ruby language features so that beginning
-Ruby implementations can run the Ruby specs. So, for example, there is not
-great concern given to constant clashes. Namespacing (or module scoping) is
-not used because implementing this correctly took a significant amount of work
-in Rubinius and it is likely that other implementations would also face
-difficulties.
+Ruby implementations can run the Ruby specs.
MSpec is not intended as a replacement for RSpec. MSpec attempts to provide a
subset of RSpec's features in some cases and a superset in others. It does not
-provide all the matchers, for instance. However, MSpec provides several
-extensions to facilitate writing the Ruby specs in a manner compatible with
-multiple Ruby implementations.
-
-First, MSpec offers a set of guards to control execution of the specs. These
-guards not only enable or disable execution but also annotate the specs with
-additional information about why they are run or not run. Second, MSpec
-provides a different shared spec implementation specifically designed to ease
-writing specs for the numerous aliased methods in Ruby. The MSpec shared spec
-implementation should not conflict with RSpec's own shared behavior facility.
-Third, MSpec provides various helper methods to simplify some specs, for
-example, creating temporary file names. Finally, MSpec has several specialized
-runner scripts that includes a configuration facility with a default project
-file and user-specific overrides.
-
-Caveats:
-
-* Use RSpec to run the MSpec specs. There are no plans currently to make
- the MSpec specs runnable by MSpec.
-* Don't mock the #hash method as MSpec's Mock implementation uses Hash
- internally. This can be replaced if necessary, but at this point there is no
- compelling need to do so.
-
-
-== Architecture
-
-
-== Matchers
-
-Matchers are additional aids for the verification process. The default
-is of course to #should or #should_not using the #== operator and its
-friends but the matchers add a new set of 'operators' to help in the
-task. They reside in `mspec/matchers/`. There are two broad categories,
-those that apply to an individual object and those that apply to a
-block:
-
-=== Object
-
-- `base` implements the standard #==, #< #<= #>= #> and #=~ with their
- normal semantics for the objects that you invoke them on.
-
-- `be_ancestor_of` is equivalent to checking `obj.ancestors.include?`.
-
-- `be_close` is a "delta" for floating-point math. Due to the very
- nature of it, floating-point comparisons should never be treated as
- exact. By default the tolerance is 0.00003 but it can be altered if
- so desired. So `0.23154.should be_close(0.23157)` would succeed
- (which is usually close enough for floating point unless you are
- doing some scientific computing.)
-
-- `be_empty` checks `obj.empty?`
-
-- `be_kind_of` is equivalent to `obj.kind_of?`
-
-- `include` is `obj.include?`
-
-=== Block
-
-All of these should be applied to a block created with `lambda` or `proc`:
-
-- `complain` is probably clearer stated as `lambda {...}.should complain`;
- it checks that the block issues a warning. The message can be checked
- against either a String or a Regexp.
-
-- `output` checks that the block produces the given output (stdout as well
- as stderr, in that order) matched either to a String or a Regexp. This one
- uses overrides so if that is a problem (for e.g. speccing Readline or
- something) see below.
-
-- `output_to_fd` is a lower-level version and actually verifies that output
- to a certain file descriptor is correct whether from an in-/output stream
- or an actual file. Also can check with either a String or a Regexp.
+provide all the matchers, for instance.
-- `raise_error` verifies the exception type (if any) raised by the block it
- is associated with. The exception class can be given for finer-grained
- control (inheritance works normally so Exception would catch everything.)
+However, MSpec provides several extensions to facilitate writing the Ruby
+specs in a manner compatible with multiple Ruby implementations.
-== Nested 'describe' blocks
+ 1. MSpec offers a set of guards to control execution of the specs. These
+ guards not only enable or disable execution but also annotate the specs
+ with additional information about why they are run or not run.
-MSpec supports nesting one 'describe' block inside another. The examples in
-the nested block are evaluated with all the before/after blocks of all the
-containing 'describe' blocks. The following example illustrates this:
+ 2. MSpec provides a different shared spec implementation specifically
+ designed to ease writing specs for the numerous aliased methods in Ruby.
+ The MSpec shared spec implementation should not conflict with RSpec's own
+ shared behavior facility.
-describe "Some#method" do
- before :each do
- @obj = 1
- end
+ 3. MSpec provides various helper methods to simplify some specs, for
+ example, creating temporary file names.
- describe "when passed String" do
- before :each do
- @meth = :to_s
- end
+ 4. MSpec has several specialized runner scripts that includes a
+ configuration facility with a default project file and user-specific
+ overrides.
- it "returns false" do
- # when this example is evaluated, @obj = 1 and @meth = :to_s
- end
- end
-end
-The output when using the SpecdocFormatter (selected with -fs to the runners)
-will be as follows:
+2. Bundler
-Some#method when passed String
-- returns false
+A Gemfile and Gemfile.lock is provide. Use Bundler to install gem
+dependencies. To install Bundler, run the following:
+ $ gem install bundler
-== Shared 'describe' blocks
+To install the gem dependencies with Bundler, run the following:
-MSpec supports RSpec-style shared 'describe' blocks. MSpec also provides a
-convenience method to assist in writing specs for the numerous aliased methods
-that Ruby provides. The following example illustrates shared blocks:
+ $ RUBYLIB=lib ruby -S bundle install
-describe :someclass_some_method, :shared => true do
- it "does something" do
- end
-end
-describe "SomeClass#some_method" do
- it_should_behave_like "someclass_some_method"
-end
+3. Running Specs
-The first argument to 'describe' for a shared block is an object that
-duck-types as a String. The representation of the object must be unique. This
-example uses a symbol. This was the convention for the previous facility that
-MSpec provided for aliased method (#it_behaves_like). However, this convention
-is not set in stone (but the uniqueness requirement is). Note that the
-argument to the #it_should_behave_like is a String because at this time RSpec
-will not find the shared block by the symbol.
+Use RSpec to run the MSpec specs. There are no plans currently to make the
+MSpec specs runnable by MSpec.
-MSpec continues to support the #it_behaves_like convenience method for
-specifying aliased methods. The syntax is as follows:
+After installing the gem dependencies, the specs can be run as follows:
-it_behaves_like :symbol_matching_shared_describe, :method [, :object]
+ $ ruby -S rspec
-describe :someclass_some_method, :shared => true do
- it "returns true" do
- obj.send(@method).should be_true
- end
+Or
- it "returns something else" do
- @object.send(@method).should be_something_else
- end
-end
+ $ ruby -S rake
-# example #1
-describe "SomeClass#some_method" do
- it_behaves_like :someclass_some_method, :other_method
-end
+To run an individual spec file, use the following example:
-# example #2
-describe "SomeOtherClass#some_method" do
- it_behaves_like :someclass_some_method, :some_method, OtherClass
-end
+ $ ruby -S rspec spec/helpers/ruby_exe_spec.rb
-The first form above (#1) is used for typical aliases. That is, methods with
-different names on the same class that behave identically. The
-#it_behaves_like helper creates a before(:all) block that sets @method to
-:other_method. The form of the first example block in the shared block
-illustrates the typical form of a spec for an aliased method.
-The second form above (#2) is used for methods on different classes that are
-essentially aliases, even though Ruby does not provide a syntax for specifying
-such methods as aliases. Examples are the methods on File, FileTest, and
-File::Stat. In this case, the #it_behaves_like helper sets both @method and
-@object in the before(:all) block (@method = :some_method, @object =
-OtherClass in this example).
+4. Documentation
-For shared specs that fall outside of either of these two narrow categories,
-use nested or shared 'describe' blocks as appropriate and use the
-#it_should_behave_like method directly.
+See http://rubyspec.org
-== Guards
-Since Ruby is not completely isolated from its platform or execution environment, the spec files may contain guards: conditions placed around a spec or a set of specs to enable or disable them.
+5. Source Code
-You can find an overview of the current guards and their usage in: http://rubyspec.org/wiki/mspec/Guards .
+See https://github.com/rubyspec/mspec
-== Helpers
+6. License
-== Runners
+See the LICENSE in the source code.
View
56 mspec/Rakefile
@@ -1,53 +1,7 @@
-require 'rubygems'
+require 'bundler/gem_tasks'
+require 'bundler/setup'
+require 'rspec/core/rake_task'
-begin
- require 'spec/rake/spectask'
+RSpec::Core::RakeTask.new(:spec)
- Spec::Rake::SpecTask.new
- task :default => :spec
-rescue LoadError
- task :default do
- STDERR.puts "Please install RSpec 1.3.x to run MSpec specs"
- end
-end
-
-require 'rake/gempackagetask'
-
-$:.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
-require 'mspec/version'
-
-spec = Gem::Specification.new do |s|
- s.name = %q{mspec}
- s.version = MSpec::VERSION.to_s
-
- s.specification_version = 2 if s.respond_to? :specification_version=
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Brian Ford"]
- s.date = %q{2010-03-13}
- s.email = %q{bford@engineyard.com}
- s.has_rdoc = true
- s.extra_rdoc_files = %w[ README LICENSE ]
- s.executables = ["mkspec", "mspec", "mspec-ci", "mspec-run", "mspec-tag"]
- s.files = FileList[ '{bin,lib,spec}/**/*.{yaml,txt,rb}', 'Rakefile', *s.extra_rdoc_files ]
- s.homepage = %q{http://rubyspec.org}
- s.rubyforge_project = 'http://rubyforge.org/projects/mspec'
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = <<EOS
-MSpec is a specialized framework that is syntax-compatible
-with RSpec for basic things like describe, it blocks and
-before, after actions.
-
-MSpec contains additional features that assist in writing
-the RubySpecs used by multiple Ruby implementations. Also,
-MSpec attempts to use the simplest Ruby language features
-so that beginning Ruby implementations can run it.
-EOS
-
- s.rdoc_options << '--title' << 'MSpec Gem' <<
- '--main' << 'README' <<
- '--line-numbers'
-end
-
-Rake::GemPackageTask.new(spec){ |pkg| pkg.gem_spec = spec }
+task :default => :spec
View
27 mspec/lib/mspec/helpers/ruby_exe.rb
@@ -22,15 +22,19 @@
#
# `#{RUBY_EXE} -e #{'puts "hello, world."'}`
#
-# The ruby_exe helper also accepts an options hash with two
-# keys: :options and :args. For example:
+# The ruby_exe helper also accepts an options hash with three
+# keys: :options, :args and :env. For example:
#
-# ruby_exe('file.rb', :options => "-w", :args => "> file.txt")
+# ruby_exe('file.rb', :options => "-w",
+# :args => "> file.txt",
+# :env => { :FOO => "bar" })
#
# will be executed as
#
# `#{RUBY_EXE} -w #{'file.rb'} > file.txt`
#
+# with access to ENV["FOO"] with value "bar".
+#
# If +nil+ is passed for the first argument, the command line
# will be built only from the options hash.
#
@@ -112,6 +116,7 @@ def resolve_ruby_exe
def ruby_exe(code, opts = {})
body = code
+ env = opts[:env] || {}
working_dir = opts[:dir] || "."
Dir.chdir(working_dir) do
if code and not File.exists?(code)
@@ -122,8 +127,20 @@ def ruby_exe(code, opts = {})
end
body = "-e #{code}"
end
- cmd = [RUBY_EXE, ENV['RUBY_FLAGS'], opts[:options], body, opts[:args]]
- `#{cmd.compact.join(' ')}`
+
+ saved_env = {}
+ env.each do |key, value|
+ key = key.to_s
+ saved_env[key] = ENV[key] if ENV.key? key
+ ENV[key] = value
+ end
+
+ begin
+ cmd = [RUBY_EXE, ENV['RUBY_FLAGS'], opts[:options], body, opts[:args]]
+ `#{cmd.compact.join(' ')}`
+ ensure
+ saved_env.each { |key, value| ENV[key] = value }
+ end
end
end
View
5 mspec/lib/mspec/matchers/be_computed_by.rb
@@ -10,8 +10,7 @@ def matches?(array)
@value = line.pop
@arguments = line
@arguments += @args
- @actual = @receiver.send(@method, *@arguments)
- return false unless @actual == @value
+ return false unless @receiver.send(@method, *@arguments) == @value
end
return true
@@ -26,7 +25,7 @@ def method_call
end
def failure_message
- ["Expected #{@value.inspect}", "to be computed by #{method_call} (computed #{@actual.inspect} instead)"]
+ ["Expected #{@value.inspect}", "to be computed by #{method_call}"]
end
end
View
61 mspec/mspec.gemspec
@@ -1,33 +1,38 @@
-Gem::Specification.new do |s|
- s.name = %q{mspec}
- s.version = "1.5.12"
+# -*- encoding: utf-8 -*-
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'mspec/version'
- s.specification_version = 2 if s.respond_to? :specification_version=
+Gem::Specification.new do |gem|
+ gem.name = "mspec"
+ gem.version = MSpec::VERSION.to_s
+ gem.authors = ["Brian Ford"]
+ gem.email = ["bford@engineyard.com"]
+ gem.homepage = "http://rubyspec.org"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Brian Ford"]
- s.date = %q{2009-6-8}
- s.email = %q{bford@engineyard.com}
- s.has_rdoc = true
- s.extra_rdoc_files = %w[ README LICENSE ]
- s.executables = ["mkspec", "mspec", "mspec-ci", "mspec-run", "mspec-tag"]
- s.files = FileList[ '{bin,lib,spec}/**/*.{yaml,txt,rb}', 'Rakefile', *s.extra_rdoc_files ]
- s.homepage = %q{http://rubyspec.org}
- s.rubyforge_project = 'http://rubyforge.org/projects/mspec'
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.1.1}
- s.summary = <<EOS
-MSpec is a specialized framework that is syntax-compatible
-with RSpec for basic things like describe, it blocks and
-before, after actions.
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) unless File.extname(f) == ".bat" }.compact
+ gem.files = `git ls-files`.split("\n")
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.require_paths = ["lib"]
+ gem.summary = <<-EOS
+ MSpec is a specialized framework that is syntax-compatible
+ with RSpec for basic things like describe, it blocks and
+ before, after actions.
-MSpec contains additional features that assist in writing
-the RubySpecs used by multiple Ruby implementations. Also,
-MSpec attempts to use the simplest Ruby language features
-so that beginning Ruby implementations can run it.
-EOS
+ MSpec contains additional features that assist in writing
+ the RubySpecs used by multiple Ruby implementations. Also,
+ MSpec attempts to use the simplest Ruby language features
+ so that beginning Ruby implementations can run it.
+ EOS
+ gem.has_rdoc = true
+ gem.extra_rdoc_files = %w[ README LICENSE ]
+ gem.rubygems_version = %q{1.3.5}
+ gem.rubyforge_project = 'http://rubyforge.org/projects/mspec'
- s.rdoc_options << '--title' << 'MSpec Gem' <<
- '--main' << 'README' <<
- '--line-numbers'
+ gem.rdoc_options << '--title' << 'MSpec Gem' <<
+ '--main' << 'README' <<
+ '--line-numbers'
+
+ gem.add_development_dependency "rake", "~> 0.9"
+ gem.add_development_dependency "rspec", "~> 2.8"
+ gem.add_development_dependency "ruby-debug", "~> 0.10"
end
View
4 mspec/spec/commands/mkspec_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/commands/mkspec'
@@ -336,7 +336,7 @@
describe MkSpec, ".main" do
before :each do
- @script = mock("MkSpec", :null_object => true)
+ @script = mock("MkSpec").as_null_object
MkSpec.stub!(:new).and_return(@script)
end
View
2 mspec/spec/commands/mspec_ci_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/runner/mspec'
require 'mspec/runner/filters/tag'
require 'mspec/commands/mspec-ci'
View
2 mspec/spec/commands/mspec_run_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/runner/mspec'
require 'mspec/commands/mspec-run'
View
6 mspec/spec/commands/mspec_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'yaml'
require 'mspec/commands/mspec'
@@ -108,9 +108,9 @@
before :each do
@stdout, $stdout = $stdout, IOStub.new
- @timer = mock("timer", :null_object => true)
+ @timer = mock("timer").as_null_object
@timer.stub!(:format).and_return("Finished in 42 seconds")
- @file = mock("file", :null_object => true)
+ @file = mock("file").as_null_object
File.stub!(:delete)
YAML.stub!(:load)
View
50 mspec/spec/commands/mspec_tag_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/runner/mspec'
require 'mspec/commands/mspec-tag'
require 'mspec/runner/actions/tag'
@@ -264,7 +264,7 @@
before :each do
MSpec.stub!(:process)
- options = mock("MSpecOptions", :null_object => true)
+ options = mock("MSpecOptions").as_null_object
options.stub!(:parse).and_return(["one", "two"])
MSpecOptions.stub!(:new).and_return(options)
@@ -318,36 +318,42 @@
@tl.stub!(:register)
end
- it "creates a TagAction if config[:tagger] is :add" do
- TagAction.should_receive(:new).with(:add, :fail, "fake", nil, [], []).and_return(@t)
- @script.register
+ it "raises an ArgumentError if no recognized action is given" do
+ @config[:tagger] = :totally_whack
+ lambda { @script.register }.should raise_error(ArgumentError)
end
- it "creates a TagAction if config[:tagger] is :del" do
- @config[:tagger] = :del
- @config[:outcome] = :pass
- TagAction.should_receive(:new).with(:del, :pass, "fake", nil, [], []).and_return(@t)
- @script.register
- end
+ describe "when config[:tagger] is the default (:add)" do
+ before :each do
+ @config[:formatter] = false
+ end
- it "calls #register on the TagAction instance" do
- TagAction.should_receive(:new).and_return(@t)
- @t.should_receive(:register)
- @script.register
- end
+ it "creates a TagAction" do
+ TagAction.should_receive(:new).and_return(@t)
+ @script.register
+ end
- it "raises an ArgumentError if no recognized action is given" do
- @config[:tagger] = :totally_whack
- lambda { @script.register }.should raise_error(ArgumentError)
+ it "creates a TagAction if config[:tagger] is :del" do
+ @config[:tagger] = :del
+ @config[:outcome] = :pass
+ TagAction.should_receive(:new).with(:del, :pass, "fake", nil, [], []).and_return(@t)
+ @script.register
+ end
+
+ it "calls #register on the TagAction instance" do
+ TagAction.should_receive(:new).and_return(@t)
+ @t.should_receive(:register)
+ @script.register
+ end
end
describe "when config[:tagger] is :list" do
before :each do
+ TagListAction.should_receive(:new).with(@config[:ltags]).and_return(@tl)
@config[:tagger] = :list
end
it "creates a TagListAction" do
- TagListAction.should_receive(:new).with(@config[:ltags]).and_return(@tl)
@tl.should_receive(:register)
@script.register
end
@@ -365,11 +371,11 @@
describe "when config[:tagger] is :list_all" do
before :each do
+ TagListAction.should_receive(:new).with(nil).and_return(@tl)
@config[:tagger] = :list_all
end
it "creates a TagListAction" do
- TagListAction.should_receive(:new).with(nil).and_return(@tl)
@tl.should_receive(:register)
@script.register
end
@@ -387,12 +393,12 @@
describe "when config[:tagger] is :purge" do
before :each do
+ TagPurgeAction.should_receive(:new).and_return(@tl)
MSpec.stub!(:register_mode)
@config[:tagger] = :purge
end
it "creates a TagPurgeAction" do
- TagPurgeAction.should_receive(:new).and_return(@tl)
@tl.should_receive(:register)
@script.register
end
View
2 mspec/spec/expectations/expectations_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
describe SpecExpectationNotMetError do
View
4 mspec/spec/expectations/should_spec.rb
@@ -1,7 +1,7 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'rbconfig'
-describe MSpec do
+describe "MSpec" do
before :all do
path = RbConfig::CONFIG['bindir']
exe = RbConfig::CONFIG['ruby_install_name']
View
4 mspec/spec/guards/background_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/background'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#process_is_foreground" do
before :each do
View
5 mspec/spec/guards/bug_spec.rb
@@ -1,6 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/utils/ruby_name'
-require 'mspec/guards/bug'
+require 'spec_helper'
+require 'mspec/guards'
describe BugGuard, "#match? when #implementation? is 'ruby'" do
before :all do
View
4 mspec/spec/guards/compliance_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/compliance'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#compliant_on" do
before :all do
View
4 mspec/spec/guards/conflict_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/conflict'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#conflicts_with" do
before :each do
View
4 mspec/spec/guards/endian_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/endian'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#big_endian" do
before :each do
View
4 mspec/spec/guards/extensions_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/extensions'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#extended_on" do
before :all do
View
4 mspec/spec/guards/feature_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/feature'
+require 'spec_helper'
+require 'mspec/guards'
describe FeatureGuard, ".enabled?" do
it "returns true if the feature is enabled" do
View
9 mspec/spec/guards/guard_spec.rb
@@ -1,6 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/utils/ruby_name'
-require 'mspec/guards/guard'
+require 'spec_helper'
+require 'mspec/guards'
require 'rbconfig'
describe SpecGuard, "#ruby_version_override=" do
@@ -19,15 +18,15 @@
end
describe SpecGuard, ".ruby_version" do
- before :all do
+ before :each do
@ruby_version = Object.const_get :RUBY_VERSION
@ruby_patchlevel = Object.const_get :RUBY_PATCHLEVEL
Object.const_set :RUBY_VERSION, "8.2.3"
Object.const_set :RUBY_PATCHLEVEL, 71
end
- after :all do
+ after :each do
Object.const_set :RUBY_VERSION, @ruby_version
Object.const_set :RUBY_PATCHLEVEL, @ruby_patchlevel
end
View
4 mspec/spec/guards/noncompliance_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/noncompliance'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#deviates_on" do
before :all do
View
4 mspec/spec/guards/platform_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/platform'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#platform_is" do
before :each do
View
4 mspec/spec/guards/quarantine_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/quarantine'
+require 'spec_helper'
+require 'mspec/guards'
describe QuarantineGuard, "#match?" do
it "returns false" do
View
4 mspec/spec/guards/runner_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/runner'
+require 'spec_helper'
+require 'mspec/guards'
describe RunnerGuard, "#match?" do
before :all do
View
4 mspec/spec/guards/specified_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/specified'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#unspecified" do
before :each do
View
4 mspec/spec/guards/superuser_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/superuser'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#as_superuser" do
before :each do
View
4 mspec/spec/guards/support_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/support'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#not_supported_on" do
before :all do
View
4 mspec/spec/guards/tty_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/tty'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#with_tty" do
before :each do
View
4 mspec/spec/guards/user_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/user'
+require 'spec_helper'
+require 'mspec/guards'
describe Object, "#as_user" do
before :each do
View
4 mspec/spec/guards/version_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/version'
+require 'spec_helper'
+require 'mspec/guards'
# The VersionGuard specifies a version of Ruby with a String of
# the form: v = 'major.minor.tiny.patchlevel'.
View
5 mspec/spec/helpers/argv_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/argv'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#argv" do
before :each do
View
5 mspec/spec/helpers/const_lookup_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/const_lookup'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
CONST = 2
View
5 mspec/spec/helpers/datetime_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/datetime'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#new_datetime" do
it "returns a default DateTime instance" do
View
5 mspec/spec/helpers/ducktype_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/ducktype'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#responds_to" do
it "returns true for specified symbols" do
View
5 mspec/spec/helpers/encode_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/encode'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#encode" do
it "raises an ArgumentError if the str parameter is not a String" do
View
4 mspec/spec/helpers/enumerator_class_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/enumerator_class'
+require 'spec_helper'
require 'mspec/guards'
+require 'mspec/helpers'
describe "#enumerator_class" do
View
6 mspec/spec/helpers/environment_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/guards/platform'
-require 'mspec/helpers/environment'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe "#env" do
it "returns a hash of variables" do
View
5 mspec/spec/helpers/fixture_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/fixture'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#fixture" do
before :each do
View
7 mspec/spec/helpers/flunk_spec.rb
@@ -1,12 +1,13 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/helpers/flunk'
require 'mspec/runner/mspec'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#flunk" do
before :each do
MSpec.stub!(:actions)
- MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
+ MSpec.stub!(:current).and_return(mock("spec state").as_null_object)
end
it "raises an SpecExpectationNotMetError unconditionally" do
View
5 mspec/spec/helpers/fmode_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/fmode'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#fmode" do
it "returns the argument unmodified if :encoding feature is enabled" do
View
5 mspec/spec/helpers/fs_spec.rb
@@ -1,7 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/guards'
-require 'mspec/helpers/tmp'
-require 'mspec/helpers/fs'
+require 'mspec/helpers'
describe Object, "#cp" do
before :each do
View
5 mspec/spec/helpers/hash_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/hash'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#hash_class" do
it "returns the Hash class" do
View
8 mspec/spec/helpers/io_spec.rb
@@ -1,8 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/io'
-require 'mspec/helpers/fs'
-require 'mspec/helpers/fmode'
-require 'mspec/helpers/tmp'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe IOStub do
before :each do
View
5 mspec/spec/helpers/language_version_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/language_version'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#language_version" do
before :all do
View
5 mspec/spec/helpers/mock_to_path_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/mock_to_path'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#mock_to_path" do
it "returns an object that responds to #to_path" do
View
5 mspec/spec/helpers/numeric_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/numeric'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#bignum_value" do
it "returns a value that is an instance of Bignum on any platform" do
View
38 mspec/spec/helpers/ruby_exe_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/ruby_exe'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
require 'rbconfig'
class RubyExeSpecs
@@ -175,4 +176,37 @@ class RubyExeSpecs
@script.should_receive(:`).with("ruby_spec_exe -w -Q -c > file.txt")
@script.ruby_exe nil, :options => "-c", :args => "> file.txt"
end
+
+ describe "with :env option" do
+ before :each do
+ @script.stub!(:`)
+ end
+
+ after :each do
+ ENV.delete "ABC"
+ end
+
+ it "preserves the values of existing ENV keys" do
+ ENV["ABC"] = "123"
+ ENV.should_receive(:[]).with("RUBY_FLAGS")
+ ENV.should_receive(:[]).with("ABC")
+ @script.ruby_exe nil, :env => { :ABC => "xyz" }
+ end
+
+ it "adds the :env entries to ENV" do
+ ENV.should_receive(:[]=).with("ABC", "xyz")
+ @script.ruby_exe nil, :env => { :ABC => "xyz" }
+ end
+
+ it "resets the values of existing ENV keys when an exception is raised" do
+ ENV["ABC"] = "123"
+ ENV.should_receive(:[]=).with("ABC", "xyz")
+ ENV.should_receive(:[]=).with("ABC", "123")
+
+ @script.should_receive(:`).and_raise(Exception)
+ lambda do
+ @script.ruby_exe nil, :env => { :ABC => "xyz" }
+ end.should raise_error(Exception)
+ end
+ end
end
View
4 mspec/spec/helpers/scratch_spec.rb
@@ -1,4 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe ScratchPad do
it "records an object and returns a previously recorded object" do
View
5 mspec/spec/helpers/stasy_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/stasy'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#stasy when RUBY_VERSION < 1.9" do
before :all do
View
5 mspec/spec/helpers/tmp_spec.rb
@@ -1,5 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/tmp'
+require 'spec_helper'
+require 'mspec/guards'
+require 'mspec/helpers'
describe Object, "#tmp" do
before :all do
View
4 mspec/spec/matchers/base_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/base'
+require 'mspec/matchers'
require 'time'
describe SpecPositiveOperatorMatcher, "== operator" do
View
4 mspec/spec/matchers/be_an_instance_of_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_an_instance_of'
+require 'mspec/matchers'
module BeAnInOfSpecs
class A
View
4 mspec/spec/matchers/be_ancestor_of_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_ancestor_of'
+require 'mspec/matchers'
class Parent; end
class Child < Parent; end
View
4 mspec/spec/matchers/be_close_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_close'
+require 'mspec/matchers'
# Adapted from RSpec 1.0.8
describe BeCloseMatcher do
View
4 mspec/spec/matchers/be_computed_by_function_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/matchers/be_computed_by_function'
+require 'spec_helper'
+require 'mspec/matchers'
describe BeComputedByFunctionMatcher do
it "matches when all entries in the Array compute" do
View
6 mspec/spec/matchers/be_computed_by_spec.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/matchers/be_computed_by'
+require 'spec_helper'
+require 'mspec/matchers'
describe BeComputedByMatcher do
it "matches when all entries in the Array compute" do
@@ -37,6 +37,6 @@
[91, "Z" ] ]
matcher = BeComputedByMatcher.new(:chr)
matcher.matches?(array)
- matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr (computed \"[\" instead)"]
+ matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr"]
end
end
View
4 mspec/spec/matchers/be_empty_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_empty'
+require 'mspec/matchers'
describe BeEmptyMatcher do
it "matches when actual is empty" do
View
6 mspec/spec/matchers/be_false_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_false'
+require 'mspec/matchers'
describe BeFalseMatcher do
it "matches when actual is false" do
@@ -25,4 +25,4 @@
matcher.matches?(false)
matcher.negative_failure_message.should == ["Expected false", "not to be false"]
end
-end
+end
View
4 mspec/spec/matchers/be_kind_of_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_kind_of'
+require 'mspec/matchers'
describe BeKindOfMatcher do
it "matches when actual is a kind_of? expected" do
View
6 mspec/spec/matchers/be_nan_spec.rb
@@ -1,6 +1,8 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_nan'
+require 'mspec/guards'
+require 'mspec/helpers'
+require 'mspec/matchers'
describe BeNaNMatcher do
it "matches when actual is NaN" do
View
6 mspec/spec/matchers/be_nil_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_nil'
+require 'mspec/matchers'
describe BeNilMatcher do
it "matches when actual is nil" do
@@ -24,4 +24,4 @@
matcher.matches?(nil)
matcher.negative_failure_message.should == ["Expected nil", "not to be nil"]
end
-end
+end
View
6 mspec/spec/matchers/be_true_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_true'
+require 'mspec/matchers'
describe BeTrueMatcher do
it "matches when actual is true" do
@@ -25,4 +25,4 @@
matcher.matches?(true)
matcher.negative_failure_message.should == ["Expected true", "not to be true"]
end
-end
+end
View
4 mspec/spec/matchers/be_valid_dns_name_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/be_valid_dns_name'
+require 'mspec/matchers'
describe BeValidDNSName do
it "matches when actual is 'localhost'" do
View
4 mspec/spec/matchers/complain_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/complain'
+require 'mspec/matchers'
describe ComplainMatcher do
it "matches when executing the proc results in output to $stderr" do
View
4 mspec/spec/matchers/eql_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/eql'
+require 'mspec/matchers'
describe EqlMatcher do
it "matches when actual is eql? to expected" do
View
4 mspec/spec/matchers/equal_element_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/equal_element'
+require 'mspec/matchers'
describe EqualElementMatcher do
it "matches if it finds an element with the passed name, no matter what attributes/content" do
View
4 mspec/spec/matchers/equal_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/equal'
+require 'mspec/matchers'
describe EqualMatcher do
it "matches when actual is equal? to expected" do
View
4 mspec/spec/matchers/equal_utf16_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/equal_utf16'
+require 'mspec/matchers'
describe EqualUtf16Matcher do
before :all do
View
6 mspec/spec/matchers/have_class_variable_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_class_variable'
+require 'mspec/matchers'
class IVarModMock; end
@@ -72,4 +72,4 @@ def IVarModMock.class_variables
end
it_should_behave_like "have_class_variable, on all Ruby versions"
-end
+end
View
4 mspec/spec/matchers/have_constant_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_constant'
+require 'mspec/matchers'
class HCMSpecs
X = :x
View
8 mspec/spec/matchers/have_data_spec.rb
@@ -1,8 +1,8 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_data'
-require 'mspec/helpers/tmp'
-require 'mspec/helpers/fs'
+require 'mspec/guards'
+require 'mspec/helpers'
+require 'mspec/matchers'
describe HaveDataMatcher do
before :each do
View
4 mspec/spec/matchers/have_instance_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_instance_method'
+require 'mspec/matchers'
class HIMMSpecs
def instance_method
View
6 mspec/spec/matchers/have_instance_variable_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_instance_variable'
+require 'mspec/matchers'
shared_examples_for "have_instance_variable, on all Ruby versions" do
after :all do
@@ -72,4 +72,4 @@ def @object.instance_variables
end
it_should_behave_like "have_instance_variable, on all Ruby versions"
-end
+end
View
4 mspec/spec/matchers/have_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_method'
+require 'mspec/matchers'
class HMMSpecs
def instance_method
View
4 mspec/spec/matchers/have_private_instance_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_private_instance_method'
+require 'mspec/matchers'
class HPIMMSpecs
private
View
4 mspec/spec/matchers/have_private_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_private_method'
+require 'mspec/matchers'
class HPMMSpecs
def self.private_method
View
4 mspec/spec/matchers/have_protected_instance_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_protected_instance_method'
+require 'mspec/matchers'
class HPIMMSpecs
protected
View
4 mspec/spec/matchers/have_public_instance_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_public_instance_method'
+require 'mspec/matchers'
class HPIMMSpecs
def public_method
View
4 mspec/spec/matchers/have_singleton_method_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/have_singleton_method'
+require 'mspec/matchers'
class HSMMSpecs
def self.singleton_method
View
4 mspec/spec/matchers/include_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/include'
+require 'mspec/matchers'
describe IncludeMatcher do
it "matches when actual includes expected" do
View
6 mspec/spec/matchers/infinity_spec.rb
@@ -1,6 +1,8 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/infinity'
+require 'mspec/guards'
+require 'mspec/helpers'
+require 'mspec/matchers'
describe InfinityMatcher do
it "matches when actual is infinite and has the correct sign" do
View
6 mspec/spec/matchers/match_yaml_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/match_yaml'
+require 'mspec/matchers'
describe MatchYAMLMatcher do
before :each do
@@ -13,7 +13,7 @@
it "compares YAML documents and does not match if they're not equivalent" do
@matcher.matches?("--- \nbar: foo\n").should == false
- @matcher.matches?("--- \nfoo: \nbar\n").should == false
+ @matcher.matches?("--- \nfoo: \nbar\n").should == false
end
it "also receives objects that respond_to to_yaml" do
View
4 mspec/spec/matchers/output_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/output'
+require 'mspec/matchers'
describe OutputMatcher do
it "matches when executing the proc results in the expected output to $stdout" do
View
4 mspec/spec/matchers/output_to_fd_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/output_to_fd'
+require 'mspec/matchers'
describe OutputToFDMatcher do
# Figure out how in the hell to achieve this
View
4 mspec/spec/matchers/raise_error_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/raise_error'
+require 'mspec/matchers'
class ExpectedException < Exception; end
class UnexpectedException < Exception; end
View
4 mspec/spec/matchers/respond_to_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/respond_to'
+require 'mspec/matchers'
describe RespondToMatcher do
it "matches when actual does respond_to? expected" do
View
4 mspec/spec/matchers/signed_zero_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/signed_zero'
+require 'mspec/matchers'
describe SignedZeroMatcher do
it "matches when actual is zero and has the correct sign" do
View
4 mspec/spec/matchers/stringsymboladapter_spec.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/expectations/expectations'
-require 'mspec/matchers/stringsymboladapter'
+require 'mspec/matchers'
describe StringSymbolAdapter, "#convert_name" do
include StringSymbolAdapter
View
24 mspec/spec/mocks/mock_spec.rb
@@ -2,7 +2,7 @@
# opposites are true (for example a failure when the specified
# arguments are NOT provided) is to simply alter the particular
# spec to a failure condition.
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require 'mspec/runner/mspec'
require 'mspec/mocks/mock'
require 'mspec/mocks/proxy'
@@ -39,7 +39,7 @@
before :each do
@mock = mock('install_method')
MSpec.stub!(:actions)
- MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
+ MSpec.stub!(:current).and_return(mock("spec state").as_null_object)
end
it "returns true if a method has been stubbed on an object" do
@@ -72,7 +72,7 @@
before :each do
@mock = mock('install_method')
MSpec.stub!(:actions)
- MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
+ MSpec.stub!(:current).and_return(mock("spec state").as_null_object)
end
after :each do
@@ -123,7 +123,7 @@
end
it "adds to the expectation tally" do
- state = mock("run state", :null_object => true)
+ state = mock("run state").as_null_object
state.stub!(:state).and_return(mock("spec state"))
MSpec.should_receive(:current).and_return(state)
MSpec.should_receive(:actions).with(:expectation, state.state)
@@ -132,7 +132,7 @@
end
it "registers that an expectation has been encountered" do
- state = mock("run state", :null_object => true)
+ state = mock("run state").as_null_object
state.stub!(:state).and_return(mock("spec state"))
MSpec.should_receive(:expectation)
Mock.install_method(@mock, :method_call).and_return(1)
@@ -144,7 +144,7 @@
before :each do
@mock = mock('install_method')
MSpec.stub!(:actions)
- MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
+ MSpec.stub!(:current).and_return(mock("spec state").as_null_object)
end
after :each do
@@ -175,7 +175,7 @@
end
it "does not add to the expectation tally" do
- state = mock("run state", :null_object => true)
+ state = mock("run state").as_null_object
state.stub!(:state).and_return(mock("spec state"))
MSpec.should_not_receive(:actions)
Mock.install_method(@mock, :method_call, :stub).and_return(1)
@@ -187,7 +187,7 @@
before :each do
@mock = mock('install_method')
MSpec.stub!(:actions)
- MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
+ MSpec.stub!(:current).and_return(mock("spec state").as_null_object)
end
after :each do
@@ -212,7 +212,7 @@ class MockAndRaiseError < Exception; end
describe Mock, ".verify_call" do
before :each do
MSpec.stub!(:actions)
- MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
+ MSpec.stub!(:current).and_return(mock("spec state").as_null_object)