scenario_context 0.0.1.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8183e3de69e84bb02f42de44f9421d85a9debea4
4
+ data.tar.gz: 0eaa8934a8bfbc17a02bac2151effe1d9bb7a9a7
5
+ SHA512:
6
+ metadata.gz: 451e398c513c6e7e56d8b5c7f0a979a51b286b6db8f30132068639e2882b5dd7c80b03974418d80fb950f2680ffd8434979fe7fe41a5d9e093f087b210b6f6c3
7
+ data.tar.gz: 44e316dc0e2224022640afc313b67c6ab523d21432ce7c4ce9555ddecf29f2e8fa7ff39378da53d392cad064c1b8c7bab634031afc168726a4b64c24c339e6e4
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,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Erran Carey
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
+ # ScenarioContext
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'scenario_context'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install scenario_context
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. [Fork it](http://github.com/erran/scenario_context/fork)
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,48 @@
1
+ # A class that holds useful debug information from a Scenario or Scenario
2
+ # Outline
3
+ class ScenarioContext
4
+ # A generic interface to a Scenario or ExampleRow
5
+ ScenarioProxy = Struct.new(:scenario) do
6
+ # @return [String] the file name colon line number representation of the
7
+ # scenario
8
+ def file_colon_line
9
+ if outline?
10
+ scenario.file_colon_line
11
+ else
12
+ scenario.scenario_outline.file_colon_line
13
+ end
14
+ end
15
+
16
+ # @raise [NotImplementedError] unless the scenario is an outline
17
+ # @return [Boolean] scenario.scenario_outline if the scenario is an outline
18
+ def outline
19
+ unless outline?
20
+ fail(
21
+ NotImplementedError,
22
+ 'ScenarioContext#outline is only available for scenario outlines.'
23
+ )
24
+ end
25
+
26
+ scenario.scenario_outline
27
+ end
28
+
29
+ # @return [Boolean] whether @scenario is an outline (ExampleRow) or a not
30
+ def outline?
31
+ return unless defined?(Cucumber::Ast::OutlineTable::ExampleRow)
32
+
33
+ scenario.is_a?(Cucumber::Ast::OutlineTable::ExampleRow)
34
+ end
35
+
36
+ # @return [String] the title of the scenario or a pretty scenario "title"
37
+ # if @scenario is an outline
38
+ def title
39
+ if outline?
40
+ scenario_name = scenario.name.match(/\| (.*) \|/)[1]
41
+ "#{outline.title}: #{scenario_name}"
42
+ else
43
+ scenario.title
44
+ end
45
+ end
46
+ alias_method :name, :title
47
+ end
48
+ end
@@ -0,0 +1,6 @@
1
+ # A class that holds useful debug information from a Scenario or Scenario
2
+ # Outline
3
+ class ScenarioContext
4
+ # The version of the scenario_context gem
5
+ VERSION = '0.0.1.beta.1'
6
+ end
@@ -0,0 +1,54 @@
1
+ require 'scenario_context/scenario_proxy'
2
+
3
+ # A class that holds useful debug information from a Scenario or Scenario
4
+ # Outline
5
+ class ScenarioContext
6
+ # @!attribute [r] scenario
7
+ # @return [Scenario,ExampleRow]
8
+ attr_reader :scenario
9
+
10
+ def initialize(scenario)
11
+ @scenario = ScenarioProxy.new(scenario)
12
+ end
13
+
14
+ # Sets @scenario as the scenario/outline wrapped in a proxy object
15
+ #
16
+ # @param [Scenario,ExampleRow,ScenarioProxy] scenario the scenario to
17
+ # set @scenario to
18
+ # @return [ScenarioProxy] a scenario proxy object that holds the scenario or
19
+ # scenario outline
20
+ def scenario=(scenario)
21
+ @scenario =
22
+ if scenario.is_a?(ScenarioProxy)
23
+ scenario
24
+ else
25
+ ScenarioProxy.new(scenario)
26
+ end
27
+ end
28
+
29
+ # @return [Boolean] true if the method is available or whether @scenario
30
+ # responds to the method
31
+ def respond_to_missing?(method_name, include_private = false)
32
+ super || scenario.respond_to?(method_name, include_private) || original_scenario.respond_to?(method_name, include_private)
33
+ end
34
+
35
+ private
36
+
37
+ # @raise [NoMethodError] if @scenario could not respond to the missing
38
+ # method
39
+ # @return the return value of the method after sending it to @scenario
40
+ def method_missing(method_name, *args, &block)
41
+ if scenario.respond_to?(method_name)
42
+ scenario.send(method_name, *args, &block)
43
+ elsif original_scenario.respond_to?(method_name)
44
+ original_scenario.send(method_name, *args, &block)
45
+ else
46
+ super
47
+ end
48
+ end
49
+
50
+ # @return the native ExampleRow or Scenario object
51
+ def original_scenario
52
+ scenario.scenario
53
+ end
54
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'scenario_context/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'scenario_context'
9
+ spec.version = ScenarioContext::VERSION
10
+ spec.authors = ['Erran Carey']
11
+ spec.email = ['me@errancarey.com']
12
+ spec.description = %q(This gem provides ScenarioContext)
13
+ spec.summary = %q(This gem provides ScenarioContext)
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = %w(lib)
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'cucumber'
24
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scenario_context
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.beta.1
5
+ platform: ruby
6
+ authors:
7
+ - Erran Carey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-10 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cucumber
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This gem provides ScenarioContext
42
+ email:
43
+ - me@errancarey.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/scenario_context.rb
54
+ - lib/scenario_context/scenario_proxy.rb
55
+ - lib/scenario_context/version.rb
56
+ - scenario_context.gemspec
57
+ homepage: ''
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">"
73
+ - !ruby/object:Gem::Version
74
+ version: 1.3.1
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.0
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: This gem provides ScenarioContext
81
+ test_files: []
82
+ has_rdoc: