ruby - testing is method is present using Rspec -


i'm testing method present in class can't make work :(

my error-log one:

1) videosearch find next video-sampler responds find next video sampler      failure/error: expect(vs).to respond_to(:find_next_sampler)        expected #<videosearch:0x007faccb8a2300 @title=2345> respond :find_next_sampler      # ./spec/models/video_search_spec.rb:41:in `block (3 levels) in <top (required)>' 

my code:

class videosearch    attr_accessor :title    def initialize(params)     @title = params    end    def self.find_next_sampler(end_time, end_point)     video.where("start_time >= ? , start_point = ?" , "#{ end_time }", "#{ end_point }" ).first   end  end 

my spec:

  describe 'find next video-sampler'     let(:v1) { v1 = video.create( title: 2345 ) }     let(:vs) { videosearch.new v1.title }      'responds find_next_sampler'       expect(vs).to respond_to(:find_next_sampler)      end 

thanks 4 yr time!

it's class instance method. instances of videosearch don't have method, class does. should this:

expect(videosearch).to respond_to(:find_next_sampler) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -