Sha256: 5ac05b6ca3a07a82ec582428295857d94eb6df92d16b0b6c28906ac677e24a76

Contents?: true

Size: 1.31 KB

Versions: 24

Compression:

Stored size: 1.31 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers/match_yaml'

describe MatchYAMLMatcher do
  before :each do
    @matcher = MatchYAMLMatcher.new("--- \nfoo: bar\n")
  end

  it "compares YAML documents and matches if they're equivalent" do
      @matcher.matches?("--- \nfoo: bar\n").should == true
  end

  it "compares YAML documents and does not match if they're not equivalent" do
      @matcher.matches?("--- \nbar: foo\n").should == false
      @matcher.matches?("--- \nfoo: \nbar\n").should == false  
  end

  it "also receives objects that respond_to to_yaml" do
    matcher = MatchYAMLMatcher.new("some string")
    matcher.matches?("some string").should == true

    matcher = MatchYAMLMatcher.new(['a', 'b'])
    matcher.matches?("--- \n- a\n- b\n").should == true

    matcher = MatchYAMLMatcher.new("foo" => "bar")
    matcher.matches?("--- \nfoo: bar\n").should == true
  end

  it "matches documents with trailing whitespace" do
    @matcher.matches?("--- \nfoo: bar   \n").should == true
    @matcher.matches?("---       \nfoo: bar   \n").should == true
  end

  it "fails with a descriptive error message" do
    @matcher.matches?("foo").should == false
    @matcher.failure_message.should == ["Expected \"foo\"", " to match \"--- \\nfoo: bar\\n\""]
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
mspec-1.5.17 spec/matchers/match_yaml_spec.rb
mspec-1.5.16 spec/matchers/match_yaml_spec.rb
mspec-1.5.15 spec/matchers/match_yaml_spec.rb
mspec-1.5.14 spec/matchers/match_yaml_spec.rb
mspec-1.5.13 spec/matchers/match_yaml_spec.rb
mspec-1.1.1 spec/matchers/match_yaml_spec.rb
mspec-1.1.0 spec/matchers/match_yaml_spec.rb
mspec-1.2.0 spec/matchers/match_yaml_spec.rb
mspec-1.3.0 spec/matchers/match_yaml_spec.rb
mspec-1.3.1 spec/matchers/match_yaml_spec.rb
mspec-1.4.0 spec/matchers/match_yaml_spec.rb
mspec-1.5.0 spec/matchers/match_yaml_spec.rb
mspec-1.5.2 spec/matchers/match_yaml_spec.rb
mspec-1.5.4 spec/matchers/match_yaml_spec.rb
mspec-1.5.11 spec/matchers/match_yaml_spec.rb
mspec-1.5.12 spec/matchers/match_yaml_spec.rb
mspec-1.5.1 spec/matchers/match_yaml_spec.rb
mspec-1.5.10 spec/matchers/match_yaml_spec.rb
mspec-1.5.3 spec/matchers/match_yaml_spec.rb
mspec-1.5.5 spec/matchers/match_yaml_spec.rb