Class: Merb::Test::Rspec::ControllerMatchers::Provide

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-core/test/matchers/controller_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ Provide

Parameters

expected<Symbol>

A format to check



165
166
167
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 165

def initialize(expected)
  @expected = expected
end

Instance Method Details

#failure_messageObject

Returns

String

The failure message.



182
183
184
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 182

def failure_message
  "expected #{@target.name} to provide #{@expected}, but it doesn't"
end

#matches?(target) ⇒ Boolean

Parameters

target<Symbol>

A ControllerClass or controller_instance

Returns

Boolean

True if the formats provided by the target controller/class include the expected

Returns:

  • (Boolean)


175
176
177
178
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 175

def matches?(target)
  @target = target
  provided_formats.include?( @expected )
end

#negative_failure_messageObject

Returns

String

The failure message to be displayed in negative matches.



188
189
190
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 188

def negative_failure_message
  "expected #{@target.name} not to provide #{@expected}, but it does"
end

#provided_formatsObject

Returns

Array

The formats the expected provides



194
195
196
# File 'lib/merb-core/test/matchers/controller_matchers.rb', line 194

def provided_formats
  @target.class_provided_formats
end