-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExpectThunk proposal #19
Conversation
Hey, this look great! I can see adding this as a sub-spec to making testing thunks easier. |
@mjarvis great feedback! I will incorporate and leave this open a tad longer in case there is any other feedback. Then I will close and make some refactors and reopen the PR. |
@jjgp you are welcome to leave the PR open and make changes in-place. We'll use a squash & merge to merge when its ready so any WIP commits will get squashed out. |
ReSwiftExpectThunk.podspec
Outdated
@@ -0,0 +1,29 @@ | |||
Pod::Spec.new do |spec| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would probably be better suited as a subspec rather than a separate pod inside the same repo.
See https://guides.cocoapods.org/syntax/podspec.html#subspec and also https://guides.cocoapods.org/syntax/podspec.html#default_subspecs for omitting this from the default.
I would create two subspecs Core
, and Expect
, then set Core
as the default_subspec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all for making it a subspec. I went with this route first to test it in a demo app. I will attempt a subspec next. Will report back on this.
Second thing I would be for adding a blurb in the README.md if that's cool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I got the subspec down. I have a test project here: https://github.com/jjgp/ExpectThunkDemo
I'd appreciate a sanity check since I did run into CocoaPods fun with a sigabrt at test time, however, I managed to resolve it.
Will work on the blurb in a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigabrt will show up if the test target is a child target in the Podfile:
target 'ExpectThunkDemo' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ExpectThunkDemo
pod 'ReSwiftThunk', :git => '[email protected]:jjgp/ReSwift-Thunk.git', :branch => 'expect-thunk-proposal'
target 'ExpectThunkDemoTests' do
inherit! :search_paths
pod 'ReSwiftThunk/ExpectThunk', :git => '[email protected]:jjgp/ReSwift-Thunk.git', :branch => 'expect-thunk-proposal'
end
end
|
Are there any news on this? I don't mean to be pushy, but we'd love to use this. Or, since this is 'just' for tests, do you think it's viable to target this branch in our project? |
Appreciate the interest! I’ll get back to it today. It should be near complete. After I double check I’ll ping for some reviews. Cheers, |
end | ||
|
||
spec.subspec "ExpectThunk" do |sp| | ||
sp.dependency "ReSwiftThunk/Core" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove this dependency, perhaps the inherited podfile example will work? I think it might be double-importing Core
when inherit
is included in the test target pod specifications.
Edit: Though, really, cocoapods dependency stuff should really handle this automatically...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thought, however, I wasn't able to get it to build this way. I'm attempting with CocoaPods 1.6.1. It may be an open issue with CocoaPods 7195 having child targets with subspecs. I'll follow up there, it does seem splitting the targets is the workaround in the Podfile at the moment.
I'm by no means a CocoaPods expert and almost never use it. Is it common to nest test targets inside the library/app target, or just an edge case? Totally missed this whole PR -- looks very cool! |
So CocoaPods defaults to nested targets on a
|
@jjgp Do you need any assistance to make things work? I'd very much like to integrate this rather sooner than later :) Also, what do you think about exposing a record of dispatched actions or similar, so one can write e.g. 3 |
Appreciate it @DivineDominion! I'm going to get a version of that The only thing I'm unsure about is CocoaPods. I tend to lean that breaking it into separate targets is acceptable for the end user. The issue sited on CocoaPods repo has been moved to a further milestone and perhaps I will have to contribute there. I'll report back by the end of the weekend. |
@DivineDominion currently I do not enforce the order of getStates within the dispatches/getStates chain. I haven't really thought about it, do you have an opinion of it? |
Looks like the following Podfile works as well:
Moral of the story is that if your using the Here is a branch where it works with the above Podfile sans Looking back at this comment, that is the distinction too: #19 (comment) I'm leaning more towards this is fine CocoaPods wise as the user has a few options and the framework linking seems to make sense. |
Do I read this correctly: this makes it impossible to use |
It seems if the test target is nested in the source target and it declares It could be related to this issue with CocoaPods as listed here: CocoaPods/CocoaPods#7195 Another way I’ve seen test helpers implemented is as a separate CocoaPod entirely such as RxTest. I would have to test, however, I’m inclined to think it wouldn’t have the issue seen here. |
Cool! I've tested the code in my app and really like the test helper. So if someone with more CocoaPods experience (maybe @mjarvis or @danielmartinprieto) accept the CocoaPods side of things, I think we should merge this 👍 |
I'm okay with a bit of awkwardness as long as:
|
I will update the README to make it more clear. Also looking to the future I’ll look into Swift Package Manager and it may make for a cleaner integration! |
Just updated the README to make it explicit to not nest the targets if using the subspec 😄 |
Great 👍 Could you add your addition to the top of the changelog? (Sorry I'm serving all this info piecemeal and asking you to always edit one more thing :)) |
Just added a blurb to the changlog. I hope I put it in the expected place 😄 |
Just noticed you enabled editing by maintainers, that's good :) I edited in some details. Thanks for all this! |
Hey all, this is just a thought that I've been exploring previously with ActionCreators and just open for discussion if it has a place somewhere in ReSwift. Here's and example of the previous rendition:
https://github.com/jjgp/ReddiX-iOS/blob/master/UNITests/Actions/ListingsActionsTests.swift
To make Thunks more testable especially when facing async things like mocking requests with MockingJay or OHHTTPStubs I created an
ExpectThunk
that is a subclass ofXCTestExpectation
.If this is to be then there would have to be a subspec or other podspec for consumers to be able to pod install into their tests.
Cheer,