Skip to content

Commit

Permalink
Minor style tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
readeharris authored and drapergeek committed Oct 19, 2012
1 parent a117db9 commit 9565ddd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions lib/shoulda/matchers/independent/delegate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Independent # :nodoc:
# Ensure that a given method is delegated properly.
#
# Dependencies:
# This matcher requires the `bourne` gem be added to your Gemfile. You will receive
# a warning if this is not the case.
# This matcher requires the `bourne` gem be added to your Gemfile. You will receive
# a warning if this is not the case.
#
# Basic Syntax:
# it { should delegate_method(:deliver_mail).to(:mailman) }
Expand All @@ -17,7 +17,7 @@ module Independent # :nodoc:
#
# Examples:
# it { should delegate_method(:deliver_mail).to(:mailman).as(:deliver_with_haste)
# it { should delegate_method(:deliver_mail).to(:mailman).with_arguments("221B Baker St.", :hastily => true)
# it { should delegate_method(:deliver_mail).to(:mailman).with_arguments('221B Baker St.', :hastily => true)
#
def delegate_method(delegating_method)
require 'bourne'
Expand Down Expand Up @@ -96,9 +96,9 @@ def target_method_name

def method_name_with_class(method)
if Class === @subject
@subject.name + "." + method.to_s
@subject.name + '.' + method.to_s
else
@subject.class.name + "#" + method.to_s
@subject.class.name + '#' + method.to_s
end
end

Expand All @@ -115,13 +115,13 @@ def ensure_target_method_is_present!

class DelegateMatcher::TargetNotDefinedError < StandardError
def message
"Delegation needs a target. Use the #to method to define one, e.g. `post_office.should delegate(:deliver_mail).to(:mailman)`"
'Delegation needs a target. Use the #to method to define one, e.g. `post_office.should delegate(:deliver_mail).to(:mailman)`'
end
end

class DelegateMatcher::InvalidDelegateMatcher < StandardError
def message
"#delegate_to does not support #should_not syntax."
'#delegate_to does not support #should_not syntax.'
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/shoulda/independent/delegate_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def mailman
define_class(:mailman)
define_class(:post_office) do
def deliver_mail
mailman.deliver_mail("221B Baker St.", hastily: true)
mailman.deliver_mail('221B Baker St.', hastily: true)
end

def mailman
Expand All @@ -97,21 +97,21 @@ def mailman
context 'when given the correct arguments' do
it 'matches' do
post_office = PostOffice.new
matcher = delegate_method(:deliver_mail).to(:mailman).with_arguments("221B Baker St.", hastily: true)
matcher = delegate_method(:deliver_mail).to(:mailman).with_arguments('221B Baker St.', hastily: true)
post_office.should matcher
end
end

context 'when not given the correct arguments' do
it 'does not match' do
post_office = PostOffice.new
matcher = delegate_method(:deliver_mail).to(:mailman).with_arguments("123 Nowhere Ln.")
matcher = delegate_method(:deliver_mail).to(:mailman).with_arguments('123 Nowhere Ln.')
matcher.matches?(post_office).should be_false
end

it 'has a failure message that indicates which arguments were expected' do
post_office = PostOffice.new
matcher = delegate_method(:deliver_mail).to(:mailman).with_arguments("123 Nowhere Ln.")
matcher = delegate_method(:deliver_mail).to(:mailman).with_arguments('123 Nowhere Ln.')
matcher.matches?(post_office)
matcher.failure_message.should == 'Expected PostOffice#deliver_mail to delegate to PostOffice#mailman with arguments: ["123 Nowhere Ln."]'
end
Expand Down Expand Up @@ -160,13 +160,13 @@ def mailman
describe Shoulda::Matchers::Independent::DelegateMatcher::TargetNotDefinedError do
it 'has a useful message' do
error = Shoulda::Matchers::Independent::DelegateMatcher::TargetNotDefinedError.new
error.message.should include "Delegation needs a target."
error.message.should include 'Delegation needs a target'
end
end

describe Shoulda::Matchers::Independent::DelegateMatcher::InvalidDelegateMatcher do
it 'has a useful message' do
error = Shoulda::Matchers::Independent::DelegateMatcher::InvalidDelegateMatcher.new
error.message.should include "does not support #should_not"
error.message.should include 'does not support #should_not'
end
end

0 comments on commit 9565ddd

Please sign in to comment.