given_when_then 0.0.1 → 0.0.2

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 CHANGED
@@ -3,4 +3,5 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  TODO.txt
6
+ SNIPPETS.rb
6
7
 
data/README.md CHANGED
@@ -1,86 +1,90 @@
1
- == given_when_then
1
+ # given_when_then
2
2
 
3
3
  Use selected Cucumber-like syntax in your Rspec tests.
4
4
 
5
5
 
6
- == Installation
6
+ ## Installation
7
7
 
8
- In your Gemfile:
8
+ In your Gemfile, under the test group, specify:
9
9
 
10
- group :test do
11
- gem 'given_when_then'
12
- # ...
13
- end
10
+ group :test do
11
+ gem 'given_when_then'
12
+ # ...
13
+ end
14
14
 
15
+ And install with
15
16
 
16
- == Usage
17
+ bundle
17
18
 
18
- If you'd love to use the Cucumber Given-When-Then mantra in your Rspec tests, just use it in place of the describe/it method calls like in this integration test:
19
19
 
20
- describe 'Signing up' do
21
- Given 'there is a guest user' do
22
- let(:user) { stub('user', :name => 'Mr XY', :email => 'xy@example.com', :password => 'secret' ) }
20
+ ## Example Usage
23
21
 
24
- When 'he goes the home page' do
25
- before { visit root_path }
22
+ If you'd love to use the BDD Given-When-Then mantra in your Rspec tests, just use it in place of the describe/it method calls like in this sample integration test:
26
23
 
27
- Then 'he should see the navigational links' do
28
- page.should have_content 'Sign up or Log in'
29
- end
24
+ describe 'Signing up' do
25
+ Given 'there is a guest user' do
26
+ let(:user) { stub('user', :name => 'Mr XY', :email => 'xy@example.com', :password => 'secret' ) }
30
27
 
31
- When 'he clicks the Sign up link' do
32
- before { visit signup_path }
28
+ When 'he goes to the home page' do
29
+ before { visit root_path }
33
30
 
34
- Then 'he should be presented with a signup form' do
35
- page.should have_selector 'div[id="signup_form"]'
31
+ Then 'he should see the navigational links' do
32
+ page.should have_content 'Sign up or Log in'
36
33
  end
37
34
 
38
- When 'he clicks the Sign up button without filling in his credentials' do
39
- Then 'he should see an error message' do
40
- click_button 'Sign up'
41
- page.should have_content('errors prohibited')
42
- User.count.should == 0
43
- end
35
+ When 'he clicks the Sign up link' do
36
+ before { visit signup_path }
44
37
 
45
- And 'the path to the form should be the signup_path (see routes.rb)' do
46
- current_path.should == signup_path
38
+ Then 'he should be presented with a signup form' do
39
+ page.should have_selector 'div[id="signup_form"]'
47
40
  end
48
- end
49
41
 
50
- When 'he fills the form with his credentials and clicks the Sign up button' do
51
- before do
52
- fill_in 'Name', :with => user.name
53
- fill_in 'Email', :with => user.email
54
- fill_in 'Password', :with => user.password
55
- fill_in 'Confirm Password', :with => user.password
56
- click_button 'Sign up'
42
+ When 'he clicks the Sign up button without filling in his credentials' do
43
+ Then 'he should see an error message' do
44
+ click_button 'Sign up'
45
+ page.should have_content('errors prohibited')
46
+ User.count.should == 0
47
+ end
48
+
49
+ And 'the path to the form should be the signup_path (see routes.rb)' do
50
+ current_path.should == signup_path
51
+ end
57
52
  end
58
53
 
59
- Then 'he should be signed up successfully' do
60
- page.should have_content('Signed up!')
61
- current_path.should == root_path
62
- User.count.should == 1
54
+ When 'he fills the form with his credentials and clicks the Sign up button' do
55
+ before do
56
+ fill_in 'Name', :with => user.name
57
+ fill_in 'Email', :with => user.email
58
+ fill_in 'Password', :with => user.password
59
+ fill_in 'Confirm Password', :with => user.password
60
+ click_button 'Sign up'
61
+ end
62
+
63
+ Then 'he should be signed up successfully' do
64
+ page.should have_content('Signed up!')
65
+ current_path.should == root_path
66
+ User.count.should == 1
67
+ end
63
68
  end
64
69
  end
65
70
  end
66
71
  end
67
72
  end
68
- end
69
-
70
-
71
- When you run the test with -fs, then in case of success you get a nicely formatted output:
72
-
73
- Signing up
74
- Given there is a guest user
75
- When he visits the home page
76
- Then he should see the navigational links
77
- When he clicks the Sign up link
78
- Then he should be presented with a signup form
79
- When he clicks the Sign up button without filling in his credentials
80
- Then he should see an error message
81
- And the path to the form should be the signup_path (see routes.rb)
82
- When he fills the form with his credentials and clicks the Sign up button
83
- Then he should be signed up successfully
73
+
74
+
75
+ When you run the test with the -fs option, then in the case of success you get'll a nicely formatted output:
76
+
77
+ Signing up
78
+ Given there is a guest user
79
+ When he visits the home page
80
+ Then he should see the navigational links
81
+ When he clicks the Sign up link
82
+ Then he should be presented with a signup form
83
+ When he clicks the Sign up button without filling in his credentials
84
+ Then he should see an error message
85
+ And the path to the form should be the signup_path (see routes.rb)
86
+ When he fills the form with his credentials and clicks the Sign up button
87
+ Then he should be signed up successfully
84
88
 
85
89
 
86
90
  Given and When are wrappers around Rspec's 'describe', while Then, And and Or wrap Rspec's 'it'.
@@ -17,5 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_runtime_dependency "rspec-core"
20
+ s.add_development_dependency "rspec"
20
21
  end
21
22
 
@@ -1,5 +1,4 @@
1
1
  require "rspec/core"
2
- require "given_when_then/version"
3
2
 
4
3
  module GivenWhenThen
5
4
 
@@ -1,3 +1,4 @@
1
1
  module GivenWhenThen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
4
+
data/spec/gwt_spec.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'given_when_then'
2
+ require 'rspec/core'
3
+
4
+ describe GivenWhenThen do
5
+ describe '#Given' do
6
+ it 'should be defined' do
7
+ lambda { RSpec::Core::ExampleGroup.Given }.should_not raise_exception(NoMethodError)
8
+ end
9
+ end
10
+
11
+ describe '#Then' do
12
+ it 'should be an instance of RSpec::Core::Example' do
13
+ example_group = RSpec::Core::ExampleGroup.Given
14
+ example_group.Then('blah', lambda {}).should be_instance_of RSpec::Core::Example
15
+ end
16
+ end
17
+ end
18
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: given_when_then
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-07 00:00:00.000000000 Z
12
+ date: 2011-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-core
16
- requirement: &82834160 !ruby/object:Gem::Requirement
16
+ requirement: &81673390 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82834160
24
+ version_requirements: *81673390
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &81673130 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *81673130
25
36
  description: Use selected Cucumber-like syntax in your Rspec tests
26
37
  email:
27
38
  - marek.prihoda@gmail.com
@@ -36,6 +47,7 @@ files:
36
47
  - given_when_then.gemspec
37
48
  - lib/given_when_then.rb
38
49
  - lib/given_when_then/version.rb
50
+ - spec/gwt_spec.rb
39
51
  homepage: https://github.com/maprihoda/given_when_then
40
52
  licenses: []
41
53
  post_install_message: