Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Giving publicly readable properties for ratings to views #52

Merged
merged 10 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
osx_image: xcode8.1
osx_image: xcode9.1
language: objective-c

cache:
- bundler
- cocoapods

before_install:
- export IOS_SIMULATOR_UDID=`instruments -s devices | grep "iPhone SE (10.1" | awk -F '[ ]' '{print $4}' | awk -F '[\[]' '{print $2}' | sed 's/.$//'`
- export IOS_SIMULATOR_UDID=`instruments -s devices | grep "iPhone SE (11.1" | awk -F '[ ]' '{print $4}' | awk -F '[\[]' '{print $2}' | sed 's/.$//'`
- echo $IOS_SIMULATOR_UDID
- open -a "simulator" --args -CurrentDeviceUDID $IOS_SIMULATOR_UDID

install:
- bundle install
- bundle exec pod repo update --silent
- bundle exec pod install --project-directory=Example
- bundle exec pod install --repo-update --project-directory=Example

script:
- set -o pipefail && travis_retry xcodebuild test -workspace Example/Trustbadge.xcworkspace -scheme Trustbadge_Example -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone SE' -derivedDataPath ${TRAVIS_BUILD_DIR}/myDerivedData ONLY_ACTIVE_ARCH=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -c
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Trustbadge

## Version 0.8.3

* Fixed an issues with a method that is not available before iOS 9.
* Redesigned the various view classes so their rating related data is now readable from outside the classes.

## Version 0.8.2

* Fixed a bug that could lead to a crash when a shop without any reviews tried to load a TRSShopRatingView or a TRSShopGradeView. From now on "zero grade" views are possible.
Expand Down
15 changes: 8 additions & 7 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ platform :ios, '8.0'
use_frameworks!

target 'Trustbadge_Example' do
pod "Trustbadge", :path => "../"
pod 'Trustbadge', :path => '../'
end

target 'Trustbadge_Tests' do
pod "Trustbadge", :path => "../"
pod 'Trustbadge', :path => '../'

pod 'Expecta', '~> 1.0.2'
pod 'Expecta', '~> 1.0.6'
pod 'Expecta+Snapshots', '~> 3.1.1'
pod 'FBSnapshotTestCase', '~> 2.1.1'
pod 'FBSnapshotTestCase', '~> 2.1.4'
pod 'OCMock', '~> 3.4'
pod 'OHHTTPStubs', '~> 5.2.3'
pod 'OHHTTPStubs/HTTPMessage', '~> 5.2.3'
pod 'Specta', '~> 1.0.6'
pod 'OHHTTPStubs', '~> 6.1.0'
pod 'OHHTTPStubs/HTTPMessage', '~> 6.1.0'
pod 'Specta', '~> 1.0.7'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
60 changes: 30 additions & 30 deletions Example/Tests/TRSShopGradeViewSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ @interface TRSShopGradeView (PrivateTests)
@property (nonatomic, strong) UILabel *gradeAsTextLabel;
@property (nonatomic, strong) UILabel *gradeAsNumbersLabel;

@property (nonatomic, strong) NSNumber *gradeNumber;
@property (nonatomic, strong) NSNumber *reviewCount;
@property (nonatomic, copy) NSString *gradeText;
@property (nonatomic, strong) NSNumber *overallMark;
@property (nonatomic, strong) NSNumber *totalReviewCount;
@property (nonatomic, copy) NSString *overallMarkDescription;
@property (nonatomic, copy) NSString *targetMarketISO3;
@property (nonatomic, copy) NSString *languageISO2;

Expand Down Expand Up @@ -149,16 +149,16 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beKindOf([NSNumber class]);
expect(testView.reviewCount).to.beKindOf([NSNumber class]);
expect(testView.overallMark).to.beKindOf([NSNumber class]);
expect(testView.totalReviewCount).to.beKindOf([NSNumber class]);
expect(testView.targetMarketISO3).to.beKindOf([NSString class]);
expect(testView.gradeText).to.beKindOf([NSString class]);
expect(testView.overallMarkDescription).to.beKindOf([NSString class]);
expect(testView.languageISO2).to.beKindOf([NSString class]);
// this data is defined in the file shopGrade.data!
expect(testView.gradeNumber).to.equal(@4.87);
expect(testView.reviewCount).to.equal(@5);
expect(testView.overallMark).to.equal(@4.87);
expect(testView.totalReviewCount).to.equal(@5);
expect(testView.targetMarketISO3).to.equal(@"CHE");
expect(testView.gradeText).to.equal([@"EXCELLENT" readableMarkDescription]);
expect(testView.overallMarkDescription).to.equal([@"EXCELLENT" readableMarkDescription]);
expect(testView.languageISO2).to.equal(@"de");

