spec/lib/octonore/template_spec.rb in octonore-0.0.2 vs spec/lib/octonore/template_spec.rb in octonore-0.0.3

- old
+ new

@@ -16,14 +16,22 @@ describe "default instance attributes" do let(:template) { Octonore::Template.new('C') } + before { VCR.insert_cassette 'template', :record => :new_episodes } + + after { VCR.eject_cassette } + it "should have a name attribute" do template.should respond_to :name end + it "should have a source attribute" do + template.should respond_to :source + end + it "should have the right name" do template.name.should eq('C') end end @@ -34,37 +42,23 @@ before { VCR.insert_cassette 'template', :record => :new_episodes } after { VCR.eject_cassette } - it "should have a data method" do - template.should respond_to :data + it "should have an update method" do + template.should respond_to :update end - it "should parse the api response from JSON to Hash" do - template.data.should be_instance_of Hash + it "should be able to refresh data from Github" do + template.source = nil + template.update + template.source.should_not equal nil end - it "should get the right data" do - template.data["name"].should eq('C') + it "should raise an error if template doesn't exist" do + expect { + bad_template = Octonore::Template.new('invalid') }.to raise_error end - describe "caching" do - - before do - template.data - stub_request(:any, /api.github.com/).to_timeout - end - - it "must cache the data" do - template.data.should be_instance_of Hash - end - - it "must refresh the data if forced" do - lambda { template.data(true) }.should raise_error Timeout::Error - end - - end - end end