我有什么方法可以重新定义describe
,以便我可以写一下
new_describe MyModule::MyClass do
it "does this" do
end
it "does that" do
end
end
而不是
describe "something" do
def app
MyModule::MyClass
end
it "does this" do
end
it "does that" do
end
end
答案 0 :(得分:0)
您已经可以使用可用的语法描述特定的类:
describe MyModule::MyClass do
it "is available as described_class" do
described_class.should eq(MyModule::MyClass)
end
end
更多信息:Rspec
答案 1 :(得分:0)
我想知道this blog post by David Chelimsky是否在谈论你想要做什么?如果是这样的话:
describe MyModule::MyClass do
subject(:app){ MyModule::MyClass.new }
it { should_not be_nil }
it "does that" do
app.that == "that"
end
end