teacup 0.3.12 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/main_spec.rb CHANGED
@@ -1,205 +1,153 @@
1
1
  describe "Application 'Teacup'" do
2
+ tests FirstController
3
+
2
4
  before do
3
- UIDevice.currentDevice.beginGeneratingDeviceOrientationNotifications
4
- @app = UIApplication.sharedApplication
5
- @view_ctrlr = @app.windows[0].rootViewController
5
+ @root_view = window.subviews[0]
6
+ @background = @root_view.subviews[0]
7
+ @welcome = @background.subviews[0]
8
+ @footer = @background.subviews[1]
9
+ @button = @background.subviews[2]
6
10
  end
7
11
 
8
- after do
9
- UIDevice.currentDevice.endGeneratingDeviceOrientationNotifications
12
+ it "should have a root view" do
13
+ view_ctrlr_view = controller.view
14
+ view_ctrlr_view.subviews.length.should == 1
15
+ view_ctrlr_view.subviews[0].class.should == CustomView
10
16
  end
11
17
 
12
- it "has one window" do
13
- @app.windows.size.should == 1
18
+ it "should be able to rotate" do
19
+ controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationPortrait).should == true
20
+ controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationLandscapeRight).should == true
21
+ controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationLandscapeLeft).should == true
22
+ controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationPortraitUpsideDown).should == nil
14
23
  end
15
24
 
16
- it "should have a root view" do
17
- view_ctrlr_view = @view_ctrlr.view
18
- view_ctrlr_view.subviews.length.should == 1
19
- view_ctrlr_view.subviews[0].class.should == CustomView
25
+ it "root view should be styled as :root" do
26
+ @root_view.stylename.should == :root
27
+ @root_view.frame.origin.x.should == 0
28
+ @root_view.frame.origin.y.should == 0
29
+ @root_view.frame.size.width.should == 320
30
+ @root_view.frame.size.height.should == 480
31
+ @root_view.backgroundColor.should == UIColor.yellowColor
32
+ end
33
+
34
+ it "should be styled as :background" do
35
+ @background.stylename.should == :background
36
+ @background.frame.origin.x.should == 10
37
+ @background.frame.origin.y.should == 30
38
+ @background.frame.size.width.should == 300
39
+ @background.frame.size.height.should == 440
40
+ @background.backgroundColor.should == UIColor.darkGrayColor
41
+ end
42
+
43
+ it "background view should have subviews" do
44
+ @background.subviews.length.should == 3
45
+ @background.subviews[0].class.should == UILabel
46
+ @background.subviews[1].class.should == UILabel
47
+ @background.subviews[2].class.ancestors.include?(UIButton).should == true
48
+ end
49
+
50
+ it "should not have styles overridden by base classes" do
51
+ @background.alpha.should == 0.5
52
+ end
53
+
54
+ it "should have styles overridden orientation styles" do
55
+ @background.backgroundColor.should == UIColor.darkGrayColor
56
+ end
57
+
58
+ it "should have all UILabels with color blue" do
59
+ @welcome.textColor.should == UIColor.blueColor
60
+ @footer.textColor.should == UIColor.blueColor
61
+ end
62
+
63
+ it "should be styled as :welcome" do
64
+ @welcome.stylename.should == :welcome
65
+ @welcome.frame.origin.x.should == 10
66
+ @welcome.frame.origin.y.should == 40
67
+ @welcome.frame.size.width.should == 280
68
+ @welcome.frame.size.height.should == 20
69
+ @welcome.text.should == "Welcome to teacup"
70
+ end
71
+
72
+ it "should be styled as :footer" do
73
+ @footer.stylename.should == :footer
74
+ @footer.frame.origin.x.should == 10
75
+ @footer.frame.origin.y.should == 410
76
+ @footer.frame.size.width.should == 280
77
+ @footer.frame.size.height.should == 20
78
+ @footer.text.should == "This is a teacup example"
20
79
  end
