Class: Pancake::Test::Matchers::MountMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/pancake/test/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_app, path) ⇒ MountMatcher

Returns a new instance of MountMatcher.



5
6
7
# File 'lib/pancake/test/matchers.rb', line 5

def initialize(expected_app, path)
  @expected_app, @path = expected_app, path
end

Instance Method Details

#failure_message_for_shouldObject



19
20
21
22
23
24
25
# File 'lib/pancake/test/matchers.rb', line 19

def failure_message_for_should
  if @ma
    "Expected #{@target} to mount #{@expected_app} at #{@path.inspect} but was mounted at #{@ma.mount_path.inspect}"
  else
    "Expected #{@target} to mount #{@expected_app} but it was not mounted"
  end
end

#failure_message_for_should_notObject



27
28
29
30
31
# File 'lib/pancake/test/matchers.rb', line 27

def failure_message_for_should_not
  if @ma
    "Expected #{@target} to not implement #{@expected_app} at #{@path} but it was mounted there"
  end
end

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/pancake/test/matchers.rb', line 9

def matches?(target)
  @target = target
  @ma = @target::Router.mounted_applications.detect{|m| m.mounted_app == @expected_app}
  if @ma
    @ma.mounted_app == @expected_app && @ma.mount_path == @path
  else
    false
  end
end