OSDN Git Service

add Bowl.load(code)
authornomeu <nomeu@users.sourceforge.jp>
Wed, 6 Feb 2013 08:55:36 +0000 (17:55 +0900)
committernomeu <nomeu@users.sourceforge.jp>
Wed, 6 Feb 2013 08:55:36 +0000 (17:55 +0900)
lib/bowl.rb
spec/bowl_spec.rb

index ac1ecf8..f3fb43d 100644 (file)
@@ -54,6 +54,12 @@ class Bowl
     @code = code
   end
 
+  def self.load(code)
+    instance = new(code)
+    instance.load
+    instance
+  end
+
   def load
     @source = IO.read(src_path)
   end
index ab02ebe..bc2458c 100644 (file)
@@ -2,10 +2,7 @@ require 'lib/bowl'
 $KCODE = 'U'
 
 describe 'Bowl20110904', 'arc dl9588' do
-  subject { Bowl20110904.new('dl9588') }
-  before do
-    subject.load
-  end
+  subject { Bowl20110904.load('dl9588') }
   its "code" do
     should == 'dl9588'
   end
@@ -27,20 +24,14 @@ describe 'Bowl20110904', 'arc dl9588' do
 end
 
 describe 'Bowl20110904', 'arc dl9587' do
-  subject { Bowl20110904.new('dl9587') }
-  before do
-    subject.load
-  end
+  subject { Bowl20110904.load('dl9587') }
   it "should be locked" do
     should be_locked
   end
 end
 
 describe 'Bowl20110904', 'arc dl671' do
-  subject { Bowl20110904.new('dl671') }
-  before do
-    subject.load
-  end
+  subject { Bowl20110904.load('dl671') }
   its "code" do
     should == 'dl671'
   end
@@ -62,20 +53,14 @@ describe 'Bowl20110904', 'arc dl671' do
 end
 
 describe 'Bowl', 'arc dl140' do
-  subject { Bowl.new('dl140') }
-  before do
-    subject.load
-  end
+  subject { Bowl.load('dl140') }
   it "should be removed" do
     should be_removed
   end
 end
 
 describe 'Bowl', 'arc dl391' do
-  subject { Bowl.new('dl391') }
-  before do
-    subject.load
-  end
+  subject { Bowl.load('dl391') }
   it "should not be removed" do
     should_not be_removed
   end
@@ -100,10 +85,7 @@ describe 'Bowl', 'arc dl391' do
 end
 
 describe 'Bowl', 'arc dl392' do
-  subject { Bowl.new('dl392') }
-  before do
-    subject.load
-  end
+  subject { Bowl.load('dl392') }
   it "should not be removed" do
     should_not be_removed
   end