shoes-mocks 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,3 @@
1
- require "shoes/mocks/version"
1
+ require_relative "mocks/version"
2
+ require_relative "mocks/shoes"
2
3
 
3
- module Shoes
4
- module Mocks
5
- # Your code goes here...
6
- end
7
- end
@@ -0,0 +1,19 @@
1
+ # All of the classes are ones that Shoes needs to be just bootstrapped
2
+ class Shoes
3
+ class Types; end
4
+ class Background; end
5
+ class Border; end
6
+ class Canvas; end
7
+ class Check; end
8
+ class Radio; end
9
+ class EditLine; end
10
+ class EditBox; end
11
+ class Effect; end
12
+ class Image; end
13
+ class ListBox; end
14
+ class Progress; end
15
+ class Shape; end
16
+ class TextBlock; end
17
+ class Text; end
18
+ end
19
+
@@ -0,0 +1,34 @@
1
+ # The classes mocked out from the C-Code
2
+ class Shoes
3
+
4
+ class TextElement
5
+ attr_accessor :text
6
+ def initialize(text)
7
+ self.text = text
8
+ end
9
+ end
10
+
11
+ # quite an inheritance chain... someone told me inheritance is bad :<
12
+ # But it felt like so much duplication
13
+ class TextBlockElement < TextElement
14
+ attr_accessor :block, :parent
15
+ def initialize(parent, text, &blk)
16
+ super(text)
17
+ self.parent = parent
18
+ self.block = blk
19
+ end
20
+
21
+ def click
22
+ parent.instance_eval(&block)
23
+ end
24
+
25
+ end
26
+
27
+ class Alert < TextElement; end
28
+ class Paragraph < TextElement; end
29
+
30
+ class Link < TextBlockElement; end
31
+ class Button < TextBlockElement; end
32
+
33
+ end
34
+
@@ -0,0 +1,53 @@
1
+ require 'rspec/mocks'
2
+ require_relative 'bootstrap'
3
+ require_relative 'mocked_classes'
4
+
5
+ # mocking the whole Shoes
6
+ class Shoes
7
+
8
+ RSpec::Mocks.setup(self)
9
+
10
+ attr_accessor :elements
11
+
12
+ # for alerts and other things (for now)
13
+ attr_accessor :events
14
+
15
+ def initialize(&block)
16
+ self.elements = []
17
+ self.events = []
18
+ instance_eval(&block) if block_given?
19
+ end
20
+
21
+ def self.app(&block)
22
+ @application = new(&block)
23
+ end
24
+
25
+ # get the application that was most recently initilized with shoes
26
+ # unfortunately this won't work with multiple Shoes.apps in a program,
27
+ # as we only get the most recent ones (see above)
28
+ def self.application
29
+ @application
30
+ end
31
+
32
+ def append(&blk)
33
+ instance_eval &blk if block_given?
34
+ end
35
+
36
+ def button(name, &blk)
37
+ self.elements << Button.new(self, name, &blk)
38
+ end
39
+
40
+ def para(text)
41
+ self.elements << Paragraph.new(text)
42
+ end
43
+
44
+ def link(text, &blk)
45
+ self.elements << Link.new(self, text, &blk)
46
+ end
47
+
48
+ def alert(text)
49
+ self.events << Alert.new(text)
50
+ end
51
+
52
+ end
53
+
@@ -1,5 +1,6 @@
1
- module Shoes
1
+ class Shoes
2
2
  module Mocks
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
6
+
@@ -5,14 +5,17 @@ require "shoes/mocks/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "shoes-mocks"
7
7
  s.version = Shoes::Mocks::VERSION
8
- s.authors = ["Steve Klabnik"]
9
- s.email = ["steve@steveklabnik.com"]
8
+ s.authors = ["Steve Klabnik", "Tobias Pfeiffer"]
9
+ s.email = ["steve@steveklabnik.com", "tobias.pfeiffer@student.hpi.uni-potsdam.de"]
10
10
  s.homepage = "http://github.com/shoes/shoes-mocks"
11
11
  s.summary = %q{Mocking for Shoes}
12
12
  s.description = %q{If you want your tests to be isolated, you need mocks. Mocking GUIs is hard. shoes-mocks to the rescue!}
13
13
 
14
+ s.add_runtime_dependency 'rspec'
15
+
14
16
  s.files = `git ls-files`.split("\n")
15
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
19
  s.require_paths = ["lib"]
18
20
  end
21
+
metadata CHANGED
@@ -1,27 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoes-mocks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve Klabnik
14
+ - Tobias Pfeiffer
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-08-27 00:00:00 -04:00
19
+ date: 2011-09-25 00:00:00 -07:00
19
20
  default_executable:
20
- dependencies: []
21
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rspec
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
22
36
  description: If you want your tests to be isolated, you need mocks. Mocking GUIs is hard. shoes-mocks to the rescue!
23
37
  email:
24
38
  - steve@steveklabnik.com
39
+ - tobias.pfeiffer@student.hpi.uni-potsdam.de
25
40
  executables: []
26
41
 
27
42
  extensions: []
@@ -34,6 +49,9 @@ files:
34
49
  - README.md
35
50
  - Rakefile
36
51
  - lib/shoes/mocks.rb
52
+ - lib/shoes/mocks/bootstrap.rb
53
+ - lib/shoes/mocks/mocked_classes.rb
54
+ - lib/shoes/mocks/shoes.rb
37
55
  - lib/shoes/mocks/version.rb
38
56
  - shoes-mocks.gemspec
39
57
  has_rdoc: true