require_relative 'spec_helper'

describe WeaselDiesel do

  before :all do
    @service = WSList.find(:get, '/services/test.xml')
    @service.should_not be_nil
  end

  it "should have an url" do
    # dummy test since that's how we found the service, but oh well
    @service.url.should == '/services/test.xml'
  end

  it "should have some http verbs defined" do
    @service.verb.should == :get
  end

  it "should have supported formats defined" do
    @service.formats.should == [:xml, :json]
  end

  it "should have params info" do
    @service.params.should be_an_instance_of(WeaselDiesel::Params)
  end

  it "should have direct access to the required params" do
    @service.required_rules.should == @service.params.list_required
  end

  it "should have direct access to the optional params" do
    @service.optional_rules.should == @service.params.list_optional
  end

  it "should have direct access to the nested params" do
    @service.nested_params.should == @service.params.namespaced_params
  end

  it "should have some documentation" do
    @service.doc.should be_an_instance_of(WeaselDiesel::Documentation)
  end

  it "should store urls with a leading slash" do
    service = WeaselDiesel.new("/foo")
    service.url.should == "/foo"
    service.url.should == WeaselDiesel.new("foo").url
    WeaselDiesel.new("foo").url.should_not == WeaselDiesel.new("foo/").url

    root = WeaselDiesel.new("/")
    root.url.should == "/"
  end

end
