Permalink
Browse files

Use RSpec matchers for checking whether a class including Broadcast::…

…Publishable responds to methods. Beats me why I did not do it in the first place.
  • Loading branch information...
Marcin Bunsch Marcin Bunsch
Marcin Bunsch authored and Marcin Bunsch committed Jun 8, 2011
1 parent 257bda5 commit 33b1e49f293bdd079cb484bde8f3a98e7e8df829
Showing with 12 additions and 9 deletions.
  1. +12 −9 spec/lib/broadcast/publishable_spec.rb
@@ -5,7 +5,7 @@ class ClassToBecomeMessage
attr_accessor :something
- def initialize(somthng)
+ def initialize(somthng = nil)
self.something = somthng
end
@@ -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

0 comments on commit 33b1e49

Please sign in to comment.