Created
          November 11, 2016 17:48 
        
      - 
      
- 
        Save bhserna/d15fc6dbaaf13ef7cf5bf3ec89440c84 to your computer and use it in GitHub Desktop. 
    5 Rules - Test through module functions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | it "(when project is refunded)" do | |
| portfolio = portfolio_on(Date.new(2018, 2, 4)) | |
| date = next_payment_date_for_project( | |
| portfolio, | |
| refunded_project, | |
| formatter: ->(date) { "My date: #{date}" }, | |
| not_executed_message: "No se ha ejecutado", | |
| no_payments_left_message: "No hay más pagos", | |
| project_refunded_message: "No aplica" | |
| ) | |
| expect(date).to eq "No aplica" | |
| end | |
| def next_payment_date_for_project(portfolio, project, options = {}) | |
| portfolio. | |
| projects_with_investment. | |
| detect { |p| p.id == project.id }. | |
| next_payment_date(options) | |
| end | |
| def portfolio_on(current_date) | |
| portfolio_with([project_one, project_two, not_executed_project, refunded_project], current_date) | |
| end | |
| def portfolio_with(projects, current_date) | |
| projects_finder = FakeProjectFinder.new(*projects) | |
| UserPortfolio.portfolio_for_user(user, current_date, projects_finder) | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment