Skip to content

Commit

Permalink
Merge pull request #17 from vhbit/nimble61andSwift
Browse files Browse the repository at this point in the history
Updated to be compatible with Nimble 6.1 & newer Swift
  • Loading branch information
ashfurrow committed Apr 25, 2017
2 parents baa116e + 9a24a3f commit c8e97f3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
@@ -1,7 +1,8 @@
osx_image: xcode8.2
osx_image: xcode8.3
language: objective-c
podfile: Demo/Podfile
cache: cocoapods
before_install:
- gem install cocoapods -v '1.2.0.beta.1'
script: cd Demo ; set -o pipefail && xcodebuild -workspace 'Demo.xcworkspace' -scheme 'Demo' -configuration 'Debug' -sdk iphonesimulator -destination platform='iOS Simulator',OS='9.1',name='iPhone 6s' build test | xcpretty -c --test
- gem install cocoapods -v '1.2.1'
- pod repo update
script: cd Demo ; set -o pipefail && xcodebuild -workspace 'Demo.xcworkspace' -scheme 'Demo' -configuration 'Debug' -sdk iphonesimulator -destination platform='iOS Simulator',OS='10.3',name='iPhone 6s' build test | xcpretty -c --test
4 changes: 2 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Expand Up @@ -259,7 +259,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
8EC133641E3963166AA7C9C3 /* [CP] Embed Pods Frameworks */ = {
Expand Down Expand Up @@ -319,7 +319,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
16 changes: 8 additions & 8 deletions Demo/Podfile.lock
@@ -1,12 +1,12 @@
PODS:
- Nimble (5.1.1)
- Nimble (6.1.0)
- Quick (1.0.0)
- RxBlocking (3.0.1):
- RxSwift (~> 3.0)
- RxNimble (0.3.0):
- Nimble (~> 5.1.1)
- RxBlocking (~> 3.0.1)
- RxSwift (~> 3.0.1)
- RxNimble (2.0.0):
- Nimble (~> 6.0)
- RxBlocking (~> 3.0)
- RxSwift (~> 3.0)
- RxSwift (3.0.1)

DEPENDENCIES:
Expand All @@ -19,12 +19,12 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
Nimble: 415e3aa3267e7bc2c96b05fa814ddea7bb686a29
Nimble: c53e6903fee94041b90ded74f135820437d8bf59
Quick: 8024e4a47e6cc03a9d5245ef0948264fc6d27cff
RxBlocking: 5de082d09d1ab45b49173f309f1a97d6b50f34c4
RxNimble: 26fc0ad74d0030a9123a5fe85ab47a2b50ec8616
RxNimble: 50a9da5852b298b2ec632cb00b79fa20be9f31b8
RxSwift: af5680055c4ad04480189c52d28385b1029493a6

PODFILE CHECKSUM: 7405369509db0cbd242146add66181ab5ab0efb0

COCOAPODS: 1.2.0.beta.1
COCOAPODS: 1.2.1
4 changes: 2 additions & 2 deletions RxNimble.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RxNimble"
s.version = "1.0.0"
s.version = "2.0.0"
s.summary = "Nimble extensions that making unit testing with RxSwift easier 🎉"
s.description = <<-DESC
This library includes functions that make testing RxSwift projects easier with Nimble.
Expand All @@ -14,7 +14,7 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = "9.0"
s.source = { :git => "https://github.com/ashfurrow/RxNimble.git", :tag => s.version }
s.source_files = "Source/**/*.swift"
s.dependency "Nimble", "~> 5.1"
s.dependency "Nimble", "~> 6.0"
s.dependency "RxSwift", "~> 3.0"
s.dependency "RxBlocking", "~> 3.0"

Expand Down
36 changes: 22 additions & 14 deletions Source/RxNimble.swift
Expand Up @@ -3,32 +3,32 @@ import RxBlocking
import Nimble

// This is handy so we can write expect(o) == 1 instead of expect(o.value) == 1 or whatever.
public func equalFirst<T: Equatable, O: ObservableType where O.E == T>(expectedValue: T?) -> MatcherFunc<O> {
public func equalFirst<T: Equatable, O: ObservableType>(_ expectedValue: T?) -> MatcherFunc<O> where O.E == T {
return MatcherFunc { actualExpression, failureMessage in

failureMessage.postfixMessage = "equal <\(expectedValue)>"
failureMessage.postfixMessage = "equal <\(String(describing: expectedValue))>"
let actualValue = try actualExpression.evaluate()?.toBlocking().first()

let matches = actualValue == expectedValue
return matches
}
}

public func equalFirst<T: Equatable>(expectedValue: T?) -> MatcherFunc<Variable<T>> {
public func equalFirst<T: Equatable>(_ expectedValue: T?) -> MatcherFunc<Variable<T>> {
return MatcherFunc { actualExpression, failureMessage in

failureMessage.postfixMessage = "equal <\(expectedValue)>"
failureMessage.postfixMessage = "equal <\(String(describing: expectedValue))>"
let actualValue = try actualExpression.evaluate()?.value

let matches = actualValue == expectedValue && expectedValue != nil
return matches
}
}

public func equalFirst<T: Equatable, O: ObservableType where O.E == T?>(expectedValue: T?) -> MatcherFunc<O> {
public func equalFirst<T: Equatable, O: ObservableType>(_ expectedValue: T?) -> MatcherFunc<O> where O.E == T? {
return MatcherFunc { actualExpression, failureMessage in

failureMessage.postfixMessage = "equal <\(expectedValue)>"
failureMessage.postfixMessage = "equal <\(String(describing: expectedValue))>"
let actualValue = try actualExpression.evaluate()?.toBlocking().first()

switch actualValue {
Expand All @@ -40,10 +40,10 @@ public func equalFirst<T: Equatable, O: ObservableType where O.E == T?>(expected
}
}

public func equalFirst<T: Equatable>(expectedValue: T?) -> MatcherFunc<Variable<T?>> {
public func equalFirst<T: Equatable>(_ expectedValue: T?) -> MatcherFunc<Variable<T?>> {
return MatcherFunc { actualExpression, failureMessage in

failureMessage.postfixMessage = "equal <\(expectedValue)>"
failureMessage.postfixMessage = "equal <\(String(describing: expectedValue))>"
let actualValue = try actualExpression.evaluate()?.value

switch actualValue {
Expand All @@ -56,18 +56,26 @@ public func equalFirst<T: Equatable>(expectedValue: T?) -> MatcherFunc<Variable<
}

// Applies to Observables of T, which must conform to Equatable.
public func ==<T: Equatable, O: ObservableType where O.E == T>(lhs: Expectation<O>, rhs: T?) {
lhs.to(equalFirst(expectedValue: rhs))
public func ==<T: Equatable, O: ObservableType>(lhs: Expectation<O>, rhs: T?) where O.E == T {
lhs.to(equalFirst(rhs))
}

public func ==<T: Equatable>(lhs: Expectation<Variable<T>>, rhs: T?) {
lhs.to(equalFirst(expectedValue: rhs))
lhs.to(equalFirst(rhs))
}

public func ==<T: Equatable, O: ObservableType where O.E == Optional<T>>(lhs: Expectation<O>, rhs: T?) {
lhs.to(equalFirst(expectedValue: rhs))
public func ==<T: Equatable, O: ObservableType>(lhs: Expectation<O>, rhs: T?) where O.E == Optional<T> {
lhs.to(equalFirst(rhs))
}

public func ==<T: Equatable>(lhs: Expectation<Variable<T?>>, rhs: T?) {
lhs.to(equalFirst(expectedValue: rhs))
lhs.to(equalFirst(rhs))
}

public func ==<T: Equatable, O: Observable<T>>(lhs: Expectation<O>, rhs: T?) {
lhs.to(equalFirst(rhs))
}

public func ==<T: Equatable, O: Observable<Optional<T>>>(lhs: Expectation<O>, rhs: T?) {
lhs.to(equalFirst(rhs))
}

0 comments on commit c8e97f3

Please sign in to comment.