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

describe MembersController do
  describe "routing" do
    # it "has correct #show parameters" do
    #   route_for(:controller => "members", :action => "show", :id => '1234').should == '/members/1234'
    # end
    # 
    # it "allows /members/:name" do
    #   route_for(:controller => "members", :action => "show", :id => 'Tsigo').should == '/members/Tsigo'
    # end
  end
end<commit_msg>Our first passing set of MembersController specs!<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe MembersController, "POST /members" do
  before(:each) do
    @mock = mock_model(Member, :to_param => '1', :save => true)
    @plan = Member.plan.stringify_keys!
  end
  
  def do_post
    post :create, :member => @plan
  end
  
  it "should create a new member from params" do
    Member.should_receive(:new).with(@plan).and_return(@mock)
    do_post
  end
  
  describe "when successful" do
    before(:each) do
      Member.should_receive(:new).with(@plan).and_return(@mock)
    end
    
    it "should add a flash success message" do
      do_post
      flash[:success].should == 'Member was successfully created.'
    end
    
    it "should redirect to the new member" do
      do_post
      response.should redirect_to(member_url('1'))
    end
  end
  
  describe "when unsuccessful" do
    before(:each) do
      @mock = mock_model(Member, :save => false)
      Member.stub!(:new).and_return(@mock)
    end
    
    it "should render template :new" do
      do_post
      response.should render_template(:new)
    end
  end
end
{'fraction_non_alphanumeric': 0.12953995157384987, 'fraction_numerical': 0.006053268765133172, 'mean_word_length': 3.1325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2968856', 'n_tokens_mistral': 528, 'n_tokens_neox': 514, 'n_words': 140}