Hi Tom,
This sounds a bit like you are "testing the framework". I tend to find
tests which assert the framework did its job correctly of low value.
If your public methods, which are part of your classes interface need
testing, specify what is interesting about those methods.
These methods could probably be covered by other explicit tests, where
there is logic to be tested.
If you have a •lot• of accessor methods which you do want to test, remember
that rspec is "just" ruby, and you can generate test cases
programmatically.
Note that you need to put the context inside the each loop in rspec, or
your spec contexts get clobbered.
%w( foo bar baz ).each do |accessor_method|
context "#{accessor_method} reads and writes" do
...
Cheers
Garrow
On Monday, 11 January 2016, Tom Hale <[email protected]> wrote:
> I'm quite surprised that there's not much out there when I google 'rspec
> attr_accessor'
>
> The best I've found (not tried) is:
> https://gist.github.com/daronco/4133411#file-have_attr_accessor-rb
>
> Or (only does attr_accessor):
>
> http://stackoverflow.com/questions/24434381/ruby-rspec-how-should-i-be-testing-attr-accessor
>
> What's the DRY way to write specs for methods created with
> attr_(accessor|writer|reader)?
>
> (Note, this is not rails)
>
> Cheers,
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/rails-oceania.
> For more options, visit https://groups.google.com/d/optout.
>
--
Garrow Bedrossian
+ 61 401 532 538
--
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rails-oceania.
For more options, visit https://groups.google.com/d/optout.