RSpec attr extensions
RDoc | Continuous Integration | Metrics
Installation
$ gem install rspec_attr_extensions
An example
Let’s test that TheHoff contains various attr_* methods.
class TheHoff
def initialize
@hair_style = "curly"
@smash_hit = "Looking for Freedom"
@date_of_birth = "July 17, 1952"
end
attr_reader :smash_hit, :date_of_birth
attr_writer :smash_hit
attr_accessor :hair_style
end
Load rspec_attr_extensions in your spec_helper file.
require "spec"
require "rspec_attr_extensions"
And use the test methods provided by this library to clean up your specs.
require "spec_helper"
describe TheHoff do
it_should_have_an_attr_reader_for :smash_hit, :date_of_birth
it_should_have_an_attr_writer_for :smash_hit
it_should_have_an_attr_accessor_for :hair_style
end