Sha256: 8fcf6e8a4849723e636a07245d945f3b206601ae1163b37d488ab9598032620f

Contents?: true

Size: 1.63 KB

Versions: 16

Compression:

Stored size: 1.63 KB

Contents

# encoding: UTF-8
require 'spec_helper'

shared_examples_for "convertable zenkaku" do |body|
  it 'should be converted' do
    @response.stub!(:body).and_return(body)
    @response.should_receive(:body=).with(/メインガギ漢字ひらがな。/)
    @filter.filter
  end
end

shared_examples_for "unconvertable zenkaku" do |body|
  it 'should not be converted' do
    @response.stub!(:body).and_return(body)
    @response.should_receive(:body=).with(/メインガギ漢字ひらがな。/)
    @filter.filter
  end
end

describe Galakei::Filter::Hankaku do
  before do
    @filter = described_class.new
    @filter.controller = mock("controller")
    @request = mock("request")
    @response = mock("response")
    @filter.controller.stub!(:request).and_return(@request)
    @filter.controller.stub!(:response).and_return(@response)
  end

  it_should_behave_like "convertable zenkaku", "<div id='hankaku'>メインガギ漢字ひらがな。</div>"
  it_should_behave_like "unconvertable zenkaku", "<textarea id='hankaku'>メインガギ漢字ひらがな。</textarea>"
  it_should_behave_like "unconvertable zenkaku", "<input id='hankaku' value='メインガギ漢字ひらがな。'></input>"
  it_should_behave_like "convertable zenkaku", "<input type='submit' id='hankaku' value='メインガギ漢字ひらがな。'></input>"
  it_should_behave_like "convertable zenkaku", "<input type='button' id='hankaku' value='メインガギ漢字ひらがな。'></input>"

  it 'should convert long vowel' do
    @response.stub!(:body).and_return("プロフィール")
    @response.should_receive(:body=).with(/プロフィール/)
    @filter.filter
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
galakei-0.15.2 spec/galakei/filter/hankaku_spec.rb
galakei-0.15.1 spec/galakei/filter/hankaku_spec.rb
galakei-0.15.0 spec/galakei/filter/hankaku_spec.rb
galakei-0.14.4 spec/galakei/filter/hankaku_spec.rb
galakei-0.14.3 spec/galakei/filter/hankaku_spec.rb
galakei-0.14.2 spec/galakei/filter/hankaku_spec.rb
galakei-0.14.1 spec/galakei/filter/hankaku_spec.rb
galakei-0.14.0 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.7 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.6 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.5 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.4 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.3 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.2 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.1 spec/galakei/filter/hankaku_spec.rb
galakei-0.13.0 spec/galakei/filter/hankaku_spec.rb