Sha256: 92876b7cb6ad930d1d13814753fe779ad32f3a6c7b6d69da7703023461020745

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

BLOG_URI = "http://168ta.com"

class Profile

  def messages(limit, offset); [limit, offset] end

  def blog; BLOG_URI end

  def change_email; yield end

end

class User
  include Fastdfs::Client::Delegation

  delegate :messages, :blog, :change_email, to: :profile

  def profile
    Profile.new
  end
end

describe Fastdfs::Client::Delegation do 

  let(:user){  User.new }

  it "user should be three methods" do 
    expect(user.respond_to?(:messages)).to be_truthy
    expect(user.respond_to?(:blog)).to be_truthy
    expect(user.respond_to?(:change_email)).to be_truthy
    expect(user.respond_to?(:title)).to be_falsey
  end

  it "user method receive argments" do 
    expect(user.messages(25, 0)).to eq([25, 0])
    expect(user.blog).to eq(BLOG_URI)
    expect(user.change_email{ "hello" }).to eq("hello")
  end

  it "argments of the execption" do 
    begin
      user.messages(25) 
    rescue Exception => e
      expect(e).to be_a_kind_of(ArgumentError)  
    end

    begin
      user.change_email     
    rescue Exception => e
      expect(e).to be_a_kind_of(LocalJumpError)  
    end  
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fastdfs-client-2.0.0 spec/delegation_spec.rb