I figured out that I needed to change how I was testing my scope.
Another forum site had this post by a guy named Ian (thanks Ian).
>> Ideally your unit tests should treat models (classes) and instances
thereof as
black boxes. After all, it''s not really the implementation you care
about but the
behavior of the interface.
>> So instead of testing that the scope is implemented in a particular way
(i.e.
with a particular set of conditions), try testing that it behaves correctly—that
it returns instances it should and doesn''t return instances it
shouldn''t.
----
This led me to believe I needed to change to testing the behavior not
the stucture. I kept my scope the same but changed my test to the
following. It works, is a good test of the data tested and the results
expected. In the test, I create an array of the instructor''s name and
netid and compare that to an array of the name and netid returned by my
scope.
require ''test_helper''
class ClassInstructorTest < ActiveSupport::TestCase
test "named_scope :find_instructor_for_a_course returns name and
netid" do
expected = [''HOLLIS'', ''rbh25'']
assert_equal expected,
[ClassInstructor.find_instructor_for_a_course(''HA5503'',
''F10'', ''LEC'',
1).first.instr_id,
ClassInstructor.find_instructor_for_a_course(''HA5503'',
''F10'', ''LEC'', 1).first.netid]
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.