Ashley, Sorry I can't really help you with your problem, but I can tell you that mocking is frowned upon in the merb community, mainly because it can lead to very brittle tests where you tend to only test your implementation and not the "real output" of your program.
That said, what about just issuing a request to your controller and then test the returned view if it include some CSS3 selector you expect it to have? Have a look at http://wiki.merbivore.com/testing/request_specs http://atmos.org/index.php/2008/11/29/merb-10-controller-testing/ to see best practices for writing merb request specs. cheers snusnu On Fri, Dec 12, 2008 at 19:29, Ashley Moran <[email protected]> wrote: > > Hi > > I've got this spec: > > describe "when the story exists" do > before(:each) do > @story = mock(Story, :latest_version => :version) > Story.stub!(:get_trying_guid).and_return(@story) > end > > # ... examples > > it "should assign the Story's latest version to the view" do > do_get > assigns(:story_version).should == :version > end > end > > And this implementation: > > class Stories < Application > > def show(id) > @story = Story.get_trying_guid(URI.unescape(id)) > raise NotFound unless @story > > @story_version = @story.latest_version > display @story > end > > end > > But the spec fails: > > 'Stories#show when the story exists should assign the Story's latest > version to the view' FAILED > expected: :version, > got: nil (using ==) > ./spec/controllers/stories_spec.rb:42: > > even though the view does what I expect it to. > > However, if I set an expectation that @story (the object that gets > passed to #display) should be assigned, that works. > > Am I doing something wrong or is this a bug? > > > Thanks for any help > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/merb?hl=en -~----------~----~----~----~------~----~------~--~---
