spec/galakei/request_spec.rb in galakei-0.8.0 vs spec/galakei/request_spec.rb in galakei-0.8.1
- old
+ new
@@ -1,68 +1,73 @@
require 'spec_helper'
%w[docomo au softbank].each do |carrier|
shared_examples_for "non-#{carrier} devices" do
it("should not be #{carrier}?") do
- @request.should_not send("be_#{carrier}")
+ should_not send("be_#{carrier}")
end
end
shared_examples_for "#{carrier} devices" do
it("should be #{carrier}?") do
- @request.should send("be_#{carrier}")
+ should send("be_#{carrier}")
end
- it("should be galakei") { @request.should be_galakei }
+ it("should be galakei") { should be_galakei }
end
end
describe Galakei::Request do
describe "from Firefox" do
- before { @request = Rack::Request.new(env_for_firefox) }
+ subject { Rack::Request.new(env_for_firefox) }
it_should_behave_like "non-au devices"
it_should_behave_like "non-docomo devices"
it_should_behave_like "non-softbank devices"
- it("should not be galakei") { @request.should_not be_galakei }
- it { @request.galakei_uid.should be_nil }
+ it("should not be galakei") { should_not be_galakei }
+ it { subject.galakei_uid.should be_nil }
end
describe "from Docomo SH-06A" do
- before { @request = Rack::Request.new(env_for_docomo_1_0) }
+ subject { Rack::Request.new(env_for_docomo_1_0) }
it_should_behave_like "docomo devices"
it_should_behave_like "non-au devices"
it_should_behave_like "non-softbank devices"
- it { @request.galakei_uid.should == "0000002" }
+ it { subject.galakei_uid.should == "0000002" }
end
describe "from AU W51SH" do
- before { @request = Rack::Request.new(env_for_au_6_2) }
+ subject { Rack::Request.new(env_for_au_6_2) }
it_should_behave_like "non-docomo devices"
it_should_behave_like "non-softbank devices"
it_should_behave_like "au devices"
- it("should be browser 6") { @request.should be_au_browser_6 }
- it { @request.galakei_uid.should == "1234567890_ve.ezweb.ne.jp" }
+ it("should be browser 6") { should be_au_browser_6 }
+ it { subject.galakei_uid.should == "1234567890_ve.ezweb.ne.jp" }
end
describe "from AU W54SH" do
- before { @request = Rack::Request.new(env_for_au_7_2) }
+ subject { Rack::Request.new(env_for_au_7_2) }
it_should_behave_like "non-docomo devices"
it_should_behave_like "non-softbank devices"
it_should_behave_like "au devices"
- it("should not be browser 6") { @request.should_not be_au_browser_6 }
- it { @request.galakei_uid.should == "1234567890_ve.ezweb.ne.jp" }
+ it("should not be browser 6") { should_not be_au_browser_6 }
+ it { subject.galakei_uid.should == "1234567890_ve.ezweb.ne.jp" }
end
describe "from Vodafone" do
- before { @request = Rack::Request.new(env_for_vodafone) }
+ subject { Rack::Request.new(env_for_vodafone) }
it_should_behave_like "non-au devices"
it_should_behave_like "non-docomo devices"
it_should_behave_like "softbank devices"
- it { @request.galakei_uid.should == "11111111msimmsim" }
+ it { subject.galakei_uid.should == "11111111msimmsim" }
end
describe "from Softbank 709SC" do
- before { @request = Rack::Request.new(env_for_softbank) }
+ subject { Rack::Request.new(env_for_softbank) }
it_should_behave_like "non-au devices"
it_should_behave_like "non-docomo devices"
it_should_behave_like "softbank devices"
- it { @request.galakei_uid.should == "11111111msimmsim" }
+ it { subject.galakei_uid.should == "11111111msimmsim" }
+ end
+
+ describe "from Docomo HT-03A (android)" do
+ subject { Rack::Request.new("HTTP_USER_AGENT" => "Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; Docomo HT-03A Build/DRD08) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1") }
+ it { should_not be_docomo }
end
end