diff options
Diffstat (limited to 'spec/mspec')
-rwxr-xr-x | spec/mspec/lib/mspec/commands/mkspec.rb | 2 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/guards/conflict.rb | 6 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/matchers/raise_error.rb | 2 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/utils/name_map.rb | 47 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/utils/script.rb | 6 | ||||
-rw-r--r-- | spec/mspec/spec/commands/mkspec_spec.rb | 4 | ||||
-rw-r--r-- | spec/mspec/spec/guards/conflict_spec.rb | 2 | ||||
-rw-r--r-- | spec/mspec/spec/utils/name_map_spec.rb | 4 |
8 files changed, 34 insertions, 39 deletions
diff --git a/spec/mspec/lib/mspec/commands/mkspec.rb b/spec/mspec/lib/mspec/commands/mkspec.rb index 7a943aa1fe..49a2e6b616 100755 --- a/spec/mspec/lib/mspec/commands/mkspec.rb +++ b/spec/mspec/lib/mspec/commands/mkspec.rb @@ -75,7 +75,7 @@ class MkSpec parents = '../' * (sub.split('/').length + 1) File.open(file, 'w') do |f| - f.puts "require File.expand_path('../#{parents}spec_helper', __FILE__)" + f.puts "require_relative '#{parents}spec_helper'" config[:requires].each do |lib| f.puts "require '#{lib}'" end diff --git a/spec/mspec/lib/mspec/guards/conflict.rb b/spec/mspec/lib/mspec/guards/conflict.rb index 7a27671c1e..4930e5734d 100644 --- a/spec/mspec/lib/mspec/guards/conflict.rb +++ b/spec/mspec/lib/mspec/guards/conflict.rb @@ -1,6 +1,12 @@ require 'mspec/guards/guard' +require 'mspec/utils/deprecate' class ConflictsGuard < SpecGuard + def initialize(*args) + MSpec.deprecate 'conflicts_with', 'guard -> { condition } do' + super(*args) + end + def match? # Always convert constants to symbols regardless of version. constants = Object.constants.map { |x| x.to_sym } diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb index 2f9afdc687..a051ea12f7 100644 --- a/spec/mspec/lib/mspec/matchers/raise_error.rb +++ b/spec/mspec/lib/mspec/matchers/raise_error.rb @@ -1,5 +1,3 @@ -require 'mspec/utils/deprecate' - class RaiseErrorMatcher def initialize(exception, message, &block) @exception = exception diff --git a/spec/mspec/lib/mspec/utils/name_map.rb b/spec/mspec/lib/mspec/utils/name_map.rb index c1de081af0..a93b0d001e 100644 --- a/spec/mspec/lib/mspec/utils/name_map.rb +++ b/spec/mspec/lib/mspec/utils/name_map.rb @@ -8,10 +8,9 @@ class NameMap '*' => 'multiply', '/' => 'divide', '%' => 'modulo', - '<<' => {'Bignum' => 'left_shift', - 'Fixnum' => 'left_shift', - 'IO' => 'output', - :default => 'append' }, + '<<' => {'Integer' => 'left_shift', + 'IO' => 'output', + :default => 'append' }, '>>' => 'right_shift', '<' => 'lt', '<=' => 'lte', @@ -25,33 +24,22 @@ class NameMap '[]=' => 'element_set', '**' => 'exponent', '!' => 'not', - '~' => {'Bignum' => 'complement', - 'Fixnum' => 'complement', - 'Regexp' => 'match', - 'String' => 'match' }, + '~' => {'Integer' => 'complement', + :default => 'match' }, '!=' => 'not_equal', '!~' => 'not_match', '=~' => 'match', - '&' => {'Bignum' => 'bit_and', - 'Fixnum' => 'bit_and', + '&' => {'Integer' => 'bit_and', 'Array' => 'intersection', - 'TrueClass' => 'and', - 'FalseClass' => 'and', - 'NilClass' => 'and', - 'Set' => 'intersection' }, - '|' => {'Bignum' => 'bit_or', - 'Fixnum' => 'bit_or', + 'Set' => 'intersection', + :default => 'and' }, + '|' => {'Integer' => 'bit_or', 'Array' => 'union', - 'TrueClass' => 'or', - 'FalseClass' => 'or', - 'NilClass' => 'or', - 'Set' => 'union' }, - '^' => {'Bignum' => 'bit_xor', - 'Fixnum' => 'bit_xor', - 'TrueClass' => 'xor', - 'FalseClass' => 'xor', - 'NilClass' => 'xor', - 'Set' => 'exclusion'}, + 'Set' => 'union', + :default => 'or' }, + '^' => {'Integer' => 'bit_xor', + 'Set' => 'exclusion', + :default => 'xor' }, } EXCLUDED = %w[ @@ -119,7 +107,12 @@ class NameMap def file_name(m, c) if MAP.key?(m) - name = MAP[m].is_a?(Hash) ? MAP[m][c.split('::').last] || MAP[m][:default] : MAP[m] + mapping = MAP[m] + if mapping.is_a?(Hash) + name = mapping[c.split('::').last] || mapping.fetch(:default) + else + name = mapping + end else name = m.gsub(/[?!=]/, '') end diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb index 2816618b0f..db5a33a91a 100644 --- a/spec/mspec/lib/mspec/utils/script.rb +++ b/spec/mspec/lib/mspec/utils/script.rb @@ -189,11 +189,7 @@ class MSpecScript end patterns.each do |pattern| - begin - expanded = File.realpath(pattern) - rescue Errno::ENOENT - next - end + expanded = File.expand_path(pattern) if File.file?(expanded) && expanded.end_with?('.rb') return [expanded] elsif File.directory?(expanded) diff --git a/spec/mspec/spec/commands/mkspec_spec.rb b/spec/mspec/spec/commands/mkspec_spec.rb index 14c363f286..1b959dcb78 100644 --- a/spec/mspec/spec/commands/mkspec_spec.rb +++ b/spec/mspec/spec/commands/mkspec_spec.rb @@ -167,13 +167,13 @@ describe MkSpec, "#write_requires" do end it "writes the spec_helper require line" do - @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)") + @file.should_receive(:puts).with("require_relative '../../../spec_helper'") @script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb") end it "writes require lines for each library specified on the command line" do @file.stub(:puts) - @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)") + @file.should_receive(:puts).with("require_relative '../../../spec_helper'") @file.should_receive(:puts).with("require 'complex'") @script.config[:requires] << 'complex' @script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb") diff --git a/spec/mspec/spec/guards/conflict_spec.rb b/spec/mspec/spec/guards/conflict_spec.rb index e06a2809ee..deada96821 100644 --- a/spec/mspec/spec/guards/conflict_spec.rb +++ b/spec/mspec/spec/guards/conflict_spec.rb @@ -3,6 +3,7 @@ require 'mspec/guards' describe Object, "#conflicts_with" do before :each do + hide_deprecation_warnings ScratchPad.clear end @@ -33,6 +34,7 @@ end describe Object, "#conflicts_with" do before :each do + hide_deprecation_warnings @guard = ConflictsGuard.new ConflictsGuard.stub(:new).and_return(@guard) end diff --git a/spec/mspec/spec/utils/name_map_spec.rb b/spec/mspec/spec/utils/name_map_spec.rb index d38230ce06..d5d2cca84a 100644 --- a/spec/mspec/spec/utils/name_map_spec.rb +++ b/spec/mspec/spec/utils/name_map_spec.rb @@ -129,7 +129,7 @@ describe NameMap, "#file_name" do it "returns the name of the spec file based on the special entry for the method" do @map.file_name("~", "Regexp").should == "match_spec.rb" - @map.file_name("~", "Fixnum").should == "complement_spec.rb" + @map.file_name("~", "Integer").should == "complement_spec.rb" end it "returns the name of the spec file based on the default entry for the method" do @@ -137,7 +137,7 @@ describe NameMap, "#file_name" do end it "uses the last component of the constant to look up the method name" do - @map.file_name("^", "NameMapSpecs::Fixnum").should == "bit_xor_spec.rb" + @map.file_name("^", "NameMapSpecs::Integer").should == "bit_xor_spec.rb" end end |