reason 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rson.gemspec
4
+ gemspec
5
+ gem "bundler"
6
+ gem "cucumber"
7
+ gem "rspec"
8
+ gem "aruba"
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Steve Yadlowsky
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
+ # Because
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'because'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install because
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 'Added 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,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,50 @@
1
+ Feature: `before` clause for describing tests
2
+ As a behaviour driven developer
3
+ In order to keep track of why specifications are required
4
+ I want a way to document the reason for a test.
5
+
6
+ Background:
7
+ Given a file named "spec/spec_helper.rb" with:
8
+ """
9
+ require "rubygems"
10
+ require "bundler/setup"
11
+ require "reason"
12
+ RSpec.configure do |config|
13
+ config.include Reason::Explanations
14
+ end
15
+ """
16
+
17
+ Scenario: Simple test with a reason
18
+ Given a file named "spec/simple_spec.rb" with:
19
+ """
20
+ require "spec_helper"
21
+
22
+ describe String do
23
+ subject { "a simple string" }
24
+
25
+ it { should respond_to(:to_s) }
26
+ because "sometimes symbols and strings both get to_s called on them"
27
+ end
28
+ """
29
+ When I run `rspec spec`
30
+ Then the example should pass
31
+
32
+ Scenario: More complex matchers with a reason
33
+ Given a file named "spec/simple_spec.rb" with:
34
+ """
35
+ require "spec_helper"
36
+
37
+ describe String do
38
+ subject { "a simple string" }
39
+ let(:welcome_message) { "Hello" }
40
+ let(:name) { "Steve Yadlowsky" }
41
+
42
+ it "should support concatenation" do
43
+ greeting = welcome_message + ", " + name
44
+ greeting.should == "Hello, Steve Yadlowsky"
45
+ end
46
+ because "NaturalLanguageProcessor uses this in its .greeting_generator method"
47
+ end
48
+ """
49
+ When I run `rspec spec`
50
+ Then the example should pass
@@ -0,0 +1,41 @@
1
+ Feature: Documentation formatter support
2
+ As a behaviour driven developer
3
+ When I use `because` to enforce contracts
4
+ I need to be able to see it in my documentation output
5
+
6
+ Background:
7
+ Given a file named "spec/spec_helper.rb" with:
8
+ """
9
+ require "rubygems"
10
+ require "bundler/setup"
11
+ require "reason"
12
+ RSpec.configure do |config|
13
+ config.include Reason::Explanations
14
+ end
15
+ """
16
+
17
+ Scenario: Displaying reason for an "it" block
18
+ Scenario: More complex matchers with a reason
19
+ Given a file named "spec/simple_spec.rb" with:
20
+ """
21
+ require "spec_helper"
22
+
23
+ describe String do
24
+ subject { "a simple string" }
25
+ let(:welcome_message) { "Hello" }
26
+ let(:name) { "Steve Yadlowsky" }
27
+
28
+ it "should support concatenation" do
29
+ greeting = welcome_message + ", " + name
30
+ greeting.should == "Hello, Steve Yadlowsky"
31
+ end
32
+ because "NaturalLanguageProcessor uses this in its .greeting_generator method"
33
+ end
34
+ """
35
+ When I run `rspec spec --format documentation`
36
+ Then it should pass with:
37
+ """
38
+ String
39
+ should support concatenation
40
+ -> because NaturalLanguageProcessor uses this in its .greeting_generator method
41
+ """
@@ -0,0 +1,4 @@
1
+ Then /^the example(?:s)? should(?: all)? pass$/ do
2
+ step %q{the output should contain "0 failures"}
3
+ step %q{the exit status should be 0}
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'aruba/cucumber'
3
+ require 'bundler/setup'
4
+ # require 'rson'
@@ -0,0 +1,5 @@
1
+ module Reason
2
+ def self.version
3
+ "0.0.1"
4
+ end
5
+ end
data/lib/reason.rb ADDED
@@ -0,0 +1,51 @@
1
+ require "reason/version"
2
+ require "rubygems"
3
+ require "rspec/core/formatters/documentation_formatter"
4
+ # require "rson/because"
5
+ module Reason
6
+ module Explanations
7
+ def because(reason)
8
+ example_group = self.examples.last
9
+ Reason::Explanations.add(example_group, reason)
10
+ end
11
+ def self.included(mod)
12
+ mod.extend self
13
+ end
14
+ def self.explanations
15
+ @explanations ||= Hash.new
16
+ end
17
+ def self.add(example, reason)
18
+ explanations[example] ||= Array.new
19
+ explanations[example] << reason
20
+ end
21
+ def self.print_for(example, options={})
22
+ depth = options[:depth] || 0
23
+ indentation = " " * depth
24
+ "#{indentation}-> because #{explanations[example].join("\n#{indentation}->")}"
25
+ end
26
+ end
27
+ end
28
+
29
+ module RSpec
30
+ module Core
31
+ module Formatters
32
+ class DocumentationFormatter < BaseTextFormatter
33
+ alias_method :old_passed, :example_passed
34
+ def example_passed(example)
35
+ old_passed(example)
36
+ output.puts yellow(Reason::Explanations.print_for(example, :depth => @group_level))
37
+ end
38
+ alias_method :old_pending, :example_pending
39
+ def example_pending(example)
40
+ old_pending(example)
41
+ output.puts yellow(Reason::Explanations.print_for(example, :depth => @group_level))
42
+ end
43
+ alias_method :old_failed, :example_failed
44
+ def example_failed(example)
45
+ old_failed(example)
46
+ output.puts yellow(Reason::Explanations.print_for(example, :depth => @group_level))
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
data/reason.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/reason/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Steve Yadlowsky"]
6
+ gem.email = ["steve.yadlowsky@mylookout.com"]
7
+ gem.description = %q{Give meaning to your specifications}
8
+ gem.summary = %q{RSpec unit tests are about enforcing a contract between interacting objects. Manage these contracts when writing your specs}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "reason"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Reason.version
17
+
18
+ gem.add_runtime_dependency "rspec"
19
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reason
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Steve Yadlowsky
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-07-15 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Give meaning to your specifications
35
+ email:
36
+ - steve.yadlowsky@mylookout.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - features/because.feature
50
+ - features/documentation.feature
51
+ - features/step_definitions/additional_cli_steps.rb
52
+ - features/support/env.rb
53
+ - lib/reason.rb
54
+ - lib/reason/version.rb
55
+ - reason.gemspec
56
+ homepage: ""
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.24
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: RSpec unit tests are about enforcing a contract between interacting objects. Manage these contracts when writing your specs
89
+ test_files:
90
+ - features/because.feature
91
+ - features/documentation.feature
92
+ - features/step_definitions/additional_cli_steps.rb
93
+ - features/support/env.rb