<commit_before># Spurious

[![Version](https://img.shields.io/cocoapods/v/Spurious.svg?style=flat)](http://cocoapods.org/pods/Spurious)
[![License](https://img.shields.io/cocoapods/l/Spurious.svg?style=flat)](http://cocoapods.org/pods/Spurious)
[![Platform](https://img.shields.io/cocoapods/p/Spurious.svg?style=flat)](http://cocoapods.org/pods/Spurious)

Why so spurious? Because sometimes the real thing is just too risky.    

```
databaseSaver.save()        // real records, yikes!
requestMaker.makeRequest()  // pound that server!
rainMaker.makeRain()        // goodness no!
```

Spurious makes it easier to stub and fake object dependencies when testing. It is essentially a message forwarding utility.  

## Usage

Given

```Swift
class FakeRainMaker: RainMaker, SpuriousTestable {
    func makeRain() -> String {
        return callSpurious() // will auto-register a stub identified by String "makeRain()"
    }
}
```

When

```Swift
rainMaker.stub("makeRain()", yield: "Chocolate rain")
```

Fantastic. And then (using Quick matchers):

```Swift
precipitation()
expect(rainMaker.wasCalled("makeRain()")).to(beTruthy())
```

Using Swift 2 ability to provide default implementations for protocols, an instance of a particular class or protocol can be declared as also implementing protocol SpuriousTestable, and will automatically gain the ability to register stubs and verify function calls through an instance of Spurious.  

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements
Swift 2.0

## Installation

Spurious is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "Spurious"
```

## Author
<commit_msg>Update README for wasCalled(_: with:)<commit_after># Spurious

[![Version](https://img.shields.io/cocoapods/v/Spurious.svg?style=flat)](http://cocoapods.org/pods/Spurious)
[![License](https://img.shields.io/cocoapods/l/Spurious.svg?style=flat)](http://cocoapods.org/pods/Spurious)
[![Platform](https://img.shields.io/cocoapods/p/Spurious.svg?style=flat)](http://cocoapods.org/pods/Spurious)

Why so spurious? Because sometimes the real thing is just too risky.    

```
databaseSaver.save()        // real records, yikes!
requestMaker.makeRequest()  // pound that server!
rainMaker.makeRain()        // goodness no!
```

Spurious makes it easier to stub and fake object dependencies when testing.  

## Usage

Given

```Swift
class FakeRainMaker: RainMaker, SpuriousTestable {
    func makeRain() -> String {
        // will register any calls with Spurious, identified by String "makeRain()"
        return callSpurious() 
    }
    
    func rainfallTotals(cityName: String, month: Int) -> Int {
        // will register any calls with Spurious, identified by String "rainfallTotals(_:month:)"
        return callSpurious([cityName, month])
    }
}
```

When

```Swift
rainMaker = FakeRainMaker()
subject.rainMaker = rainMaker
rainMaker.stub("makeRain()", yield: "Chocolate rain")
```

Fantastic. And then (using Quick matchers):

```Swift
let rain = subject.precipitation()
expect(rainMaker.wasCalled("makeRain()")).to(beTruthy())
expect(rain) == "Chocolate rain"
```

Using Swift 2 ability to provide default implementations for protocols, an instance of a particular class or protocol can be declared as also implementing protocol SpuriousTestable, and will automatically gain the ability to register stubs and verify function calls through an instance of Spurious.  

<b>More...</b>

```Swift
rainMaker.stub("rainfallTotals(_:month:)", yield: 5555)
let totalInches = subject.getLocalRainLastJanuary()

expect(rainMaker.wasCalled("rainfallTotals(_:month:)", <-"UserCity", <-1)) == true
// can also be written as:
expect(rainMaker.wasCalled("rainfallTotals(_:month:)", with("UserCity"), and(1))) == true

expect(totalInches) == 5555
```

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements
Swift 2.0

## Installation

Spurious is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "Spurious"
```

## Author

{'fraction_non_alphanumeric': 0.12989788648777012, 'fraction_numerical': 0.00379957254808834, 'mean_word_length': 4.691891891891892, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 6, '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': '3450429', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1288, 'n_words': 384}