fix 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e0bdb51428d1e9befcd3f876463ec42ecd33f24
4
+ data.tar.gz: 080b67c3571d376c76c11c7073a1905179a5e79e
5
+ SHA512:
6
+ metadata.gz: e2cce45a87309814780a680087b0f8c6805ec87e53960c5e56d047894f5aeef544bc3053dcaed099c023a970cb5e585043aa8857937300ede5cd6a7eadd4c801
7
+ data.tar.gz: 7733c37958d09da34948aaf7b357874bfc9cfc647849aaf0baac451b6c0731b73c46c418d0a9424ace1171ad047ef95e568478f2f2d9fa6940f315bb1cc064d4
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1 @@
1
+ 2.1.2
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ script: 'bundle exec rake test'
3
+ rvm:
4
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Cyril Wack
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.
@@ -0,0 +1,103 @@
1
+ # Fix
2
+
3
+ Minimal and fast BDD framework for Ruby.
4
+
5
+ ![Fix](https://raw.githubusercontent.com/cyril/fix.rb/master/logo.svg)
6
+
7
+ ## Status
8
+
9
+ [![Gem Version](https://badge.fury.io/rb/fix.png)](http://badge.fury.io/rb/fix)
10
+ [![Build Status](https://secure.travis-ci.org/cyril/fix.rb.png?branch=master)](http://travis-ci.org/cyril/fix.rb?branch=master)
11
+ [![Coverage](https://coveralls.io/repos/cyril/fix.rb/badge.png?branch=master)](https://coveralls.io/r/cyril/fix.rb)
12
+ [![Code Climate](https://codeclimate.com/github/cyril/fix.rb.png)](https://codeclimate.com/github/cyril/fix.rb)
13
+ [![Dependencies](https://gemnasium.com/cyril/fix.rb.png)](https://gemnasium.com/cyril/fix.rb)
14
+ [![Inline docs](http://inch-ci.org/github/cyril/fix.rb.png)](http://inch-ci.org/github/cyril/fix.rb)
15
+ ![](https://ruby-gem-downloads-badge.herokuapp.com/fix?type=total)
16
+
17
+ ## Rubies
18
+
19
+ __Fix__ supports Ruby (MRI) 2+.
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'fix'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install fix
36
+
37
+ ## Usage
38
+
39
+ Given that you'd like to test the following class:
40
+
41
+ ```ruby
42
+ # app.rb
43
+ class Meme
44
+ def i_can_has_cheezburger?
45
+ "OHAI!"
46
+ end
47
+
48
+ def will_it_blend?
49
+ "YES!"
50
+ end
51
+ end
52
+ ```
53
+
54
+ Define your tests as methods:
55
+
56
+ ```ruby
57
+ # spec.rb
58
+ require "app"
59
+
60
+ constant :Meme do
61
+ call :new do
62
+ scope "when asked about cheeseburgers" do
63
+ call :i_can_has_cheezburger? do
64
+ subject.should eql "OHAI!"
65
+ end
66
+ end
67
+
68
+ scope "when asked about blending possibilities" do
69
+ call :will_it_blend? do
70
+ subject.should_not match /^no/i
71
+ end
72
+ end
73
+ end
74
+ end
75
+ ```
76
+
77
+ And then, test it:
78
+
79
+ ```bash
80
+ $ fix ./spec.rb
81
+ /Users/bob/spec.rb
82
+ ..
83
+ Finished in 0.004397 seconds
84
+ 2 examples, 0 failures
85
+ ```
86
+
87
+ PS: Thanks to the Minitest authors that I picked up the example.
88
+
89
+ ## Contributing
90
+
91
+ 1. Fork it ( https://github.com/cyril/fix.rb/fork )
92
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
93
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
94
+ 4. Push to the branch (`git push origin my-new-feature`)
95
+ 5. Create a new Pull Request
96
+
97
+ ## Versioning
98
+
99
+ __Fix__ uses [Semantic Versioning 2.0.0](http://semver.org).
100
+
101
+ ## Copyright
102
+
103
+ Copyright 2014 Cyril Wack – Released under [MIT License](LICENSE.md)
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1 @@
1
+ 0.0.1.pre
data/bin/fix ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ START_TIME = Time.now
4
+
5
+ require_relative File.join %w(.. lib fix)
6
+
7
+ include Fix
8
+
9
+ absolute_paths = Set.new
10
+
11
+ unless ARGV.any?
12
+ ARGV.concat %w(spec test).select {|s|
13
+ Dir.exist? File.join(__FILE__, '..', '..', s)
14
+ }.map {|s| File.absolute_path(File.join(__FILE__, '..', '..', s)) }
15
+ end
16
+
17
+ ARGV.map! do |s|
18
+ s = File.absolute_path(s) unless s.start_with?('/')
19
+ s
20
+ end
21
+
22
+ ARGV.map do |s|
23
+ if File.directory? s
24
+ spec_files = File.join(s, '**', '*_spec.rb')
25
+ Dir.glob(spec_files).each do |spec_file|
26
+ absolute_paths.add spec_file
27
+ end
28
+ else
29
+ absolute_paths.add s
30
+ end
31
+ end
32
+
33
+ unless absolute_paths.any?
34
+ puts 'Sorry, specs not found.'
35
+ exit
36
+ end
37
+
38
+ examples = nil
39
+ failures = nil
40
+
41
+ absolute_paths.each do |absolute_path|
42
+ puts absolute_path
43
+ require absolute_path
44
+
45
+ examples = Fix.run
46
+ examples.each {|example| print example.to_s }
47
+ puts
48
+
49
+ failures = examples.reject {|example| example.valid? }
50
+ failures.each do |failure|
51
+ puts failure.backtrace
52
+ end
53
+ end
54
+
55
+ TIME_TAKEN = Time.now - START_TIME
56
+
57
+ puts "Finished in #{TIME_TAKEN} seconds"
58
+ puts "#{examples.length} examples, #{failures.length} failures"
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'fix'
3
+ spec.version = File.read('VERSION.semver')
4
+ spec.authors = ['Cyril Wack']
5
+ spec.email = ['cyril@sashite.com']
6
+ spec.summary = %q{Fix and keep the green code.}
7
+ spec.description = %q{Minimal and fast BDD framework for Ruby.}
8
+ spec.homepage = 'https://github.com/cyril/fix.rb'
9
+ spec.license = 'MIT'
10
+
11
+ spec.files = `git ls-files -z`.split("\x0")
12
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
+ spec.test_files = spec.files.grep(%r{^spec/})
14
+ spec.require_paths = ['lib']
15
+
16
+ spec.add_development_dependency 'bundler', '~> 1.7'
17
+ spec.add_development_dependency 'rake', '~> 10.0'
18
+ end
@@ -0,0 +1,20 @@
1
+ %w(set thread).each {|lib| require lib }
2
+ %w(
3
+ helper
4
+ base_matcher
5
+ expectation_target
6
+ call
7
+ constant
8
+ subject
9
+ spec
10
+ ).each {|path| require_relative File.join 'fix', path }
11
+
12
+ module Fix
13
+ def constant *syms, &block
14
+ @@spec = Spec.new *syms, &block
15
+ end
16
+
17
+ def self.run
18
+ @@spec.run
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ module Fix
2
+ class BaseMatcher
3
+ def initialize expected
4
+ @expected = expected
5
+ end
6
+
7
+ def matches? actual
8
+ match? @expected, actual
9
+ end
10
+ end
11
+
12
+ class Equal < BaseMatcher
13
+
14
+ private
15
+
16
+ def match? expected, actual
17
+ actual.equal? expected
18
+ end
19
+ end
20
+
21
+ class Eql < BaseMatcher
22
+
23
+ private
24
+
25
+ def match? expected, actual
26
+ actual.eql? expected
27
+ end
28
+ end
29
+
30
+ class Match < BaseMatcher
31
+
32
+ private
33
+
34
+ def match? expected, actual
35
+ !actual.match(expected).nil?
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ module Fix
2
+ class Call < BasicObject
3
+ include Helper::CallHelper
4
+ include Helper::ScopeHelper
5
+ include Helper::FooHelper
6
+
7
+ def initialize subject, method_with_args
8
+ @subject = subject
9
+ @method_with_args = method_with_args
10
+ end
11
+
12
+ def subject
13
+ Subject.new @subject.object.__send__(*@method_with_args), @subject.examples
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ module Fix
2
+ class Constant < BasicObject
3
+ include Helper::CallHelper
4
+ include Helper::ScopeHelper
5
+ include Helper::FooHelper
6
+
7
+ def initialize const, examples
8
+ @const = const
9
+ @subject = Subject.new @const, examples
10
+ end
11
+
12
+ def constant *syms, &block
13
+ const = syms.inject(@const) do |base, const|
14
+ base.const_get(const)
15
+ end
16
+
17
+ @constant = Constant.new const, @subject.examples
18
+ @constant.instance_exec &block if block
19
+ end
20
+
21
+ def subject &block
22
+ if block
23
+ update_subject_with @subject.instance_exec &block
24
+ end
25
+
26
+ @subject
27
+ end
28
+
29
+ def update_subject_with obj
30
+ @subject = Subject.new obj, @subject.examples
31
+ end
32
+
33
+ def should *args
34
+ @subject.should *args
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,41 @@
1
+ module Fix
2
+ class ExpectationTarget
3
+ attr_reader :backtrace
4
+
5
+ def initialize value
6
+ @actual = value
7
+ end
8
+
9
+ def to matcher
10
+ unless matcher.matches?(@actual)
11
+ @backtrace = "matcher: #{matcher.inspect}, actual: #{@actual}"
12
+ end
13
+
14
+ self
15
+ end
16
+
17
+ def not_to matcher
18
+ unless !matcher.matches?(@actual)
19
+ @backtrace = "matcher: !#{matcher}, actual: #{@actual}"
20
+ end
21
+
22
+ self
23
+ end
24
+
25
+ def valid?
26
+ @backtrace.nil?
27
+ end
28
+
29
+ def to_s
30
+ case valid?
31
+
32
+ when true
33
+ '.'
34
+ when false
35
+ 'F'
36
+ else
37
+ '?'
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,34 @@
1
+ module Fix
2
+ module Helper
3
+ module FooHelper
4
+ def equal expected
5
+ Equal.new expected
6
+ end
7
+
8
+ def eql expected
9
+ Eql.new expected
10
+ end
11
+
12
+ def match expected
13
+ Match.new expected
14
+ end
15
+ end
16
+
17
+ module CallHelper
18
+ def call *args, &block
19
+ @call = Call.new subject, args
20
+ @call.instance_exec &block
21
+ end
22
+ end
23
+
24
+ module ScopeHelper
25
+ def scope desc = nil, &block
26
+ @scope = Scope.new subject, desc
27
+ @scope.instance_exec &block
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ require_relative 'call'
34
+ require_relative 'scope'
@@ -0,0 +1,20 @@
1
+ module Fix
2
+ class Scope < BasicObject
3
+ include Helper::CallHelper
4
+ include Helper::ScopeHelper
5
+ include Helper::FooHelper
6
+
7
+ def initialize subject, desc
8
+ @subject = subject
9
+ @desc = desc
10
+ end
11
+
12
+ def subject &block
13
+ if block
14
+ @subject = Subject.new @subject.instance_exec(&block), @subject.examples
15
+ end
16
+
17
+ @subject
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Fix
2
+ class Spec
3
+ attr_reader :examples
4
+
5
+ def initialize *syms, &block
6
+ @examples = Set.new
7
+
8
+ const = syms.inject(Object) do |base, const|
9
+ base.const_get(const)
10
+ end
11
+
12
+ @constant = Constant.new const, @examples
13
+ @constant.instance_exec &block if block
14
+ end
15
+
16
+ def run
17
+ @examples.map {|example| example.value }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module Fix
2
+ class Subject
3
+ attr_reader :object, :examples
4
+
5
+ def initialize object, examples
6
+ @examples = examples
7
+ @object = object
8
+ end
9
+
10
+ def expect value
11
+ ExpectationTarget.new value
12
+ end
13
+
14
+ def should matcher
15
+ @examples << Thread.new { expect(@object).to matcher }
16
+ end
17
+
18
+ def should_not matcher
19
+ @examples << Thread.new { expect(@object).not_to matcher }
20
+ end
21
+ end
22
+ end
Binary file
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0"?>
2
+ <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
3
+ <g>
4
+ <title>Fix logo</title>
5
+
6
+ <g>
7
+ <rect fill="none" height="202" width="202" y="-1" x="-1"/>
8
+ <g display="none" overflow="visible" y="0" x="0" height="100%" width="100%">
9
+ <rect fill="url(#gridpattern)" stroke-width="0" y="0" x="0" height="100%" width="100%"/>
10
+ </g>
11
+ </g>
12
+ </g>
13
+
14
+ <g stroke="null">
15
+ <path stroke="#000" d="m96.921051,4.165738c44.131577,-1.082873 51.315796,-2.165746 73.894745,25.988952c22.578949,28.154697 26.684204,62.806637 21.552628,85.546963c-5.131577,22.740334 -16.421051,50.895027 -30.789474,61.723763c-14.368423,10.82872 -40.026314,20.5746 -66.710526,17.325958c-26.684212,-3.248596 -50.289474,-11.911591 -66.710527,-29.237549c-16.421054,-17.325989 -23.605265,-41.149185 -24.63158,-66.05526c-1.026316,-24.906082 12.31579,-66.055256 20.526316,-75.801113c8.210526,-9.745856 28.736843,-18.40884 72.86842,-19.491714z" stroke-opacity="null" stroke-width="0" fill="#007f00"/>
16
+ <path stroke="#000" d="m70.236847,22.03306c31.815788,-5.414331 74.921051,-4.331459 74.407867,-4.331459c0.513184,0 -57.473694,12.453007 -74.407867,22.740316c-16.934246,10.287292 -55.421058,56.309395 -55.934246,56.309395c0.513188,0 2.565821,-32.486191 9.750031,-47.646412c7.184212,-15.160221 14.368423,-21.657475 46.184216,-27.07184z" stroke-opacity="null" stroke-width="0" fill="#00bf00"/>
17
+ <path stroke="#000" d="m20.459461,117.86631c5.645834,-19.490639 47.209522,-50.895027 67.735844,-63.889503c20.526314,-12.994469 49.263161,-25.447508 65.684212,-23.823198c17.960281,6.49732 24.631577,35.193361 26.684204,55.226511c2.052643,20.03315 -2.052628,57.391182 -18.473679,75.258614c-16.421051,17.867401 -33.868423,23.281784 -53.881615,22.198914c-20.013123,-1.082916 -51.315727,-11.370209 -63.118389,-18.950302c-11.802601,-7.580124 -30.276347,-26.53038 -24.630577,-46.021034z" stroke-opacity="null" stroke-width="0" fill="#00bf00"/>
18
+ </g>
19
+ </svg>
@@ -0,0 +1,5 @@
1
+ require_relative File.join %w(.. lib fix)
2
+
3
+ Dir[
4
+ File.join %w(spec support ** *.rb)
5
+ ].each { |f| require File.expand_path(f) }
@@ -0,0 +1,5 @@
1
+ require_relative 'spec_helper'
2
+
3
+ constant :Fix, :Subject do
4
+ subject.should equal Fix::Subject
5
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Cyril Wack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Minimal and fast BDD framework for Ruby.
42
+ email:
43
+ - cyril@sashite.com
44
+ executables:
45
+ - fix
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".ruby-version"
51
+ - ".travis.yml"
52
+ - Gemfile
53
+ - LICENSE.md
54
+ - README.md
55
+ - Rakefile
56
+ - VERSION.semver
57
+ - bin/fix
58
+ - fix.gemspec
59
+ - lib/fix.rb
60
+ - lib/fix/base_matcher.rb
61
+ - lib/fix/call.rb
62
+ - lib/fix/constant.rb
63
+ - lib/fix/expectation_target.rb
64
+ - lib/fix/helper.rb
65
+ - lib/fix/scope.rb
66
+ - lib/fix/spec.rb
67
+ - lib/fix/subject.rb
68
+ - logo.png
69
+ - logo.svg
70
+ - spec/spec_helper.rb
71
+ - spec/subject_spec.rb
72
+ homepage: https://github.com/cyril/fix.rb
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.1
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Fix and keep the green code.
96
+ test_files:
97
+ - spec/spec_helper.rb
98
+ - spec/subject_spec.rb
99
+ has_rdoc: