liltest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in liltest.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dennis Schneider
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Liltest
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'liltest'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install liltest
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,82 @@
1
+ require 'liltest/expectation'
2
+ require 'liltest/request'
3
+
4
+ module Liltest
5
+ class Case
6
+ def self.describe(description, &block)
7
+ block.call
8
+ end
9
+
10
+ def self.it(description, &block)
11
+ @tests ||= []
12
+ @tests << { context: @current_context, description: description, block: block }
13
+ end
14
+
15
+ def self.context(context_name, &block)
16
+ @current_context = context_name
17
+ block.call
18
+ end
19
+
20
+ def self.execute
21
+ @tests.each do |test|
22
+ begin
23
+ test[:block].call
24
+ $stdout.write "."
25
+ rescue
26
+ @failed ||= []
27
+ @failed << test
28
+ $stdout.write "F"
29
+ end
30
+ end
31
+
32
+ write_failed_tests
33
+ write_failed_expectations
34
+ end
35
+
36
+ def self.write_failed_expectations
37
+ if @expectations
38
+ @expectations.each do |expectation|
39
+ if expectation.failed?
40
+ $stdout.write "\n #{expectation.failed_reason}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def self.write_failed_tests
47
+ if @failed
48
+ $stdout.write "\n"
49
+ @failed.each do |failed|
50
+ $stdout.write "\n #{@current_context} #{failed[:description]} failed"
51
+ end
52
+ end
53
+ end
54
+
55
+ def self.expect(value)
56
+ expectation = Expectation.new(value)
57
+ @expectations ||= []
58
+ @expectations << expectation
59
+ expectation
60
+ end
61
+
62
+ def self.get(endpoint, body = nil, headers = nil)
63
+ @response = Liltest::Request.new(:get, endpoint, body, headers)
64
+ end
65
+
66
+ def self.post(endpoint, body = nil, headers = nil)
67
+ @response = Liltest::Request.new(:post, endpoint, body, headers)
68
+ end
69
+
70
+ def self.put(endpoint, body = nil, headers = nil)
71
+ @response = Liltest::Request.new(:put, endpoint, body, headers)
72
+ end
73
+
74
+ def self.delete(endpoint, body = nil, headers = nil)
75
+ @response = Liltest::Request.new(:delete, endpoint, body, headers)
76
+ end
77
+
78
+ def self.response
79
+ @response
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,20 @@
1
+ module Liltest
2
+ class Expectation
3
+ attr_reader :value, :failed_reason
4
+
5
+ def initialize(value)
6
+ @value = value
7
+ end
8
+
9
+ def to_eq(expectation)
10
+ if value != expectation
11
+ @failed_reason = "Expected '#{value}' to equal '#{expectation}', but it was '#{value}'"
12
+ raise "Failed"
13
+ end
14
+ end
15
+
16
+ def failed?
17
+ !!@failed_reason
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require "typhoeus"
2
+
3
+ module Liltest
4
+ class Request
5
+ def initialize(method, endpoint, body, headers)
6
+ @response = Typhoeus::Request.new(
7
+ endpoint,
8
+ method: method,
9
+ body: body,
10
+ params: nil,
11
+ headers: headers
12
+ ).run
13
+ end
14
+
15
+ def body
16
+ @response.body
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Liltest
2
+ VERSION = "0.0.1"
3
+ end
data/lib/liltest.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "liltest/version"
2
+ require "liltest/case"
3
+
4
+ module Liltest
5
+ end
data/liltest.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'liltest/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "liltest"
8
+ gem.version = Liltest::VERSION
9
+ gem.authors = ["Dennis Schneider"]
10
+ gem.email = ["sinned.schneider@gmail.com"]
11
+ gem.description = %q{A small test-framework with Rspec-like syntax}
12
+ gem.summary = %q{A small test-framework with Rspec-like syntax}
13
+ gem.homepage = "https://github.com/dschneider/liltest"
14
+
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_runtime_dependency('typhoeus')
22
+ gem.add_runtime_dependency('json')
23
+
24
+ gem.add_development_dependency('rspec')
25
+ gem.add_development_dependency('rake')
26
+ gem.add_development_dependency('simplecov')
27
+ gem.add_development_dependency('travis')
28
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liltest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dennis Schneider
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: typhoeus
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: travis
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A small test-framework with Rspec-like syntax
111
+ email:
112
+ - sinned.schneider@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Gemfile
119
+ - LICENSE.txt
120
+ - README.md
121
+ - Rakefile
122
+ - lib/liltest.rb
123
+ - lib/liltest/case.rb
124
+ - lib/liltest/expectation.rb
125
+ - lib/liltest/request.rb
126
+ - lib/liltest/version.rb
127
+ - liltest.gemspec
128
+ homepage: https://github.com/dschneider/liltest
129
+ licenses: []
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ segments:
141
+ - 0
142
+ hash: 1455469989762286184
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ segments:
150
+ - 0
151
+ hash: 1455469989762286184
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 1.8.24
155
+ signing_key:
156
+ specification_version: 3
157
+ summary: A small test-framework with Rspec-like syntax
158
+ test_files: []