Sha256: 9d7381244ed3927b03ae83591809dbc40790f0198a6c6cbd4e261196efa0849c

Contents?: true

Size: 1.75 KB

Versions: 12

Compression:

Stored size: 1.75 KB

Contents

require 'teststrap'
require 'whyvalidationssuckin96/test/riot'

context "validation macro assertions" do
  
  context "being registered" do
    setup do
      WhyValidationsSuckIn96::ValidationBuilder::RegisteredMacros
    end
  
    should "actually have more than one registered macro to ensure these tests are valid" do
      topic.size > 1
    end

    should "add a riot assertion macro for each registered validation" do
      WhyValidationsSuckIn96::ValidationBuilder::RegisteredMacros.keys.all? do |k|
        Riot::Assertion.macros.has_key?(k.to_s)
      end
    end
  end # being registered
  
  context "asserting against a class" do
    setup do 
      klass = Class.new do
        include WhyValidationsSuckIn96::ValidationSupport
        setup_validations do
          validates_format_of :foo, :with => /[a-z]/
        end
      end
      
      Riot::Assertion.new("test") { klass }
    end
    
    should "fail if there's no validation against the specified attribute" do
      topic.validates_format_of(:ministry).run(Riot::Situation.new).first
    end.equals(:fail)
    
    should "fail if there's a validation against the specified attribute but no options are specified" do
      topic.validates_format_of(:foo).run(Riot::Situation.new).first
    end.equals(:fail)
    
    should "fail if there's a validation against the specified attribute but bad options are specified" do
      topic.validates_format_of(:foo, :with => //).run(Riot::Situation.new).first
    end.equals(:fail)
    
    should "pass if there's a validation against the specified attribute and good options are specified" do
      topic.validates_format_of(:foo, :with => /[a-z]/).run(Riot::Situation.new).first
    end.equals(:pass)

  end # asserting against a class
end   # validation macro assertions

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
whyvalidationssuckin96-1.6.4 test/riot/macros_test.rb
whyvalidationssuckin96-1.6.3 test/riot/macros_test.rb
whyvalidationssuckin96-1.6.2 test/riot/macros_test.rb
whyvalidationssuckin96-1.6.1 test/riot/macros_test.rb
whyvalidationssuckin96-1.6.0 test/riot/macros_test.rb
whyvalidationssuckin96-1.5.5 test/riot/macros_test.rb
whyvalidationssuckin96-1.5.4 test/riot/macros_test.rb
whyvalidationssuckin96-1.5.3 test/riot/macros_test.rb
whyvalidationssuckin96-1.5.2 test/riot/macros_test.rb
whyvalidationssuckin96-1.5.1 test/riot/macros_test.rb
whyvalidationssuckin96-1.5.0 test/riot/macros_test.rb
whyvalidationssuckin96-1.4.0 test/riot/macros_test.rb