rspec_attr_extensions
rspec_attr_extensions copied to clipboard
Ruby attribute extensions for RSpec
h1. RSpec attr extensions
p. "RDoc":http://rdoc.info/projects/rubiii/rspec_attr_extensions | "Continuous Integration":http://runcoderun.com/rubiii/rspec_attr_extensions | "Metrics":http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/rspec_attr_extensions.git
h2. Installation
bc. $ gem install rspec_attr_extensions
h2. An example
p. 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
p. Load rspec_attr_extensions in your spec_helper file.
bc. require "spec" require "rspec_attr_extensions"
p. 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