Reputation: 2264
I have following class method
module Abc
class Def
class << self
include Ghi::Lmn
def mymethod(*args)
puts 'class method'
def value
@value.nil? ? 'test' << name : @value
end
end
end
end
now how can i write test cases for this method so it will call method mymethod?
Upvotes: 1
Views: 1923
Reputation: 1674
Here's a good link on how to call a class method with rspec
. Basically you create a call to the class method in the rspec
itself:
class FooBar
def initialize(foo, bar)
@foo = foo
@bar = bar
end
def output
puts @foo
puts @bar
end
end
describe Foo do
context bar do
subject { FooBar.new(<info>).output } # Create an instance of the class in the rspec
end
end
Upvotes: 1
Reputation: 369430
You can call your method like this:
Abc::Def.mymethod(1, 2, 3, :foo, :bar, :baz)
Upvotes: 0