Sha256: 24f33405a1a2c85a972806cca644b58261fd0d0df1a0b5778da98dc01e999acc

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

require "rspec"

describe "Medea Framework" do
  it "should install templates if they aren't there" do
    resp = mock("Response").as_null_object
    RestClient.stub(:get).and_return resp
    RestClient.stub(:post).and_return resp
    resp.stub(:code).and_return 404
    resp.stub(:headers).and_return({})

    RestClient.should_receive(:post)
    Medea::setup_templates
  end

  it "should install templates if the template version is newer" do
    resp = mock("Response").as_null_object
    RestClient.stub(:get).and_return resp
    RestClient.stub(:post).and_return resp
    resp.stub(:code).and_return 200
    resp.stub(:headers).and_return({:http_x_version => "0.1.0"}) 

    RestClient.should_receive(:post)
    Medea::setup_templates
  end

  it "should not install templates if they are up to date" do
    resp = mock("Response").as_null_object
    RestClient.stub(:get).and_return resp
    RestClient.stub(:post).and_return resp
    resp.stub(:code).and_return 200
    resp.stub(:headers).and_return({:http_x_version => Medea::TEMPLATE_VERSION})

    RestClient.should_not_receive(:post)
    Medea::setup_templates
  end

  it "should raise an error if the remote version is newer" do
    resp = mock("Response").as_null_object
    RestClient.stub(:get).and_return resp
    RestClient.stub(:post).and_return resp
    resp.stub(:code).and_return 200
    #version 999.0.0 is pretty much guaranteed to always be a newer version
    resp.stub(:headers).and_return({:http_x_version => "999.0.0"})

    RestClient.should_not_receive(:post)
    expect{Medea::setup_templates}.to raise_error(RuntimeError)
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
medea-0.7.2 spec/medea_spec.rb
medea-0.7.1 spec/medea_spec.rb
medea-0.7.0 spec/medea_spec.rb
medea-0.6.9 spec/medea_spec.rb
medea-0.6.8 spec/medea_spec.rb
medea-0.6.7 spec/medea_spec.rb
medea-0.6.6 spec/medea_spec.rb
medea-0.6.5 spec/medea_spec.rb
medea-0.6.4 spec/medea_spec.rb
medea-0.6.3 spec/medea_spec.rb
medea-0.6.1 spec/medea_spec.rb
medea-0.6.0 spec/medea_spec.rb
medea-0.5.4 spec/medea_spec.rb
medea-0.5.3 spec/medea_spec.rb
medea-0.5.2 spec/medea_spec.rb
medea-0.5.1 spec/medea_spec.rb
medea-0.5.0 spec/medea_spec.rb
medea-0.4.0 spec/medea_spec.rb