[OHHTTPStubs removeStub:myStub];
Expand Down Expand Up @@ -201,10 +201,10 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -235,10 +235,10 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -270,10 +270,10 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -309,10 +309,10 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -342,10 +342,10 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -375,10 +375,10 @@ - (NSString *)gradeNumberString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -500,8 +500,8 @@ - (NSString *)gradeNumberString;
TRSStarsView *fakeStars = [[TRSStarsView alloc] initWithRating:@5];
id starsMock = OCMPartialMock(fakeStars);
testView.starsView = starsMock;
testView.gradeText = @"Test";
testView.gradeNumber = @4.67;
testView.overallMarkDescription = @"Test";
testView.overallMark = @4.67;
OCMExpect([starsMock setFrame:testView.starPlaceholder.bounds]);
[testView layoutSubviews];
OCMVerifyAll(starsMock);
Expand All @@ -512,7 +512,7 @@ - (NSString *)gradeNumberString;
it(@"returns a nicely formatted string for the reviewCount", ^{
TRSShopGradeView *view = [TRSShopGradeView new];
view.debugMode = YES;
view.gradeNumber = @4.78;
view.overallMark = @4.78;
NSString *result = [view gradeNumberString];
expect(result).to.equal(@"4.78/5.00"); // basically just the separator...
});
Expand Down
62 changes: 31 additions & 31 deletions Example/Tests/TRSShopRatingViewSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ @interface TRSShopRatingView (PrivateTests)
@property (nonatomic, strong) TRSStarsView *starsView;
@property (nonatomic, strong) UILabel *gradeLabel;

@property (nonatomic, strong) NSNumber *gradeNumber;
@property (nonatomic, strong) NSNumber *reviewCount;
@property (nonatomic, copy) NSString *gradeText; // atm this not actually displayed in the view
@property (nonatomic, strong) NSNumber *overallMark;
@property (nonatomic, strong) NSNumber *totalReviewCount;
@property (nonatomic, copy) NSString *overallMarkDescription; // atm this not actually displayed in the view
@property (nonatomic, copy) NSString *targetMarketISO3;
@property (nonatomic, copy) NSString *languageISO2;

Expand Down Expand Up @@ -150,16 +150,16 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beKindOf([NSNumber class]);
expect(testView.reviewCount).to.beKindOf([NSNumber class]);
expect(testView.overallMark).to.beKindOf([NSNumber class]);
expect(testView.totalReviewCount).to.beKindOf([NSNumber class]);
expect(testView.targetMarketISO3).to.beKindOf([NSString class]);
expect(testView.gradeText).to.beKindOf([NSString class]);
expect(testView.overallMarkDescription).to.beKindOf([NSString class]);
expect(testView.languageISO2).to.beKindOf([NSString class]);
// this data is defined in the file shopGrade.data!
expect(testView.gradeNumber).to.equal(@4.87);
expect(testView.reviewCount).to.equal(@5);
expect(testView.overallMark).to.equal(@4.87);
expect(testView.totalReviewCount).to.equal(@5);
expect(testView.targetMarketISO3).to.equal(@"CHE");
expect(testView.gradeText).to.equal([@"EXCELLENT" readableMarkDescription]);
expect(testView.overallMarkDescription).to.equal([@"EXCELLENT" readableMarkDescription]);
expect(testView.languageISO2).to.equal(@"de");

[OHHTTPStubs removeStub:myStub];
Expand Down Expand Up @@ -202,10 +202,10 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -236,10 +236,10 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -271,10 +271,10 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -310,10 +310,10 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -343,10 +343,10 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -376,10 +376,10 @@ - (NSString *)reviewCountString;
});
// see class for this: we have an artificial delay, so we need to wait before checking for changes!
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
expect(testView.gradeNumber).to.beNil();
expect(testView.reviewCount).to.beNil();
expect(testView.overallMark).to.beNil();
expect(testView.totalReviewCount).to.beNil();
expect(testView.targetMarketISO3).to.beNil();
expect(testView.gradeText).to.beNil();
expect(testView.overallMarkDescription).to.beNil();
expect(testView.languageISO2).to.beNil();
[OHHTTPStubs removeStub:myStub];
});
Expand Down Expand Up @@ -520,7 +520,7 @@ - (NSString *)reviewCountString;
TRSShopRatingView *testView = [TRSShopRatingView new];
testView.debugMode = YES;
[testView sizeToFit];
testView.reviewCount = @45;
testView.totalReviewCount = @45;
[testView layoutSubviews];
NSString *showntext = testView.gradeLabel.text;
NSString *localizedReviewsName = TRSLocalizedString(@"Reviews", nil);
Expand All @@ -531,7 +531,7 @@ - (NSString *)reviewCountString;
TRSShopRatingView *testView = [TRSShopRatingView new];
testView.debugMode = YES;
[testView sizeToFit];
testView.reviewCount = @0;
testView.totalReviewCount = @0;
[testView layoutSubviews];
NSString *showntext = testView.gradeLabel.text;
NSString *localizedReviewsName = TRSLocalizedString(@"Reviews", nil);
Expand All @@ -542,7 +542,7 @@ - (NSString *)reviewCountString;
TRSShopRatingView *testView = [TRSShopRatingView new];
testView.debugMode = YES;
[testView sizeToFit];
testView.reviewCount = @1;
testView.totalReviewCount = @1;
[testView layoutSubviews];
NSString *showntext = testView.gradeLabel.text;
NSString *localizedReviewsName = TRSLocalizedString(@"Review", nil);
Expand Down Expand Up @@ -579,7 +579,7 @@ - (NSString *)reviewCountString;
it(@"returns a nicely formatted string for the reviewCount", ^{
TRSShopRatingView *view = [TRSShopRatingView new];
view.debugMode = YES;
view.reviewCount = @3876;
view.totalReviewCount = @3876;
NSString *result = [view reviewCountString];
expect(result).to.equal(@"3.876"); // basically just the separator...
});
Expand Down