21
80
 
22
- describe "view controller" do
23
-
24
- it "should be able to rotate" do
25
- @view_ctrlr.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationPortrait).should == true
26
- @view_ctrlr.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationLandscapeRight).should == true
27
- @view_ctrlr.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationLandscapeLeft).should == true
28
- @view_ctrlr.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationPortraitUpsideDown).should == nil
29
- end
30
- end
31
-
32
- describe "root view" do
33
-
34
- before do
35
- @root_view = @app.windows[0].subviews[0]
36
- end
37
-
38
- it "root view should be styled as 'root'" do
39
- @root_view.stylename.should == :root
40
- @root_view.frame.origin.x.should == 0
41
- @root_view.frame.origin.y.should == 0
42
- @root_view.frame.size.width.should == 320
43
- @root_view.frame.size.height.should == 480
44
- @root_view.backgroundColor.should == UIColor.yellowColor
45
- end
46
-
47
- end
48
-
49
- describe "background view" do
50
-
51
- before do
52
- @background = @app.windows[0].subviews[0].subviews[0]
53
- end
54
-
55
- it "should be styled as :background" do
56
- @background.stylename.should == :background
57
- @background.frame.origin.x.should == 10
58
- @background.frame.origin.y.should == 30
59
- @background.frame.size.width.should == 300
60
- @background.frame.size.height.should == 440
61
- @background.backgroundColor.should == UIColor.darkGrayColor
62
- end
63
-
64
- it "background view should have subviews" do
65
- @background.subviews.length.should == 3
66
- @background.subviews[0].class.should == UILabel
67
- @background.subviews[1].class.should == UILabel
68
- @background.subviews[2].class.ancestors.include?(UIButton).should == true
69
- end
70
-
71
- it "should not have styles overridden by base classes" do
72
- @background.alpha.should == 0.5
73
- end
74
-
75
- it "should have styles overridden orientation styles" do
76
- @background.backgroundColor.should == UIColor.darkGrayColor
77
- end
78
-
79
- describe "background subviews" do
80
-
81
- before do
82
- @welcome = @background.subviews[0]
83
- @footer = @background.subviews[1]
84
- @button = @background.subviews[2]
85
- end
86
-
87
- it "should have all UILabels with color blue" do
88
- @welcome.textColor.should == UIColor.blueColor
89
- @footer.textColor.should == UIColor.blueColor
90
- end
91
-
92
- describe "welcome" do
93
- it "should be styled as :welcome" do
94
- @welcome.stylename.should == :welcome
95
- @welcome.frame.origin.x.should == 10
96
- @welcome.frame.origin.y.should == 40
97
- @welcome.frame.size.width.should == 280
98
- @welcome.frame.size.height.should == 20
99
- @welcome.text.should == "Welcome to teacup"
100
- end
101
- end
102
-
103
- describe "footer" do
104
- it "should be styled as :footer" do
105
- @footer.stylename.should == :footer
106
- @footer.frame.origin.x.should == 10
107
- @footer.frame.origin.y.should == 410
108
- @footer.frame.size.width.should == 280
109
- @footer.frame.size.height.should == 20
110
- @footer.text.should == "This is a teacup example"
111
- end
112
- end
113
-
114
- describe "button" do
115
- it "should be styled as :next_message" do
116
- @button.stylename.should == :next_message
117
- @button.frame.origin.x.should == 150
118
- @button.frame.origin.y.should == 370
119
- @button.frame.size.width.should == 130
120
- @button.frame.size.height.should == 20
121
- @button.titleForState(UIControlStateNormal).should == "Next Message..."
122
- end
123
- end
124
-
125
- end
126
-
127
- end
128
-
129
- describe "background view in landscape" do
130
-
131
- before do
132
- @background = @app.windows[0].subviews[0].subviews[0]
133
- @view_ctrlr.landscape_only
134
- UIApplication.sharedApplication.setStatusBarOrientation(UIInterfaceOrientationLandscapeLeft, animated:false)
135
- end
136
-
137
- it "should be in landscape" do
138
- # the rest of these tests *pass*, but the device orientation isn't actually
139
- # updated to be landscape yet... :-/
140
- UIDevice.currentDevice.orientation.should > 0
141
- end
142
-
143
- it "should be styled as :background - landscape" do
144
- @background.stylename.should == :background
145
- @background.frame.origin.x.should == 10
146
- @background.frame.origin.y.should == 30
147
- @background.frame.size.width.should == 460
148
- @background.frame.size.height.should == 280
149
- @background.backgroundColor.should == UIColor.lightGrayColor
150
- end
151
-
152
- it "should not have styles overridden by base classes" do
153
- @background.alpha.should == 0.8
154
- end
155
-
156
- it "should have styles overridden orientation styles" do
157
- @background.backgroundColor.should == UIColor.lightGrayColor
158
- end
159
-
160
- describe "background subviews in landscape" do
161
-
162
- before do
163
- @welcome = @background.subviews[0]
164
- @footer = @background.subviews[1]
165
- @button = @background.subviews[2]
166
- end
167
-
168
- describe "welcome" do
169
- it "should be styled as :welcome - landscape" do
170
- @welcome.stylename.should == :welcome
171
- @welcome.frame.origin.x.should == 90
172
- @welcome.frame.origin.y.should == 40
173
- @welcome.frame.size.width.should == 280
174
- @welcome.frame.size.height.should == 20
175
- @welcome.text.should == "Welcome to teacup"
176
- end
177
- end
178
-
179
- describe "footer" do
180
- it "should be styled as :footer - landscape" do
181
- @footer.stylename.should == :footer
182
- @footer.frame.origin.x.should == 90
183
- @footer.frame.origin.y.should == 250
184
- @footer.frame.size.width.should == 280
185
- @footer.frame.size.height.should == 20
186
- @footer.text.should == "This is a teacup example"
187
- end
188
- end
189
-
190
- describe "button" do
191
- it "should be styled as :next_message - landscape" do
192
- @button.stylename.should == :next_message
193
- @button.frame.origin.x.should == 20
194
- @button.frame.origin.y.should == 200
195
- @button.frame.size.width.should == 130
196
- @button.frame.size.height.should == 20
197
- @button.titleForState(UIControlStateNormal).should == "Next Message..."
198
- end
199
- end
200
-
201
- end
81
+ it "should be styled as :next_message" do
82
+ @button.stylename.should == :next_message
83
+ @button.frame.origin.x.should == 150
84
+ @button.frame.origin.y.should == 370
85
+ @button.frame.size.width.should == 130
86
+ @button.frame.size.height.should == 20
87
+ @button.titleForState(UIControlStateNormal).should == "Next Message..."
88
+ end
89
+
90
+ end
91
+
92
+
93
+ describe "background view in landscape" do
94
+ tests FirstController
95
+
96
+ before do
97
+ @root_view = window.subviews[0]
98
+ @background = @root_view.subviews[0]
99
+ @welcome = @background.subviews[0]
100
+ @footer = @background.subviews[1]
101
+ @button = @background.subviews[2]
102
+ rotate_device :to => :landscape
103
+ end
104
+
105
+ it "should be in landscape" do
106
+ UIApplication.sharedApplication.statusBarOrientation.should == UIInterfaceOrientationLandscapeLeft
107
+ end
108
+
109
+ it "should be styled as :background - landscape" do
110
+ @background.stylename.should == :background
111
+ @background.frame.origin.x.should == 10
112
+ @background.frame.origin.y.should == 30
113
+ @background.frame.size.width.should == 460
114
+ @background.frame.size.height.should == 280
115
+ @background.backgroundColor.should == UIColor.lightGrayColor
116
+ end
117
+
118
+ it "should not have styles overridden by base classes" do
119
+ @background.alpha.should == 0.8
120
+ end
121
+
122
+ it "should have styles overridden orientation styles" do
123
+ @background.backgroundColor.should == UIColor.lightGrayColor
124
+ end
125
+
126
+ it "should be styled as :welcome - landscape" do
127
+ @welcome.stylename.should == :welcome
128
+ @welcome.frame.origin.x.should == 90
129
+ @welcome.frame.origin.y.should == 40
130
+ @welcome.frame.size.width.should == 280
131
+ @welcome.frame.size.height.should == 20
132
+ @welcome.text.should == "Welcome to teacup"
133
+ end
134
+
135
+ it "should be styled as :footer - landscape" do
136
+ @footer.stylename.should == :footer
137
+ @footer.frame.origin.x.should == 90
138
+ @footer.frame.origin.y.should == 250
139
+ @footer.frame.size.width.should == 280
140
+ @footer.frame.size.height.should == 20
141
+ @footer.text.should == "This is a teacup example"
142
+ end
202
143
 
