From 0ef61c062fef0bbf8d6de81bc4f8018b9584f6fa Mon Sep 17 00:00:00 2001 From: Stormwind Date: Thu, 10 Jan 2013 20:18:03 +0100 Subject: Rename Zero::Request::AcceptType spec folder --- spec/unit/zero/request/accept_type/each_spec.rb | 10 ++++++ .../zero/request/accept_type/preferred_spec.rb | 41 ++++++++++++++++++++++ spec/unit/zero/request/accepttype/each_spec.rb | 10 ------ .../unit/zero/request/accepttype/preferred_spec.rb | 41 ---------------------- 4 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 spec/unit/zero/request/accept_type/each_spec.rb create mode 100644 spec/unit/zero/request/accept_type/preferred_spec.rb delete mode 100644 spec/unit/zero/request/accepttype/each_spec.rb delete mode 100644 spec/unit/zero/request/accepttype/preferred_spec.rb diff --git a/spec/unit/zero/request/accept_type/each_spec.rb b/spec/unit/zero/request/accept_type/each_spec.rb new file mode 100644 index 0000000..964a63e --- /dev/null +++ b/spec/unit/zero/request/accept_type/each_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe Zero::Request::AcceptType, '#each' do + subject { Zero::Request::AcceptType.new(types) } + let(:html) { 'text/html' } + let(:json) { 'application/json' } + let(:types) { [html, json].join(',') } + + specify { expect {|b| subject.each(&b) }.to yield_successive_args(html, json) } +end diff --git a/spec/unit/zero/request/accept_type/preferred_spec.rb b/spec/unit/zero/request/accept_type/preferred_spec.rb new file mode 100644 index 0000000..daeba86 --- /dev/null +++ b/spec/unit/zero/request/accept_type/preferred_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe Zero::Request::AcceptType, '#preferred' do + subject { Zero::Request::AcceptType } + let(:html) { 'text/html' } + let(:json) { 'application/json' } + let(:foo) { 'text/foo' } + let(:lower_quality) { foo + ';q=0.5' } + let(:default) { '*/*;q=0.1' } + let(:option) { [foo + ';b=23', html].join(',') } + let(:simple_accept) { [html, json].join(',') } + let(:quality_accept) { [html, lower_quality, default].join(',') } + let(:random_accept) { [lower_quality, default, html].join(',') } + let(:lower_accept) { [lower_quality, default].join(',') } + + context 'without mapping' do + it { subject.new(html).preferred.should == html } + it { subject.new(json).preferred.should == json } + it { subject.new(option).preferred.should == foo } + it { subject.new(simple_accept).preferred.should == html } + it { subject.new(quality_accept).preferred.should == html } + it { subject.new(random_accept).preferred.should == html } + it { subject.new(lower_accept).preferred.should == foo } + it { subject.new(nil).preferred.should == '*/*' } + it { subject.new('').preferred.should == '*/*' } + it { subject.new('text / html').preferred.should == html } + it { subject.new("#{html};q=0.9,#{json}").preferred.should == json } + end + +# context 'with mapping' do +# before :all do +# Zero::Request::Accept.map = {'text/html' => 'html'} +# end +# +# after :all do +# Zero::Request::Accept.map = {} +# end +# +# it { subject.new(html).preferred.should == 'html' } +# end +end diff --git a/spec/unit/zero/request/accepttype/each_spec.rb b/spec/unit/zero/request/accepttype/each_spec.rb deleted file mode 100644 index 964a63e..0000000 --- a/spec/unit/zero/request/accepttype/each_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'spec_helper' - -describe Zero::Request::AcceptType, '#each' do - subject { Zero::Request::AcceptType.new(types) } - let(:html) { 'text/html' } - let(:json) { 'application/json' } - let(:types) { [html, json].join(',') } - - specify { expect {|b| subject.each(&b) }.to yield_successive_args(html, json) } -end diff --git a/spec/unit/zero/request/accepttype/preferred_spec.rb b/spec/unit/zero/request/accepttype/preferred_spec.rb deleted file mode 100644 index daeba86..0000000 --- a/spec/unit/zero/request/accepttype/preferred_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe Zero::Request::AcceptType, '#preferred' do - subject { Zero::Request::AcceptType } - let(:html) { 'text/html' } - let(:json) { 'application/json' } - let(:foo) { 'text/foo' } - let(:lower_quality) { foo + ';q=0.5' } - let(:default) { '*/*;q=0.1' } - let(:option) { [foo + ';b=23', html].join(',') } - let(:simple_accept) { [html, json].join(',') } - let(:quality_accept) { [html, lower_quality, default].join(',') } - let(:random_accept) { [lower_quality, default, html].join(',') } - let(:lower_accept) { [lower_quality, default].join(',') } - - context 'without mapping' do - it { subject.new(html).preferred.should == html } - it { subject.new(json).preferred.should == json } - it { subject.new(option).preferred.should == foo } - it { subject.new(simple_accept).preferred.should == html } - it { subject.new(quality_accept).preferred.should == html } - it { subject.new(random_accept).preferred.should == html } - it { subject.new(lower_accept).preferred.should == foo } - it { subject.new(nil).preferred.should == '*/*' } - it { subject.new('').preferred.should == '*/*' } - it { subject.new('text / html').preferred.should == html } - it { subject.new("#{html};q=0.9,#{json}").preferred.should == json } - end - -# context 'with mapping' do -# before :all do -# Zero::Request::Accept.map = {'text/html' => 'html'} -# end -# -# after :all do -# Zero::Request::Accept.map = {} -# end -# -# it { subject.new(html).preferred.should == 'html' } -# end -end -- cgit v1.2.3-70-g09d2