macros4cuke 0.2.15 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
data/.simplecov ADDED
@@ -0,0 +1,5 @@
1
+ # .simplecov
2
+ SimpleCov.start do
3
+ # Remove all files that match /spec/ in their path
4
+ add_filter "/spec/"
5
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.16 / 2013-05-04
2
+ * [FEATURE] Added dependency to SimpleCov. It is used to measure test code coverage (the combination of Cucumber and RSpec result in 95.9% code coverage).
3
+ * [CHANGE] File `macro-step-support_spec.rb`: Added one RSpec example
4
+
1
5
  ## 0.2.15 / 2013-05-03
2
6
  * [CHANGE] File `macro-step-support_spec.rb`: Added one RSpec example.
3
7
  * [FIX] Updated gemspec.
@@ -3,7 +3,11 @@
3
3
  # Purpose: Allow Cucumber to load the sample application configuration and hooks.
4
4
  # It also demonstrate what to do in your env.rb file to use the Macros4Cuke gem.
5
5
 
6
-
6
+ begin
7
+ require 'simplecov'
8
+ rescue LoadError
9
+ # Gobble silently the exception if simplecov isn't installed.
10
+ end
7
11
 
8
12
  module DemoMacros4Cuke # Use the module as a namespace
9
13
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Macros4Cuke # Module used as a namespace
5
5
  # The version number of the gem.
6
- Version = '0.2.15'
6
+ Version = '0.2.16'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = "Macros for Cucumber"
@@ -47,7 +47,7 @@ end # class
47
47
  # Raised when one invokes a macro-step with an unknown phrase.
48
48
  class UnknownMacroError < Macros4CukeError
49
49
  def initialize(aPhrase)
50
- super("Unknown macro-step with phrase: '[#{aPhrase}'.")
50
+ super("Unknown macro-step with phrase: '#{aPhrase}'.")
51
51
  end
52
52
  end # class
53
53
 
@@ -9,19 +9,26 @@ module Macros4Cuke # Open the module to avoid lengthy qualified names
9
9
  # Class created just for testing purposes.
10
10
  class MyWorld
11
11
  include Macros4Cuke::MacroStepSupport
12
+
13
+ # The list of encountered sub-steps
14
+ attr_reader(:substeps)
15
+
16
+ # Let's mimicks the behaviour of a Cucumber::RbSupport::RbWorld
17
+ def steps(substep_text)
18
+ @substeps ||= {}
19
+ @substeps << substep_text
20
+ end
21
+
22
+
12
23
  end # class
13
24
 
14
25
  describe MacroStepSupport do
15
- # Rule to build a bland world object
16
- let(:world) do
17
- w = Object.new
18
- w.extend(Macros4Cuke::MacroStepSupport)
19
- w
20
- end
26
+ # Rule to build a custom world object
27
+ let(:world) { MyWorld.new }
21
28
 
22
- context "Defining macro(s):" do
23
- let(:m1_phrase) { "enter the credentials" }
24
- let(:m1_substeps) do
29
+ let(:m1_phrase) { "enter the credentials" }
30
+
31
+ let(:m1_substeps) do
25
32
  ssteps = <<-SNIPPET
26
33
  Given I landed in the homepage
27
34
  When I click "Sign in"
@@ -30,7 +37,9 @@ describe MacroStepSupport do
30
37
  And I click "Submit"
31
38
  SNIPPET
32
39
  ssteps
33
- end
40
+ end
41
+
42
+ context "Defining macro(s):" do
34
43
  it "should add valid new macro" do
35
44
  lambda { world.add_macro(m1_phrase, m1_substeps, true) }.should_not raise_error
36
45
  end
@@ -47,6 +56,28 @@ SNIPPET
47
56
  lambda { world.add_macro("fill in the credentials", m1_substeps, false) }.should raise_error(Macros4Cuke::UnreachableSubstepArgument, error_message)
48
57
  end
49
58
  end # context
59
+
60
+ context "Invoking macro(s)" do
61
+
62
+ it "should complain when invoking an unknown macro-step" do
63
+ phrase_unknown = "dream of a perfect world"
64
+
65
+ error_message = "Unknown macro-step with phrase: 'dream of a perfect world'."
66
+ lambda { world.invoke_macro(phrase_unknown) }.should raise_error( Macros4Cuke::UnknownMacroError, error_message)
67
+ end
68
+
69
+ end # context
70
+
71
+ context "Clearing macro(s)" do
72
+
73
+ it "should clear all macros" do
74
+ lambda { world.clear_macros() }.should_not raise_error
75
+
76
+ # Control the post-condition
77
+ MacroCollection::instance.macro_steps.should be_empty
78
+ end
79
+
80
+ end # context
50
81
 
51
82
  end # describe
52
83
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # File: spec_helper.rb
2
2
  # Purpose: utility file that is loaded by all our RSpec files
3
3
 
4
+ require 'simplecov'
5
+
4
6
 
5
7
  require 'rspec' # Use the RSpec framework
6
8
  require 'pp' # Use pretty-print for debugging purposes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macros4cuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-03 00:00:00.000000000 Z
12
+ date: 2013-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
@@ -43,12 +43,29 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2.00'
46
+ - !ruby/object:Gem::Dependency
47
+ name: simplecov
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.5.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.0
46
62
  description: Create your own macros in your Cucumber scenarios.
47
63
  email:
48
64
  executables: []
49
65
  extensions: []
50
66
  extra_rdoc_files: []
51
67
  files:
68
+ - .simplecov
52
69
  - .yardopts
53
70
  - cucumber.yml
54
71
  - CHANGELOG.md