144
+ it "should be styled as :next_message - landscape" do
145
+ @button.stylename.should == :next_message
146
+ @button.frame.origin.x.should == 20
147
+ @button.frame.origin.y.should == 200
148
+ @button.frame.size.width.should == 130
149
+ @button.frame.size.height.should == 20
150
+ @button.titleForState(UIControlStateNormal).should == "Next Message..."
203
151
  end
204
152
 
205
153
  end
data/teacup.gemspec CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  require File.expand_path('../lib/teacup/version.rb', __FILE__)
2
3
 
3
4
  Gem::Specification.new do |gem|
@@ -0,0 +1,11 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ enum {
4
+ AnyType = 0,
5
+ };
6
+ typedef char AnyOldType;
7
+
8
+ @interface TeacupDummy : NSObject
9
+ - (void) setType:(AnyOldType)type;
10
+ - (AnyOldType) type;
11
+ @end
@@ -0,0 +1,8 @@
1
+ #import "TeacupDummy.h"
2
+
3
+ @implementation TeacupDummy
4
+ - (void) setType:(AnyOldType)type {}
5
+ - (AnyOldType) type {
6
+ return AnyType;
7
+ }
8
+ @end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teacup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-14 00:00:00.000000000 Z
12
+ date: 2012-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -74,12 +74,16 @@ files:
74
74
  - app/views/custom_view.rb
