我正在为控制器编写规范:
it 'should call the method that performs the movies search' do
movie = Movie.new
movie.should_receive(:search_similar)
get :find_similar, {:id => '1'}
end
Run Code Online (Sandbox Code Playgroud)
我的控制器看起来像:
def find_similar
@movies = Movie.find(params[:id]).search_similar
end
Run Code Online (Sandbox Code Playgroud)
运行rspec后,我得到以下内容:
Failures:
1) MoviesController searching by director name should call the method that performs the movies search
Failure/Error: movie.should_receive(:search_similar)
(#<Movie:0xaa2a454>).search_similar(any args)
expected: 1 time
received: 0 times
# ./spec/controllers/movies_controller_spec.rb:33:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)
我似乎理解并接受,因为在我的控制器代码中我调用了Class(Movie)方法,我没有看到任何方法将"find_similar"与在规范中创建的对象连接起来.
所以问题是 - >检查是否在对象上调用方法的方法是什么?
我们在Domino中有过一段时间的Web服务.现在,在8.5.3版之后,可以安装和部署REST服务(http://extlib.openntf.org).
根据我的理解,REST方式更清晰,只是感觉正确.
但是,Web服务仍然出于某种原因.
现在,因为看起来我将不得不深入研究这个主题,我想提出一个问题:它是否有任何理由学习并尝试实施Web服务,或者我宁愿立即开始使用最新的图书馆?(http://www.openntf.org/blogs/openntf.nsf/d6plinks/NHEF-8J994J)
更新. 发现了以下Link/Duscussion SOAP或REST for Web Services?
虽然它不是特定于Domino的,但却有很多好的信息.现在只有一些特定于Domino的经历失败了,我很高兴看到这里......
我的代码中似乎有一个错误.但是我无法找到它.
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s
attr_reader attr_name
attr_writer attr_name
attr_reader attr_name + "_history"
class_eval %Q{
@#{attr_name}_history=[1,2,3]
}
end
end
class Foo
attr_accessor_with_history :bar
end
f = Foo.new
f.bar = 1
f.bar = 2
puts f.bar_history.to_s
Run Code Online (Sandbox Code Playgroud)
我希望它能返回一个数组[1,2,3].但是,它不返回任何东西.
如果我的问题听起来不那么具体,我还是要道歉,但我确实相信(我已经从答案中看到了这个问题),这里有些人能够帮助我解决一般问题.
此外,我有一种感觉,这不仅是我的问题,而且对于许多Domino开发人员来说,获得以下问题的答案将是非常有益的.
这就是说,问题/问题是 - >我想在XPage中使用Java.我不是Java的专业知识,但我知道基础知识并对OOP和OOD有很好的理解.
因此,一般的问题是 - >我如何以及从何处开始在Domino XPages Universe中开发新技能作为Java开发人员?
更具体的一个 - >我是对的,认为起点可以从JavaBeans的形式开始使用Java来描述MVC架构中的M(模型)层?
我非常感谢一些简单的Java代码和简短的解释如何使用它们.另外一些好的链接将被接受作为帮助:)