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

given "a user_group exists" do
  UserGroup.all.destroy!
  request(resource(:user_groups), :method => "POST", 
    :params => { :user_group => { :id => nil }})
end

describe "resource(:user_groups)" do
  describe "GET" do
    
    before(:each) do
      @response = request(resource(:user_groups))
    end
    
    it "responds successfully" do
      @response.should be_successful
    end

    it "contains a list of user_groups" do
      pending
      @response.should have_xpath("//ul")
    end
    
  end
  
  describe "GET", :given => "a user_group exists" do
    before(:each) do
      @response = request(resource(:user_groups))
    end
    
    it "has a list of user_groups" do
      pending
      @response.should have_xpath("//ul/li")
    end
  end
  
  describe "a successful POST" do
    before(:each) do
      UserGroup.all.destroy!
      @response = request(resource(:user_groups), :method => "POST", 
        :params => { :user_group => { :id => nil }})
    end
    
    it "redirects to resource(:user_groups)" do
      @response.should redirect_to(resource(UserGroup.first), :message => {:notice => "user_group was successfully created"})
    end
    
  end
end

describe "resource(@user_group)" do 
  describe "a successful DELETE", :given => "a user_group exists" do
     before(:each) do
       @response = request(resource(UserGroup.first), :method => "DELETE")
     end

     it "should redirect to the index action" do
       @response.should redirect_to(resource(:user_groups))
     end

   end
end

describe "resource(:user_groups, :new)" do
  before(:each) do
    @response = request(resource(:user_groups, :new))
  end
  
  it "responds successfully" do
    @response.should be_successful
  end
end

describe "resource(@user_group, :edit)", :given => "a user_group exists" do
  before(:each) do
    @response = request(resource(UserGroup.first, :edit))
  end
  
  it "responds successfully" do
    @response.should be_successful
  end
end

describe "resource(@user_group)", :given => "a user_group exists" do
  
  describe "GET" do
    before(:each) do
      @response = request(resource(UserGroup.first))
    end
  
    it "responds successfully" do
      @response.should be_successful
    end
  end
  
  describe "PUT" do
    before(:each) do
      @user_group = UserGroup.first
      @response = request(resource(@user_group), :method => "PUT", 
        :params => { :user_group => {:id => @user_group.id} })
    end
  
    it "redirect to the article show action" do
      @response.should redirect_to(resource(@user_group))
    end
  end
  
end

