Created
January 15, 2011 12:56
-
-
Save paulca/780891 to your computer and use it in GitHub Desktop.
refactoring using let, subject and its
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe EasonBook do | |
describe ".load!" do | |
let(:house_at_riverton_item) { Item.find_by_barcode(9780330448444) } | |
let(:house_at_riverton) { EasonBook.find(9780330448444) } | |
before(:each) do | |
# set a category mapping | |
CategoryMapping.create!({:system_name => 'eason', | |
:system_code => "FAZ", | |
:category_id => 1}) | |
# loading EASONWWW.TXT from data_feed/test/today/eason/ | |
EasonBook.load! | |
end | |
describe "loaded book" do | |
subject { house_at_riverton } | |
it { should_not be_nil } | |
its(:title) { should == "House at Riverton" } | |
its(:author) { should == "Morton Kate"} | |
end | |
describe "loaded item" do | |
subject { house_at_riverton_item } | |
it { should have(1).category_memberships } | |
it "should set up category memberships" do | |
house_at_riverton_item.category_memberships.first.category_id.should == 1 | |
end | |
end | |
it "should load the items table" do | |
Item.count.should == 14 | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe EasonBook do | |
describe ".load!" do | |
let(:house_at_riverton_item) { Item.find_by_barcode(9780330448444) } | |
let(:house_at_riverton) { EasonBook.find(9780330448444) } | |
before(:each) do | |
# set a category mapping | |
CategoryMapping.create!({:system_name => 'eason', | |
:system_code => "FAZ", | |
:category_id => 1}) | |
# loading EASONWWW.TXT from data_feed/test/today/eason/ | |
EasonBook.load! | |
end | |
it "should load the eason_books table" do | |
house_at_riverton.should_not be_nil | |
end | |
it "should set the title" do | |
house_at_riverton.title.should == "House at Riverton" | |
end | |
it "should set the title" do | |
house_at_riverton.author.should == "Morton Kate" | |
end | |
it "should load the items table" do | |
Item.count.should == 14 | |
end | |
it "should set up category memberships" do | |
house_at_riverton_item.should have(1).category_memberships | |
house_at_riverton_item.category_memberships.first.category_id.should == 1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment