rspec-example_steps 0.2.5 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 560058d2eeca41408e0cc1bf55c6b179b6373dc9
4
- data.tar.gz: 3840525830d82be9f0ba1195ab9ee35d60bb8af3
2
+ SHA256:
3
+ metadata.gz: 40d89f80fb35aef9cfb8ce1d297837dd5f2e098510a46755f44d45319deba587
4
+ data.tar.gz: f2c855602e8d63359ae33d858dd46dd95b0141a0084e3ab4914dc75d30092ab3
5
5
  SHA512:
6
- metadata.gz: 4b1e922a5b487ed69466a392c642ffb6fcc08e2a011bfded641b575669adde8191677d6b8b8208caeb52639cc246ce722724cb72b67fac518cda65c1227a611f
7
- data.tar.gz: 9d86dff6f94cb42bd9ab53a208f7356e01c282f9796026eb18a172c59037286ec0e14d39072a5970d37a84155cb5108ef9cf00ef8e12ed8a4a5dc1006509e761
6
+ metadata.gz: bed8ec04b2ef510309947ff90d237f155f11689a78c49cdaa4f5bee4501e4e1db1409b6c550260cca62c0f4dccfcd3b52ce07e4c863ed7f9ab18f430e068d154
7
+ data.tar.gz: a89bc4a8f02b55613a19a7821f6dabf8ed1d85209f6c2dea239add358a7bb50da357218e6c649ab69c8de2155ce4f8148bd0300e8d2debaff01b2bc3a68fa1c7
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 3.1.1
4
+
5
+ * Remove missing stuff of shared_steps feature
6
+
7
+ ## 3.1.0
8
+
9
+ * Remove shared_steps feature
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rspec', '2.14.0'
5
+ gem 'rspec', '3.0.0'
data/README.md CHANGED
@@ -2,133 +2,88 @@
2
2
 
3
3
  Given/When/Then/And/But steps for RSpec examples
4
4
 
5
- ### Example
6
-
7
- require 'rspec/example_steps'
5
+ ### Description
8
6
 
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
7
+ This gem brings two major functionality to your `spec/features`
15
8
 
16
- When "I search something" do
17
- page.fill_in('Search', :with => 'John')
18
- page.click_button "Go"
19
- end
9
+ * Verbosity for rspec documentation formatter.
10
+ * Ability to comment or describe set of actions in example into some step.
20
11
 
21
- Then "I should see result" do
22
- page.should have_content("Result")
23
- end
24
- end
25
- end
26
-
27
- ### Documentation formatting output:
12
+ ### Installation
28
13
 
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
14
+ * For rspec v2 use gem **v0.2.x** or rspec2 branch
15
+ * For rspec v3 use gem **v3.x.x** or master branch
34
16
 
17
+ ```ruby
18
+ gem 'rspec-example_steps'
19
+ ```
35
20
 
36
- ### Shared steps
21
+ Add to `spec/spec_helper.rb`
37
22
 
38
- Use _shared_steps_ do define block that will be evaluated in the context of example using _include_steps_.
23
+ ```ruby
24
+ require 'rspec/example_steps'
25
+ ```
39
26
 
40
- Shared _steps_ behavior is simular to shared _example_ but context is example nor example_group.
27
+ ### Example
41
28
 
42
- ### Example with shared steps
29
+ `spec/features/search_spec.rb`
43
30
 
44
- shared_steps "login" do
45
- When "I go to login page" do
46
- page.visit '/login'
47
- end
48
- When "I put credentials" do
49
- page.fill_in 'Login', :with => 'jack@example.com'
50
- page.fill_in 'Password', :with => 'password''
51
- end
52
- Then "I should be logged in" do
53
- page.status_code.should == 200
54
- page.should have_content("Welcome jack@example.com")
55
- end
31
+ ```ruby
32
+ context 'Searching' do
33
+ Steps 'Result found' do
34
+ Given 'I am on search page' do
35
+ visit '/search'
36
+ expect(page).to have_content('Search')
56
37
  end
57
38
 
58
- shared_steps "logout" do
59
- page.visit '/logout'
60
- page.status_code.should == 200
39
+ When 'I search something' do
40
+ fill_in 'Search', with: 'John'
41
+ click_button 'Go'
61
42
  end
62
43
 
63
- context "user flow"
64
- Steps "User updates profile description" do
65
- include_steps "login"
66
- When "I update profile description" do
67
- ...
68
- end
69
- include_steps "logout"
70
- end
71
-
72
- Steps "User updates profile avatar" do
73
- include_steps "login"
74
- When "I update profile avatar" do
75
- ...
76
- end
77
- include_steps "logout"
78
- end
44
+ Then 'I should see result' do
45
+ expect(page).to have_content('Result')
79
46
  end
47
+ end
48
+ end
49
+ ```
80
50
 
81
- ### Passing arguments to shared steps
82
-
83
- It's possible to customize shared steps. See example
84
-
85
- ### Example with shared steps with arguments
86
-
87
- shared_steps "login" do |email, password|
88
- When "I go to login page" do
89
- page.visit '/login'
90
- end
91
- When "I put credentials" do
92
- page.fill_in 'Login', :with => email
93
- page.fill_in 'Password', :with => password
94
- end
95
- end
51
+ ### Documentation formatting output:
96
52
 
97
- shared_steps "invalid login" do
98
- Then "I should see login error" do
99
- ...
100
- end
101
- end
102
-
103
- Steps "User provides wrong email" do
104
- include_steps "login", 'jack', 'qwerty'
105
- include_steps "invalid login"
106
- end
107
-
108
- Steps "User provides wrong password" do
109
- include_steps "login", 'jack@example.com', 'bla'
110
- include_steps "invalid login"
111
- end
53
+ `rspec -fd spec/features/search_spec.rb`
112
54
 
55
+ <pre>
56
+ Searching
57
+ User succesfully replaces device
58
+ Given I am on search page
59
+ When I search something
60
+ Then I should see result
61
+ </pre>
113
62
 
114
63
  ### Pending steps
115
64
 
116
65
  Simular to Example :pending behavior:
117
66
 
118
- Steps "User login" do
119
- # just skip block
120
- When "I go to login"
67
+ ```ruby
68
+ Steps 'User login' do
69
+ # just skip block
70
+ When 'I go to login'
121
71
 
122
- # pass :pending => true option
123
- Then "I should see welcome", :pending => true do
124
- ...
125
- end
72
+ # pass pending: true option
73
+ Then 'I should see welcome', pending: true do
74
+ ...
75
+ end
126
76
 
127
- # pass :pending => "some pending message"
128
- Then "I should see last login IP", :pending => "WIP" do
129
- ...
130
- end
131
- end
77
+ # pass pending: 'some pending message'
78
+ Then 'I should see last login IP', pending: 'WIP' do
79
+ ...
80
+ end
81
+ end
82
+ ```
83
+
84
+ ## Authors
85
+
86
+ * [Andriy Yanko](http://ayanko.github.io)
132
87
 
133
88
  ## License
134
89
 
@@ -1,27 +1,22 @@
1
1
  require 'rspec/core'
2
- require 'rspec/core/formatters/base_formatter'
2
+ require 'rspec/core/formatters'
3
+ require 'rspec/core/formatters/console_codes'
3
4
  require 'rspec/core/formatters/documentation_formatter'
4
5
  require 'rspec/core/example_group'
5
6
  require 'rspec/core/reporter'
6
- require 'rspec/core/world'
7
7
 
8
- require 'rspec/example_steps/base_formatter'
9
8
  require 'rspec/example_steps/documentation_formatter'
10
9
  require 'rspec/example_steps/example_group'
10
+ require 'rspec/example_steps/notification'
11
11
  require 'rspec/example_steps/reporter'
12
- require 'rspec/example_steps/world'
13
12
 
14
- RSpec::Core::Formatters::BaseFormatter.send :include, RSpec::ExampleSteps::BaseFormatter
15
13
  RSpec::Core::Formatters::DocumentationFormatter.send :include, RSpec::ExampleSteps::DocumentationFormatter
16
14
  RSpec::Core::ExampleGroup.send :include, RSpec::ExampleSteps::ExampleGroup
17
15
  RSpec::Core::Reporter.send :include, RSpec::ExampleSteps::Reporter
18
- RSpec::Core::World.send :include, RSpec::ExampleSteps::World
19
16
 
20
- if RSpec::Core::ExampleGroup.singleton_class.respond_to?(:define_example_method, true)
21
- RSpec::Core::ExampleGroup.singleton_class.define_example_method :Steps, :with_steps => true
22
- else
23
- RSpec::Core::ExampleGroup.define_example_method :Steps, :with_steps => true
24
- end
17
+ RSpec::Core::ExampleGroup.define_example_method :Steps, with_steps: true
25
18
 
26
- require 'rspec/example_steps/shared_steps'
27
- include RSpec::ExampleSteps::SharedSteps
19
+ if formatter = RSpec.world.reporter.find_registered_formatter(RSpec::Core::Formatters::DocumentationFormatter)
20
+ RSpec.world.reporter.register_listener formatter,
21
+ :example_started, :example_step_passed, :example_step_pending, :example_step_failed
22
+ end
@@ -14,55 +14,42 @@ module RSpec
14
14
  end
15
15
 
16
16
  module InstanceMethods
17
- def example_started_with_steps(example)
18
- example_started_without_steps(example)
17
+ def example_started(notification)
18
+ end
19
+
20
+ def example_started_with_steps(notification)
21
+ example_started_without_steps(notification)
19
22
 
20
- if example.options[:with_steps]
21
- full_message = "#{current_indentation}#{example.description}"
22
- if respond_to?(:default_color, true)
23
- output.puts default_color(full_message)
24
- else
25
- output.puts white(full_message)
26
- end
23
+ if notification.example.metadata[:with_steps]
24
+ full_message = "#{current_indentation}#{notification.example.description}"
25
+ output.puts Core::Formatters::ConsoleCodes.wrap(full_message, :default)
27
26
  end
28
27
  end
29
28
 
30
- def example_passed_with_steps(example)
31
- example_passed_without_steps(example) unless example.options[:with_steps]
29
+ def example_passed_with_steps(notification)
30
+ example_passed_without_steps(notification) unless notification.example.metadata[:with_steps]
32
31
  end
33
32
 
34
- def example_step_passed(example_group, type, message, options)
35
- full_message = "#{current_indentation} #{type.to_s.capitalize} #{message}"
36
- if respond_to?(:success_color, true)
37
- output.puts success_color(full_message)
38
- else
39
- output.puts green(full_message)
40
- end
33
+ def example_step_passed(notification)
34
+ full_message = "#{current_indentation} #{notification.type.to_s.capitalize} #{notification.message}"
35
+ output.puts Core::Formatters::ConsoleCodes.wrap(full_message, :success)
41
36
  end
42
37
 
43
- def example_step_pending(example_group, type, message, options)
44
- full_message = "#{current_indentation} #{type.to_s.capitalize} #{message}"
38
+ def example_step_pending(notification)
39
+ full_message = "#{current_indentation} #{notification.type.to_s.capitalize} #{notification.message}"
45
40
 
46
- if options[:pending] && options[:pending] != true
47
- full_message << " (PENDING: #{options[:pending]})"
41
+ if notification.options[:pending] && notification.options[:pending] != true
42
+ full_message << " (PENDING: #{notification.options[:pending]})"
48
43
  else
49
44
  full_message << " (PENDING)"
50
45
  end
51
46
 
52
- if respond_to?(:pending_color, true)
53
- output.puts pending_color(full_message)
54
- else
55
- output.puts yellow(full_message)
56
- end
47
+ output.puts Core::Formatters::ConsoleCodes.wrap(full_message, :pending)
57
48
  end
58
49
 
59
- def example_step_failed(example_group, type, message, options)
60
- full_message = "#{current_indentation} #{type.to_s.capitalize} #{message} (FAILED)"
61
- if respond_to?(:failure_color, true)
62
- output.puts failure_color(full_message)
63
- else
64
- output.puts red(full_message)
65
- end
50
+ def example_step_failed(notification)
51
+ full_message = "#{current_indentation} #{notification.type.to_s.capitalize} #{notification.message} (FAILED)"
52
+ output.puts Core::Formatters::ConsoleCodes.wrap(full_message, :failure)
66
53
  end
67
54
  end
68
55
  end
@@ -1,88 +1,25 @@
1
1
  module RSpec
2
2
  module ExampleSteps
3
3
  module ExampleGroup
4
- def include_steps(*args)
5
- name = args.shift
6
- shared_block = RSpec.world.shared_example_steps[name]
7
- shared_block or raise ArgumentError, "Could not find shared steps #{name.inspect}"
8
- instance_eval_with_args(*args, &shared_block)
4
+ def Given(message, options = {}, &block)
5
+ RSpec.world.reporter.process_example_step(self, :given, message, options, &block)
9
6
  end
10
7
 
11
- def Given(message, options = {})
12
- RSpec.world.reporter.example_step_started(self, :given, message, options)
13
- if block_given? && !options[:pending]
14
- begin
15
- yield
16
- rescue Exception => e
17
- RSpec.world.reporter.example_step_failed(self, :given, message, options)
18
- raise e
19
- end
20
- RSpec.world.reporter.example_step_passed(self, :given, message, options)
21
- else
22
- RSpec.world.reporter.example_step_pending(self, :given, message, options)
23
- end
8
+ def When(message, options = {}, &block)
9
+ RSpec.world.reporter.process_example_step(self, :when, message, options, &block)
24
10
  end
25
11
 
26
- def When(message, options = {})
27
- RSpec.world.reporter.example_step_started(self, :when, message, options)
28
- if block_given? && !options[:pending]
29
- begin
30
- yield
31
- rescue Exception => e
32
- RSpec.world.reporter.example_step_failed(self, :when, message, options)
33
- raise e
34
- end
35
- RSpec.world.reporter.example_step_passed(self, :when, message, options)
36
- else
37
- RSpec.world.reporter.example_step_pending(self, :when, message, options)
38
- end
12
+ def Then(message, options = {}, &block)
13
+ RSpec.world.reporter.process_example_step(self, :then, message, options, &block)
39
14
  end
40
15
 
41
- def Then(message, options = {})
42
- RSpec.world.reporter.example_step_started(self, :then, message, options)
43
- if block_given? && !options[:pending]
44
- begin
45
- yield
46
- rescue Exception => e
47
- RSpec.world.reporter.example_step_failed(self, :then, message, options)
48
- raise e
49
- end
50
- RSpec.world.reporter.example_step_passed(self, :then, message, options)
51
- else
52
- RSpec.world.reporter.example_step_pending(self, :then, message, options)
53
- end
16
+ def And(message, options = {}, &block)
17
+ RSpec.world.reporter.process_example_step(self, :and, message, options, &block)
54
18
  end
55
19
 
56
- def And(message, options = {})
57
- RSpec.world.reporter.example_step_started(self, :and, message, options)
58
- if block_given? && !options[:pending]
59
- begin
60
- yield
61
- rescue Exception => e
62
- RSpec.world.reporter.example_step_failed(self, :and, message, options)
63
- raise e
64
- end
65
- RSpec.world.reporter.example_step_passed(self, :and, message, options)
66
- else
67
- RSpec.world.reporter.example_step_pending(self, :and, message, options)
68
- end
20
+ def But(message, options = {}, &block)
21
+ RSpec.world.reporter.process_example_step(self, :but, message, options, &block)
69
22
  end
70
-
71
- def But(message, options = {})
72
- RSpec.world.reporter.example_step_started(self, :but, message, options)
73
- if block_given? && !options[:pending]
74
- begin
75
- yield
76
- rescue Exception => e
77
- RSpec.world.reporter.example_step_failed(self, :but, message, options)
78
- raise e
79
- end
80
- RSpec.world.reporter.example_step_passed(self, :but, message, options)
81
- else
82
- RSpec.world.reporter.example_step_pending(self, :but, message, options)
83
- end
84
- end
85
-
86
23
  end
87
24
  end
88
25
  end
@@ -0,0 +1,6 @@
1
+ module RSpec
2
+ module ExampleSteps
3
+ class Notification < Struct.new(:example, :type, :message, :options)
4
+ end
5
+ end
6
+ end
@@ -1,29 +1,44 @@
1
1
  module RSpec
2
2
  module ExampleSteps
3
3
  module Reporter
4
- def self.included(base)
5
- base::NOTIFICATIONS.push(
6
- :example_step_started,
7
- :example_step_passed,
8
- :example_step_pending,
9
- :example_step_failed
10
- ) if base.constants.include?(:NOTIFICATIONS)
4
+ def process_example_step(example, type, message, options)
5
+ example_step_started(self, type, message, options)
6
+
7
+ if block_given? && !options[:pending]
8
+ begin
9
+ yield
10
+ rescue Exception => e
11
+ example_step_failed(self, type, message, options)
12
+ raise e
13
+ end
14
+ example_step_passed(self, type, message, options)
15
+ else
16
+ example_step_pending(self, type, message, options)
17
+ end
11
18
  end
12
19
 
13
20
  def example_step_started(example, type, message, options)
14
- notify :example_step_started, example, type, message, options
21
+ notify :example_step_started, Notification.new(example, type, message, options)
15
22
  end
16
23
 
17
24
  def example_step_passed(example, type, message, options)
18
- notify :example_step_passed, example, type, message, options
25
+ notify :example_step_passed, Notification.new(example, type, message, options)
19
26
  end
20
27
 
21
28
  def example_step_pending(example, type, message, options)
22
- notify :example_step_pending, example, type, message, options
29
+ notify :example_step_pending, Notification.new(example, type, message, options)
23
30
  end
24
31
 
25
32
  def example_step_failed(example, type, message, options)
26
- notify :example_step_failed, example, type, message, options
33
+ notify :example_step_failed, Notification.new(example, type, message, options)
34
+ end
35
+
36
+ def registered_formatters
37
+ @listeners.values.map(&:to_a).flatten.uniq
38
+ end
39
+
40
+ def find_registered_formatter(klass)
41
+ registered_formatters.detect { |formatter| formatter.class == klass }
27
42
  end
28
43
  end
29
44
  end
@@ -2,19 +2,20 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "rspec-example_steps"
6
- s.version = "0.2.5"
7
- s.authors = ["Andriy Yanko"]
8
- s.email = ["andriy.yanko@gmail.com"]
9
- s.homepage = "https://github.com/railsware/rspec-example_steps"
5
+ s.name = 'rspec-example_steps'
6
+ s.version = '3.1.1'
7
+ s.authors = ['Andriy Yanko']
8
+ s.email = ['andriy.yanko@gmail.com']
9
+ s.homepage = 'https://github.com/railsware/rspec-example_steps'
10
10
  s.summary = %q{Given/When/Then steps for RSpec examples}
11
+ s.license = 'MIT'
11
12
 
12
- s.rubyforge_project = "rspec_example_steps"
13
+ s.rubyforge_project = 'rspec_example_steps'
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
18
+ s.require_paths = ['lib']
18
19
 
19
- s.add_runtime_dependency "rspec-core", ">2.0.0"
20
+ s.add_runtime_dependency 'rspec-core', '>=3.0.0'
20
21
  end
@@ -25,11 +25,11 @@ describe "example steps" do
25
25
  @but = "But value"
26
26
  end
27
27
 
28
- @thing.should == "Given value"
29
- @action.should == "When value"
30
- @result.should == "Then value"
31
- @and.should == "And value"
32
- @but.should == "But value"
28
+ expect(@thing).to eq("Given value")
29
+ expect(@action).to eq("When value")
30
+ expect(@result).to eq("Then value")
31
+ expect(@and).to eq("And value")
32
+ expect(@but).to eq("But value")
33
33
  end
34
34
  end
35
35
 
@@ -113,7 +113,7 @@ describe "example steps" do
113
113
 
114
114
  Steps "When fails" do
115
115
  When "action" do
116
- (2*2).should == 5
116
+ expect(2*2).to eq(5)
117
117
  end
118
118
 
119
119
  Then "I should see error" do
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Usual example' do
4
+ subject { 2 + 2 }
5
+
6
+ context 'success' do
7
+ specify { expect(subject).to eq(4) }
8
+ end
9
+
10
+ context 'failed' do
11
+ specify { expect(subject).to eq(5) }
12
+ end
13
+
14
+ context 'pending' do
15
+ it 'should be pending'
16
+ end
17
+ end
metadata CHANGED
@@ -1,76 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-example_steps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andriy Yanko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-29 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>'
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>'
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
27
- description:
26
+ version: 3.0.0
27
+ description:
28
28
  email:
29
29
  - andriy.yanko@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
+ - CHANGELOG.md
35
36
  - Gemfile
36
37
  - LICENSE
37
38
  - README.md
38
39
  - Rakefile
39
40
  - lib/rspec/example_steps.rb
40
- - lib/rspec/example_steps/base_formatter.rb
41
41
  - lib/rspec/example_steps/documentation_formatter.rb
42
42
  - lib/rspec/example_steps/example_group.rb
43
+ - lib/rspec/example_steps/notification.rb
43
44
  - lib/rspec/example_steps/reporter.rb
44
- - lib/rspec/example_steps/shared_steps.rb
45
- - lib/rspec/example_steps/world.rb
46
45
  - rspec-example_steps.gemspec
47
46
  - spec/example_steps_spec.rb
48
- - spec/shared_steps_spec.rb
47
+ - spec/regression_spec.rb
49
48
  - spec/spec_helper.rb
50
49
  homepage: https://github.com/railsware/rspec-example_steps
51
- licenses: []
50
+ licenses:
51
+ - MIT
52
52
  metadata: {}
53
- post_install_message:
53
+ post_install_message:
54
54
  rdoc_options: []
55
55
  require_paths:
56
56
  - lib
57
57
  required_ruby_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubyforge_project: rspec_example_steps
69
- rubygems_version: 2.0.3
70
- signing_key:
68
+ rubygems_version: 3.1.4
69
+ signing_key:
71
70
  specification_version: 4
72
71
  summary: Given/When/Then steps for RSpec examples
73
72
  test_files:
74
73
  - spec/example_steps_spec.rb
75
- - spec/shared_steps_spec.rb
74
+ - spec/regression_spec.rb
76
75
  - spec/spec_helper.rb
@@ -1,17 +0,0 @@
1
- module RSpec
2
- module ExampleSteps
3
- module BaseFormatter
4
- def example_step_started(example, type, message, options)
5
- end
6
-
7
- def example_step_passed(example, type, message, options)
8
- end
9
-
10
- def example_step_pending(example, type, message, options)
11
- end
12
-
13
- def example_step_failed(example, type, message, options)
14
- end
15
- end
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- module RSpec
2
- module ExampleSteps
3
- module SharedSteps
4
-
5
- def shared_steps(name, &block)
6
- ensure_shared_example_steps_name_not_taken(name)
7
- RSpec.world.shared_example_steps[name] = block
8
- end
9
-
10
- private
11
-
12
- def ensure_shared_example_steps_name_not_taken(name)
13
- if RSpec.world.shared_example_steps.has_key?(name)
14
- raise ArgumentError.new("Shared example steps '#{name}' already exists")
15
- end
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,9 +0,0 @@
1
- module RSpec
2
- module ExampleSteps
3
- module World
4
- def shared_example_steps
5
- @shared_example_steps ||= {}
6
- end
7
- end
8
- end
9
- end
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_steps "push steps" do
4
- Given "empty pipe" do
5
- pipe.clear
6
- end
7
-
8
- When "push data" do
9
- pipe.push "hello"
10
- end
11
-
12
- Then "pipe should have data" do
13
- pipe.items.should == ["hello"]
14
- end
15
- end
16
-
17
- shared_steps "push with arguments steps" do |value|
18
- When "push data" do
19
- pipe.push value
20
- end
21
- end
22
-
23
- shared_steps "pull steps" do
24
- When "pull data" do
25
- pipe.pull
26
- end
27
-
28
- Then "pipe should be empty" do
29
- pipe.items.should == []
30
- end
31
- end
32
-
33
- describe "shared steps" do
34
-
35
- let(:pipe) do
36
- Class.new do
37
- def initialize
38
- @values = []
39
- end
40
-
41
- def items
42
- @values
43
- end
44
-
45
- def clear
46
- @values = []
47
- end
48
-
49
- def push(value)
50
- @values << value
51
- end
52
-
53
- def pull
54
- @values.shift
55
- end
56
-
57
- end.new
58
- end
59
-
60
- Steps "push and pull steps" do
61
- include_steps "push steps"
62
- include_steps "pull steps"
63
- end
64
-
65
- Steps "push, count and pull" do
66
- include_steps "push steps"
67
- Then "pipe should have 1 item" do
68
- pipe.items.size.should == 1
69
- end
70
- include_steps "pull steps"
71
- end
72
-
73
- Steps "push with arguments and pull" do
74
- include_steps "push with arguments steps", "hi"
75
- pipe.items.should == ["hi"]
76
- include_steps "pull steps"
77
- end
78
- end