Sha256: 1f81a2a502cedbe9a07a2e45dd22d0e00d1216059616445890f62cf9ac2da7d6

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")

describe "Join" do
  before :all do
    @source_a = TestSource.source :a
    @source_b = TestSource.source :b
    @source_c = TestSource.source :c
  end
  
  describe "joining" do
    before do
      @joined = Smoke.join(:a, :b)
    end
    
    it "should be named in a_b_joined" do
      Smoke[:a_b_joined].should be_an_instance_of(Smoke::Source::Join)
    end
    
    it "should contain items from sources a and b" do
      Smoke[:a_b_joined].output.size.should == (@source_a.output.size + @source_b.output.size)
    end
    
    it "should accept a block" do
      lambda { Smoke.join(:a, :b, :c, Proc.new {}) }.should_not raise_error
    end
    
    it "should allow sorting" do
      Smoke[:a_b_joined].should respond_to(:sort)
    end
    
    it "should allow changes to output" do
      Smoke[:a_b_joined].should respond_to(:output)
    end
        
    describe "renaming" do
      it "should allow renaming" do
        Smoke[:a_b_joined].should respond_to(:rename)
      end
      
      it "should be renamed" do
        Smoke.rename(:a_b_joined => :rename_spec)
        Smoke[:rename_spec].should be_an_instance_of(Smoke::Source::Join)
      end
      
      it "should change its name property after being renamed" do
        Smoke[:rename_spec].name.should == "rename_spec"
      end
    end
    
    describe "dispatching" do
      before :all do
        FakeWeb.register_uri("http://photos.tld", :response => File.join(SPEC_DIR, 'supports', 'flickr-photo.json'))

        Smoke.data(:should_dispatch) do
          url "http://photos.tld"
          path :photos, :photo
        end
      end
      
      it "should call dispatch for its children" do
        Smoke[:should_dispatch].should_receive(:dispatch)
        Smoke.join(:a, :should_dispatch).output
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
benschwarz-smoke-0.3.5 spec/smoke/source/join_spec.rb
benschwarz-smoke-0.3.6 spec/smoke/source/join_spec.rb
benschwarz-smoke-0.3.7 spec/smoke/source/join_spec.rb
benschwarz-smoke-0.3.9 spec/smoke/source/join_spec.rb