Sha256: 5c3d1e8dbbb13fb14af2c5c103399897a3a788ce25f2fee513eba9c9909198f9

Contents?: true

Size: 928 Bytes

Versions: 9

Compression:

Stored size: 928 Bytes

Contents

require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'

describe Object, "#encode" do
  it "raises an ArgumentError if the str parameter is not a String" do
    lambda { encode(Object.new, "utf-8") }.should raise_error(ArgumentError)
  end

  it "raises an ArgumentError if the encoding parameter is not a String" do
    lambda { encode("some str", Object.new) }.should raise_error(ArgumentError)
  end

  it "calls #force_encoding if the :encoding feature is enabled" do
    FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(true)
    str = "some text"
    str.should_receive(:force_encoding).with("utf-8")
    encode(str, "utf-8")
  end

  it "does not call #force_encoding if the :encoding feature is not enabled" do
    FeatureGuard.should_receive(:enabled?).with(:encoding).and_return(false)
    str = "some text"
    str.should_not_receive(:force_encoding)
    encode(str, "utf-8")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/helpers/encode_spec.rb
mspec-1.9.0 spec/helpers/encode_spec.rb
mspec-1.8.0 spec/helpers/encode_spec.rb
mspec-1.7.0 spec/helpers/encode_spec.rb
mspec-1.6.0 spec/helpers/encode_spec.rb
mspec-1.5.21 spec/helpers/encode_spec.rb
mspec-1.5.20 spec/helpers/encode_spec.rb
mspec-1.5.19 spec/helpers/encode_spec.rb
mspec-1.5.18 spec/helpers/encode_spec.rb