75
75
  - lib/dummy.rb
76
76
  - lib/teacup.rb
77
+ - lib/teacup/constraint.rb
77
78
  - lib/teacup/handler.rb
78
79
  - lib/teacup/layout.rb
79
80
  - lib/teacup/merge_defaults.rb
80
81
  - lib/teacup/restyle.rb
81
82
  - lib/teacup/style.rb
82
83
  - lib/teacup/stylesheet.rb
84
+ - lib/teacup/stylesheet_extensions/autoresize.rb
85
+ - lib/teacup/stylesheet_extensions/constraints.rb
86
+ - lib/teacup/stylesheet_extensions/geometry.rb
83
87
  - lib/teacup/stylesheet_extensions/rotation.rb
84
88
  - lib/teacup/version.rb
85
89
  - lib/teacup/z_core_extensions/ca_layer.rb
@@ -101,6 +105,8 @@ files:
101
105
  - spec/stylesheet_spec.rb
102
106
  - spec/view_spec.rb
103
107
  - teacup.gemspec
108
+ - vendor/TeacupDummy/TeacupDummy.h
109
+ - vendor/TeacupDummy/TeacupDummy.m
104
110
  homepage: https://github.com/rubymotion/teacup
105
111
  licenses: []
106
112
  post_install_message:
@@ -121,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
127
  version: '0'
122
128
  requirements: []
123
129
  rubyforge_project:
124
- rubygems_version: 1.8.19
130
+ rubygems_version: 1.8.24
125
131
  signing_key:
126
132
  specification_version: 3
127
133
  summary: A community-driven DSL for creating user interfaces on iOS.