From 927d8b8cde930244a16215c57896c8e45f616d0f Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 20 Sep 2009 12:59:32 -0400 Subject: Fix almost all Ruby warnings during spec suite --- spec/arel/algebra/unit/predicates/equality_spec.rb | 2 +- spec/arel/algebra/unit/primitives/attribute_spec.rb | 6 ++---- spec/arel/algebra/unit/relations/alias_spec.rb | 2 +- spec/arel/algebra/unit/relations/relation_spec.rb | 6 +++--- spec/arel/algebra/unit/relations/table_spec.rb | 2 +- spec/arel/engines/sql/unit/predicates/binary_spec.rb | 11 ++++++----- spec/doubles/hash.rb | 4 ++++ spec/spec_helper.rb | 8 ++++++++ 8 files changed, 26 insertions(+), 15 deletions(-) (limited to 'spec') diff --git a/spec/arel/algebra/unit/predicates/equality_spec.rb b/spec/arel/algebra/unit/predicates/equality_spec.rb index c917520158..01917842f6 100644 --- a/spec/arel/algebra/unit/predicates/equality_spec.rb +++ b/spec/arel/algebra/unit/predicates/equality_spec.rb @@ -11,7 +11,7 @@ module Arel describe '==' do it "obtains if attribute1 and attribute2 are identical" do - Equality.new(@attribute1, @attribute2).should == Equality.new(@attribute1, @attribute2) + check Equality.new(@attribute1, @attribute2).should == Equality.new(@attribute1, @attribute2) Equality.new(@attribute1, @attribute2).should_not == Equality.new(@attribute1, @attribute1) end diff --git a/spec/arel/algebra/unit/primitives/attribute_spec.rb b/spec/arel/algebra/unit/primitives/attribute_spec.rb index cd484007e1..93b661c6fc 100644 --- a/spec/arel/algebra/unit/primitives/attribute_spec.rb +++ b/spec/arel/algebra/unit/primitives/attribute_spec.rb @@ -73,10 +73,8 @@ module Arel describe 'when dividing two matching attributes' do it 'returns a the highest score for the most similar attributes' do - (@aliased_relation[:id] / @relation[:id]) \ - .should == (@aliased_relation[:id] / @relation[:id]) - (@aliased_relation[:id] / @relation[:id]) \ - .should < (@aliased_relation[:id] / @aliased_relation[:id]) + check((@aliased_relation[:id] / @relation[:id]).should == (@aliased_relation[:id] / @relation[:id])) + (@aliased_relation[:id] / @relation[:id]).should < (@aliased_relation[:id] / @aliased_relation[:id]) end end end diff --git a/spec/arel/algebra/unit/relations/alias_spec.rb b/spec/arel/algebra/unit/relations/alias_spec.rb index 2aa4d52d99..eaf31652b9 100644 --- a/spec/arel/algebra/unit/relations/alias_spec.rb +++ b/spec/arel/algebra/unit/relations/alias_spec.rb @@ -8,7 +8,7 @@ module Arel describe '==' do it "obtains if the objects are the same" do - Alias.new(@relation).should_not == Alias.new(@relation) + check Alias.new(@relation).should_not == Alias.new(@relation) (aliaz = Alias.new(@relation)).should == aliaz end end diff --git a/spec/arel/algebra/unit/relations/relation_spec.rb b/spec/arel/algebra/unit/relations/relation_spec.rb index 0a08deffb8..2688ece4a5 100644 --- a/spec/arel/algebra/unit/relations/relation_spec.rb +++ b/spec/arel/algebra/unit/relations/relation_spec.rb @@ -17,8 +17,8 @@ module Arel describe 'when given a', Symbol, String do it "returns the attribute with the same name, if it exists" do - @relation[:id].should == @attribute1 - @relation['id'].should == @attribute1 + check @relation[:id].should == @attribute1 + check @relation['id'].should == @attribute1 @relation[:does_not_exist].should be_nil end end @@ -180,7 +180,7 @@ module Arel describe Relation::Enumerable do it "implements enumerable" do - @relation.collect.should == @relation.session.read(@relation).collect + check @relation.collect.should == @relation.session.read(@relation).collect @relation.first.should == @relation.session.read(@relation).first end end diff --git a/spec/arel/algebra/unit/relations/table_spec.rb b/spec/arel/algebra/unit/relations/table_spec.rb index e4c4e58b75..19c1ba2bea 100644 --- a/spec/arel/algebra/unit/relations/table_spec.rb +++ b/spec/arel/algebra/unit/relations/table_spec.rb @@ -9,7 +9,7 @@ module Arel describe '[]' do describe 'when given a', Symbol do it "manufactures an attribute if the symbol names an attribute within the relation" do - @relation[:id].should == Attribute.new(@relation, :id) + check @relation[:id].should == Attribute.new(@relation, :id) @relation[:does_not_exist].should be_nil end end diff --git a/spec/arel/engines/sql/unit/predicates/binary_spec.rb b/spec/arel/engines/sql/unit/predicates/binary_spec.rb index ccf9d4ef73..783e6c6a7b 100644 --- a/spec/arel/engines/sql/unit/predicates/binary_spec.rb +++ b/spec/arel/engines/sql/unit/predicates/binary_spec.rb @@ -2,15 +2,16 @@ require 'spec_helper' module Arel describe Binary do + class ConcreteBinary < Binary + def predicate_sql + "<=>" + end + end + before do @relation = Table.new(:users) @attribute1 = @relation[:id] @attribute2 = @relation[:name] - class ConcreteBinary < Binary - def predicate_sql - "<=>" - end - end end describe "with compound predicates" do diff --git a/spec/doubles/hash.rb b/spec/doubles/hash.rb index 32c5b98058..fd9edd34ad 100644 --- a/spec/doubles/hash.rb +++ b/spec/doubles/hash.rb @@ -3,18 +3,22 @@ class Hash to_a.sort { |(key1, value1), (key2, value2)| key1.hash <=> key2.hash } end + undef :keys def keys ordered_array.collect(&:first) end + undef :values def values ordered_array.collect { |_, v| v } end + undef :each def each(&block) ordered_array.each(&block) end + undef :shift def shift returning to_a.first do |k, v| delete(k) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index beb634fbd3..7d61fc9120 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,9 +37,17 @@ module AdapterGuards end end +module Check + # This is used to eliminate Ruby warnings on some RSpec assertion lines + # See: https://rspec.lighthouseapp.com/projects/5645/tickets/504 + def check(*args) + end +end + Spec::Runner.configure do |config| config.include BeLikeMatcher, HashTheSameAsMatcher, DisambiguateAttributesMatcher config.include AdapterGuards + config.include Check config.mock_with :rr config.before do Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base) -- cgit v1.2.3