Sha256: af5ffe29dc54438403f5cb604cffbc801baaaf32b72672cfea65bb72e29bd4e9

Contents?: true

Size: 1.3 KB

Versions: 21

Compression:

Stored size: 1.3 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
require "usher"

def build_email_mock(email)
  request = mock "Request"
  request.should_receive(:email).any_number_of_times.and_return(email)
  request
end

describe "Usher (for email) route recognition" do

  before(:each) do
    @route_set = Usher::Interface.for(:email)
  end

  it "should recognize a simple request" do
    receiver = mock('receiver')
    receiver.should_receive(:action).with({}).exactly(1)
    @route_set.for('joshbuddy@gmail.com') { |params| receiver.action(params) }
    @route_set.act('joshbuddy@gmail.com')
  end

  it "should recognize a wildcard domain" do
    receiver = mock('receiver')
    receiver.should_receive(:action).with({:domain => 'gmail.com'}).exactly(1)
    @route_set.for('joshbuddy@{!domain,.*}') { |params| receiver.action(params) }
    @route_set.act('joshbuddy@gmail.com')
  end

  it "should recognize a complex email" do
    receiver = mock('receiver')
    receiver.should_receive(:action).with({:subject => 'sub+ect', :id => '123', :sid => '456', :tok => 'sdqwe123ae', :domain => 'mydomain.org'}).exactly(1)
    @route_set.for(':subject.{!id,\d+}-{!sid,\d+}-{!tok,\w+}@{!domain,.*}') { |params| receiver.action(params) }
    @route_set.act('sub+ect.123-456-sdqwe123ae@mydomain.org')
  end

end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
joshbuddy-usher-0.5.7 spec/private/email/recognize_spec.rb
usher-0.7.4 spec/private/email/recognize_spec.rb
usher-0.7.3 spec/private/email/recognize_spec.rb
usher-0.7.2 spec/private/email/recognize_spec.rb
usher-0.7.1 spec/private/email/recognize_spec.rb
usher-0.7.0 spec/private/email/recognize_spec.rb
usher-0.6.8 spec/private/email/recognize_spec.rb
usher-0.6.7 spec/private/email/recognize_spec.rb
usher-0.6.6 spec/private/email/recognize_spec.rb
usher-0.6.5 spec/private/email/recognize_spec.rb
usher-0.6.4 spec/private/email/recognize_spec.rb
usher-0.6.3 spec/private/email/recognize_spec.rb
usher-0.6.2 spec/private/email/recognize_spec.rb
usher-0.6.1 spec/private/email/recognize_spec.rb
usher-0.6.0 spec/private/email/recognize_spec.rb
usher-0.5.13 spec/private/email/recognize_spec.rb
usher-0.5.12 spec/private/email/recognize_spec.rb
usher-0.5.11 spec/private/email/recognize_spec.rb
usher-0.5.10 spec/private/email/recognize_spec.rb
usher-0.5.8 spec/private/email/recognize_spec.rb