Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

Commit

Permalink
Use RSpec matchers for checking whether a class including Broadcast::…
Browse files Browse the repository at this point in the history
…Publishable responds to methods. Beats me why I did not do it in the first place.
  • Loading branch information
Marcin Bunsch authored and Marcin Bunsch committed Oct 22, 2011
1 parent 257bda5 commit 33b1e49
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions spec/lib/broadcast/publishable_spec.rb
Expand Up @@ -5,7 +5,7 @@ class ClassToBecomeMessage

attr_accessor :something

def initialize(somthng)
def initialize(somthng = nil)
self.something = somthng
end

Expand All @@ -16,33 +16,36 @@ def initialize(somthng)
describe "in class scope" do

it "should add the media accessor" do
ClassToBecomeMessage.methods.should include('media')
ClassToBecomeMessage.methods.should include('media=')
ClassToBecomeMessage.should respond_to(:media)
ClassToBecomeMessage.should respond_to(:media=)
end

it "should add the medium method" do
ClassToBecomeMessage.methods.should include('medium')
ClassToBecomeMessage.should respond_to(:medium)
end

end

describe "in instance scope" do

before {
@instance = ClassToBecomeMessage.new(123)
}
it "should add the publish method" do
ClassToBecomeMessage.public_instance_methods.should include('publish')
@instance.should respond_to(:publish)
end

it "should add the subject method" do
ClassToBecomeMessage.public_instance_methods.should include('subject')
@instance.should respond_to(:subject)
end

it "should add the body method" do
ClassToBecomeMessage.public_instance_methods.should include('body')
@instance.should respond_to(:body)
end

it "should not add the options accessor" do
ClassToBecomeMessage.public_instance_methods.should_not include('options')
ClassToBecomeMessage.public_instance_methods.should_not include('options=')
@instance.should_not respond_to(:options)
@instance.should_not respond_to(:options=)
end

it "should not mess with the initializer" do
Expand Down

0 comments on commit 33b1e49

Please sign in to comment.