aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-16 15:08:50 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-16 15:08:50 -0700
commitc96155c4fdd9a15eeca6e59ca3f35197d2ad3541 (patch)
tree5e06f45fcb96b7c8727a125b057bdd06638634a2 /spec
parent131b106dc0c6b001a78f6f6656c52c49831b9c9d (diff)
downloadrails-c96155c4fdd9a15eeca6e59ca3f35197d2ad3541.tar.gz
rails-c96155c4fdd9a15eeca6e59ca3f35197d2ad3541.tar.bz2
rails-c96155c4fdd9a15eeca6e59ca3f35197d2ad3541.zip
custom matcher
Diffstat (limited to 'spec')
-rw-r--r--spec/arel/integration/joins/with_adjacency_spec.rb40
-rw-r--r--spec/matchers/be_like.rb10
-rw-r--r--spec/matchers/hash_the_same_as.rb10
-rw-r--r--spec/spec_helper.rb2
4 files changed, 31 insertions, 31 deletions
diff --git a/spec/arel/integration/joins/with_adjacency_spec.rb b/spec/arel/integration/joins/with_adjacency_spec.rb
index e75ae3766e..4ffdf1f64f 100644
--- a/spec/arel/integration/joins/with_adjacency_spec.rb
+++ b/spec/arel/integration/joins/with_adjacency_spec.rb
@@ -92,33 +92,33 @@ module Arel
describe '[]' do
describe 'when given an attribute belonging to both sub-relations' do
it 'disambiguates the relation that serves as the ancestor to the attribute' do
- relation = @relation1.join(@relation2).on(@predicate)
- relation[@relation1[:id]].ancestor.should == @relation1[:id]
- relation[@relation2[:id]].ancestor.should == @relation2[:id]
+ @relation1 \
+ .join(@relation2) \
+ .on(@predicate) \
+ .should disambiguate_attributes(@relation1[:id], @relation2[:id])
end
- describe 'when the left relation is compound' do
+ describe 'when the left relation is extremely compound' do
it 'disambiguates the relation that serves as the ancestor to the attribute' do
- relation = @relation1 \
- .select(@predicate) \
- .select(@predicate) \
- .join(@relation2) \
- .on(@predicate)
- relation[@relation1[:id]].should be_descends_from(@relation1[:id])
- relation[@relation1[:id]].should_not be_descends_from(@relation2[:id])
+ @relation1 \
+ .select(@predicate) \
+ .select(@predicate) \
+ .join(@relation2) \
+ .on(@predicate) \
+ .should disambiguate_attributes(@relation1[:id], @relation2[:id])
end
end
- describe 'when the right relation is compound' do
+ describe 'when the right relation is extremely compound' do
it 'disambiguates the relation that serves as the ancestor to the attribute' do
- relation = @relation1 \
- .join( \
- @relation2 \
- .select(@predicate) \
- .select(@predicate) \
- .select(@predicate)) \
- .on(@predicate)
- relation[@relation2[:id]].should be_descends_from(@relation2[:id])
+ @relation1 \
+ .join( \
+ @relation2 \
+ .select(@predicate) \
+ .select(@predicate) \
+ .select(@predicate)) \
+ .on(@predicate) \
+ .should disambiguate_attributes(@relation1[:id], @relation2[:id])
end
end
end
diff --git a/spec/matchers/be_like.rb b/spec/matchers/be_like.rb
index cea3f3027b..c1b1ffc3fd 100644
--- a/spec/matchers/be_like.rb
+++ b/spec/matchers/be_like.rb
@@ -4,17 +4,17 @@ module BeLikeMatcher
@expected = expected
end
- def matches?(target)
- @target = target
- @expected.gsub(/\s+/, ' ').strip == @target.gsub(/\s+/, ' ').strip
+ def matches?(actual)
+ @actual = actual
+ @expected.gsub(/\s+/, ' ').strip == @actual.gsub(/\s+/, ' ').strip
end
def failure_message
- "expected #{@target} to be like #{@expected}"
+ "expected #{@actual} to be like #{@expected}"
end
def negative_failure_message
- "expected #{@target} to be unlike #{@expected}"
+ "expected #{@actual} to be unlike #{@expected}"
end
end
diff --git a/spec/matchers/hash_the_same_as.rb b/spec/matchers/hash_the_same_as.rb
index 86e98f31a3..c1903b62b4 100644
--- a/spec/matchers/hash_the_same_as.rb
+++ b/spec/matchers/hash_the_same_as.rb
@@ -4,19 +4,19 @@ module HashTheSameAsMatcher
@expected = expected
end
- def matches?(target)
- @target = target
+ def matches?(actual)
+ @actual = actual
hash = {}
hash[@expected] = :some_arbitrary_value
- hash[@target] == :some_arbitrary_value
+ hash[@actual] == :some_arbitrary_value
end
def failure_message
- "expected #{@target} to hash the same as #{@expected}; they must be `eql?` and have the same `#hash` value"
+ "expected #{@actual} to hash the same as #{@expected}; they must be `eql?` and have the same `#hash` value"
end
def negative_failure_message
- "expected #{@target} to hash differently than #{@expected}; they must not be `eql?` or have a differing `#hash` values"
+ "expected #{@actual} to hash differently than #{@expected}; they must not be `eql?` or have a differing `#hash` values"
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index bc117ec47d..eb87e2448c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -12,7 +12,7 @@ require 'arel'
end
Spec::Runner.configure do |config|
- config.include(BeLikeMatcher, HashTheSameAsMatcher)
+ config.include(BeLikeMatcher, HashTheSameAsMatcher, DisambiguateAttributesMatcher)
config.mock_with :rr
config.before do
Arel::Table.engine = Arel::Engine.new(Fake::Engine.new)