<commit_before>require 'spec_helper'

module Stockers
  module Ctx
    module Player

      describe BuyFromMarket do
        context "valid player_portfolio and market_share" do
          let(:player) { Model::Player.make }
          let(:market) { Model::Market.make :market_shares => [ market_share ] }
          let(:market_share) { Model::MarketShare.make :price => 1.0 }
          let(:share_count) { 10 }

          let(:updated_portfolio) { player.portfolio  }

          before do
            # set correct balance to be able to pay for 
            # our shares
            player.account.increase_balance(10.0)
            player.save
            market.save

            # execute context, updating all objects
            BuyFromMarket.call(player, market_share, share_count) 
          end

          it { player.account.balance.should == 0.0 }
          it { market.account.balance.should == 10.0 }

          xit { updated_portfolio.portfolio_shares.count.should == 1 }
        end
      end

    end
  end
end<commit_msg>added it for portfolio_share account<commit_after>require 'spec_helper'

module Stockers
  module Ctx
    module Player

      describe BuyFromMarket do
        context "valid player_portfolio and market_share" do
          let(:player) { Model::Player.make }
          let(:market) { Model::Market.make :market_shares => [ market_share ] }
          let(:market_share) { Model::MarketShare.make :price => 1.0 }
          let(:share_count) { 10 }

          let(:updated_portfolio) { player.portfolio  }

          before do
            # set correct balance to be able to pay for 
            # our shares
            player.account.increase_balance(10.0)
            player.save
            market.save

            # execute context, updating all objects
            BuyFromMarket.call(player, market_share, share_count) 
          end

          it { player.account.balance.should == 0.0 }
          it { market.account.balance.should == 10.0 }

          it { updated_portfolio.portfolio_shares.count.should == 1 }
        end
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.08579599618684461, 'fraction_numerical': 0.012392755004766444, 'mean_word_length': 1.9605077574047955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1209025', 'n_tokens_mistral': 610, 'n_tokens_neox': 564, 'n_words': 143}