rspec-example_steps 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,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ ## RSpec example steps
2
+
3
+ Given/When/Then steps for RSpec examples
4
+
5
+ ### Example
6
+
7
+ require 'rspec/example_steps'
8
+
9
+ context "Searching" do
10
+ Steps "Result found" do
11
+ Given "I am on search page" do
12
+ page.visit("/search")
13
+ page.should have_content("Search")
14
+ end
15
+
16
+ When "I search something" do
17
+ page.fill_in('Search', :with => 'John')
18
+ page.click_button "Go"
19
+ end
20
+
21
+ Then "I should see result" do
22
+ page.should have_content("Result")
23
+ end
24
+ end
25
+ end
26
+
27
+ ### Documentation formatting output:
28
+
29
+ Searching
30
+ User succesfully replaces device
31
+ Given I am on search page
32
+ When I search something
33
+ Then I should see result
34
+
35
+ ## References
36
+
37
+ * [rspec-steps](https://github.com/LRDesign/rspec-steps)
38
+ * [rspec-given](https://github.com/jimweirich/rspec-given)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ module RSpec
2
+ module ExampleSteps
3
+ module BaseFormatter
4
+ def example_step_started(example, type, message)
5
+ end
6
+
7
+ def example_step_passed(example, type, message)
8
+ end
9
+
10
+ def example_step_pending(example, type, message)
11
+ end
12
+
13
+ def example_step_failed(example, type, message)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ module RSpec
2
+ module ExampleSteps
3
+ module DocumentationFormatter
4
+ def self.included(base)
5
+ base.class_eval do
6
+ include InstanceMethods
7
+
8
+ alias :example_started_without_steps :example_started
9
+ alias :example_started :example_started_with_steps
10
+
11
+ alias :example_passed_without_steps :example_passed
12
+ alias :example_passed :example_passed_with_steps
13
+ end
14
+ end
15
+
16
+ module InstanceMethods
17
+ def example_started_with_steps(example)
18
+ example_started_without_steps(example)
19
+
20
+ if example.options[:with_steps]
21
+ full_message = "#{current_indentation}#{example.description}"
22
+ output.puts white(full_message)
23
+ end
24
+ end
25
+
26
+ def example_passed_with_steps(example)
27
+ example_passed_without_steps(example) unless example.options[:with_steps]
28
+ end
29
+
30
+ def example_step_passed(example_group, type, message)
31
+ full_message = "#{current_indentation} #{type.to_s.capitalize} #{message}"
32
+ output.puts green(full_message)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ module RSpec
2
+ module ExampleSteps
3
+ module ExampleGroup
4
+ def Given(message)
5
+ ::RSpec.configuration.reporter.example_step_started(self, :given, message)
6
+ yield
7
+ ::RSpec.configuration.reporter.example_step_passed(self, :given, message)
8
+ end
9
+
10
+ def When(message)
11
+ ::RSpec.configuration.reporter.example_step_started(self, :when, message)
12
+ yield
13
+ ::RSpec.configuration.reporter.example_step_passed(self, :when, message)
14
+ end
15
+
16
+ def Then(message)
17
+ ::RSpec.configuration.reporter.example_step_started(self, :then, message)
18
+ yield
19
+ ::RSpec.configuration.reporter.example_step_passed(self, :then, message)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module RSpec
2
+ module ExampleSteps
3
+ module Reporter
4
+ def example_step_started(example, type, message)
5
+ notify :example_step_started, example, type, message
6
+ end
7
+
8
+ def example_step_passed(example, type, message)
9
+ notify :example_step_passed, example, type, message
10
+ end
11
+
12
+ def example_step_pending(example, type, message)
13
+ notify :example_step_pending, example, type, message
14
+ end
15
+
16
+ def example_step_failed(example, type, message)
17
+ notify :example_step_failed, example, type, message
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ require 'rspec/example_steps/base_formatter'
2
+ require 'rspec/example_steps/documentation_formatter'
3
+ require "rspec/example_steps/example_group"
4
+ require 'rspec/example_steps/reporter'
5
+
6
+ RSpec::Core::Formatters::BaseFormatter.send :include, RSpec::ExampleSteps::BaseFormatter
7
+ RSpec::Core::Formatters::DocumentationFormatter.send :include, RSpec::ExampleSteps::DocumentationFormatter
8
+ RSpec::Core::ExampleGroup.send :include, RSpec::ExampleSteps::ExampleGroup
9
+ RSpec::Core::Reporter.send :include, RSpec::ExampleSteps::Reporter
10
+
11
+ RSpec::Core::ExampleGroup.define_example_method :Steps, :with_steps => true
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "rspec-example_steps"
6
+ s.version = "0.0.1"
7
+ s.authors = ["Andriy Yanko"]
8
+ s.email = ["andriy.yanko@gmail.com"]
9
+ s.homepage = ""
10
+ s.summary = %q{Given/When/Then steps for RSpec examples}
11
+
12
+ s.rubyforge_project = "rspec_example_steps"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency "rspec-core", ">2.0.0"
20
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-example_steps
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
+ - Andriy Yanko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-29 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec-core
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 0
34
+ version: 2.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description:
38
+ email:
39
+ - andriy.yanko@gmail.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - README.md
50
+ - Rakefile
51
+ - lib/rspec/example_steps.rb
52
+ - lib/rspec/example_steps/base_formatter.rb
53
+ - lib/rspec/example_steps/documentation_formatter.rb
54
+ - lib/rspec/example_steps/example_group.rb
55
+ - lib/rspec/example_steps/reporter.rb
56
+ - rspec-example_steps.gemspec
57
+ has_rdoc: true
58
+ homepage: ""
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options: []
63
+
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project: rspec_example_steps
87
+ rubygems_version: 1.5.2
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Given/When/Then steps for RSpec examples
91
+ test_files: []
92
+