Sha256: 1e4a97da4051d3f066148b9fc1946ef96704d7112644d91724a3035839b60458

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Culerity, 'run_rails' do
  before(:each) do
    Kernel.stub!(:sleep)
    IO.stub!(:popen)
    Culerity.stub!(:fork).and_yield.and_return(3200)
    Culerity.stub!(:exec)
    Culerity.stub!(:sleep)
    [$stdin, $stdout, $stderr].each{|io| io.stub(:reopen)}
  end
  
  it "should not run rails if we are not using rails" do
    Culerity.should_not_receive(:exec)
    Culerity.run_rails :port => 4000, :environment => 'culerity'
  end
  
  it "should run rails with default values" do
    Rails ||= stub(:rails, :root => Dir.pwd)
    Culerity.should_receive(:exec).with("script/server -e culerity -p 3001")
    Culerity.run_rails
  end
  
  it "should run rails with the given values" do
    Rails ||= stub(:rails, :root => Dir.pwd)
    Culerity.should_receive(:exec).with("script/server -e culerity -p 4000")
    Culerity.run_rails :port => 4000, :environment => 'culerity'
  end

  it "should change into the rails root directory" do
    Rails ||= stub(:rails, :root => Dir.pwd)
    Dir.should_receive(:chdir).with(Dir.pwd)
    Culerity.run_rails :port => 4000, :environment => 'culerity'
  end
  
  it "should wait for the server to start up" do
    Rails ||= stub(:rails, :root => Dir.pwd)
    Culerity.should_receive(:sleep)
    Culerity.run_rails :port => 4000, :environment => 'culerity'
  end
  
  it "should reopen the i/o channels to /dev/null" do
    Rails ||= stub(:rails, :root => Dir.pwd)
    [$stdin, $stdout, $stderr].each{|io| io.should_receive(:reopen).with("/dev/null")}
    Culerity.run_rails :port => 4000, :environment => 'culerity'
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
culerity-0.2.10 spec/culerity_spec.rb
fletcherm-culerity-0.2.9 spec/culerity_spec.rb
culerity-0.2.9 spec/culerity_spec.rb
fletcherm-culerity-0.2.8 spec/culerity_spec.rb
culerity-0.2.8 spec/culerity_spec.rb