安装rspec gem,把后面的代码保存为file1.rb, 然后运行:
rpsec file1.rb
可以看到彩色效果。
require 'rspec'
RSpec.configure do |config|
config.color = true
# config.mock_framework = :rspec
end
class Item
attr_accessor :name
def initialize(name)
self.name = name
end
end
describe Item do
let(:x) { 1 }
it "should be created by name" do
item = Item.new("bar")
expect(item.name).to eq("bar")
#item.name.should == "bar"
end
end
网友评论