m-spec 0.1.0 → 0.1.5

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
2
  SHA256:
3
- metadata.gz: 92375890d1da886c3ae53626b708eba8d93d00076dabd9dc9f2282f67d860032
4
- data.tar.gz: 62918be644fb75c3d5831c2884cfdf6099203c59cc31bce3129a1566d4b2c6f6
3
+ metadata.gz: fe47e5d229c865a8619c6f62bc61d85535df6455cdc3f6c6c3f4c23071b633bd
4
+ data.tar.gz: 4a9085d8178b12ef11170b053f8e17d27a8e8a0666219541a3937f616af133f6
5
5
  SHA512:
6
- metadata.gz: 332454bdef60665103d66612748d42b9a6bd1af25c96228ae2b0009c236af8871f1d809100ad20905ef4d217ef65e9ecc9a64be6a35a88aab21579447cf59680
7
- data.tar.gz: ae2b63dac9719375fa1bc286c43b0b9410ec9cc1e5a08c350301da9aa08e1f8032987315eb62a5f6f2d925cbb8d5a5dfb2133b79b1b0aab89d78930824340725
6
+ metadata.gz: 0a9982cf39b798aadc96fb67629bfc77935e4e417b22843a9bf411a5cc5431a64378e98ac3610eb6e34ebe2c92f1bc8072324baae2cbb7c77c2df2a6169045f0
7
+ data.tar.gz: c20edd5f8e4f083bdc675d16ed844069c15386a4e78056c2c7017c6c9930a2bd4961d7df130ecd13368a798a81a8a7fc3b80e4c445e2c27c00f3c6e9c43f1560
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Mspec
2
2
 
3
- The lightest-weight spec framework in ruby
3
+ The lightest-weight spec framework in ruby. Built for learning at [Makers](https://makers.tech). You have one matcher, the comparison matcher, and test setup and teardown is your responsibility. For additional features, you must extend the gem.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'mspec'
10
+ gem 'm-spec'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,7 +16,7 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install mspec
19
+ $ gem install m-spec
20
20
 
21
21
  ## Usage
22
22
 
@@ -37,7 +37,7 @@ describe 'The Animal' do
37
37
  expect(animal.roar).to eq "ROAAAARRRR!"
38
38
  end
39
39
 
40
- it 'gives a lovely red when it fails' do
40
+ it 'fails nicely' do
41
41
  animal = Animal.new
42
42
  expect(animal.roar).to eq "little roar!"
43
43
  end
@@ -55,31 +55,49 @@ end
55
55
  To run your specs, pass the spec file directly as an argument. You have to run individual spec files.
56
56
 
57
57
  ```sh
58
- $ mspec ./spec/animal_spec.rb
58
+ $ m-spec ./spec/animal_spec.rb
59
59
  ```
60
60
 
61
61
  ```
62
62
  The Animal
63
63
  returns a string
64
64
  fails nicely
65
- /path/to/directory/app/spec/animal_spec.rb:11:in block (2 levels) in <top (required)>'
65
+ Expected: ROAAAARRRR!
66
+ Got: little roar!
67
+ # /path/to/directory/spec/animal_spec.rb:11:in `block (2 levels) in <top (required)>'
66
68
  stubbing
67
69
  we can mock too!
68
70
  ```
69
71
 
70
- It's got simple one-level indentation and simple colour coding for test passes and failures. Failures will give you only the spec file path and line number.
72
+ It's got simple one-level indentation, simple colour coding for test passes and failures, and simple failure messages with expected and actual values and the failing spec file path and line number.
71
73
 
72
- Remember - you'll have to manage test setup and test cleanup yourself, while keeping your test code dry also yourself. Make sure each test runs in isolation.
74
+ Remember - you'll have to manage yourself: test setup and teardown, keeping test code dry, each test running in isolation, and loading source code properly.
73
75
 
74
- ## Development
76
+ ## Extending
75
77
 
76
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+ After checking out the repo
79
+ ```sh
80
+ $ git clone git@github.com:dearshrewdwit/m-spec.git
81
+ $ cd m-spec
82
+ ```
83
+ Add more matchers, or extend the mocking library. Then build locally and use.
84
+ ```sh
85
+ bundle exec rake build --trace
86
+ gem install pkg/m-spec-[version].gem
87
+ m-spec [spec-file]
88
+ ```
89
+
90
+ ## Pushing to Rubygems
91
+ Sign up for an account, check for the gem name you want, change the gem metadata to represent what you want, and then follow the hints and errors when you
92
+ ```sh
93
+ $ bundle exec rake release
94
+ ```
77
95
 
78
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
96
+ [Bundler docs](https://bundler.io/guides/creating_gem.html) are a good resource, as are the [rubygems docs](https://guides.rubygems.org/publishing/)
79
97
 
80
98
  ## Contributing
81
99
 
82
- Bug reports and pull requests are welcome on GitHub at https://github.com/dearshrewdwit/mspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dearshrewdwit/m-spec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
83
101
 
84
102
  ## License
85
103
 
@@ -87,4 +105,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
87
105
 
88
106
  ## Code of Conduct
89
107
 
90
- Everyone interacting in the Mspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dearshrewdwit/mspec/blob/master/CODE_OF_CONDUCT.md).
108
+ Everyone interacting in the Mspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dearshrewdwit/m-spec/blob/master/CODE_OF_CONDUCT.md).
@@ -1,5 +1,7 @@
1
1
  module Mspec
2
2
  class Expect
3
+ attr_reader :value
4
+
3
5
  def initialize(value)
4
6
  @value = value
5
7
  end
@@ -11,7 +13,7 @@ module Mspec
11
13
  data = e
12
14
  end
13
15
 
14
- SpecResult.new(data)
16
+ SpecResult.new(self, matcher, data)
15
17
  end
16
18
  end
17
19
  end
@@ -1,6 +1,7 @@
1
1
  COLOUR_CODES = {
2
- true => 32,
3
- false => 31
2
+ green: 32,
3
+ red: 31,
4
+ light_blue: 36
4
5
  }
5
6
 
6
7
  def describe(str)
@@ -10,16 +11,17 @@ end
10
11
 
11
12
  def it(str)
12
13
  spec_result = yield
13
- colour_code = COLOUR_CODES[spec_result.success?]
14
- puts " \e[#{colour_code}m#{str}\e[0m"
15
- unless spec_result.success?
16
- spec_result.simple_stack_trace.each do |stackline|
17
- puts " \e[#{colour_code}m#{stackline}\e[0m"
14
+ if spec_result.success?
15
+ puts " \e[#{COLOUR_CODES[:green]}m#{str}\e[0m"
16
+ else
17
+ puts " \e[#{COLOUR_CODES[:red]}m#{str}\e[0m"
18
+ spec_result.failure_message.each do |line|
19
+ puts " \e[#{COLOUR_CODES[:red]}m#{line}\e[0m"
18
20
  end
21
+ puts " \e[#{COLOUR_CODES[:light_blue]}m# #{spec_result.trace}\e[0m"
19
22
  end
20
23
  end
21
24
 
22
-
23
25
  def expect(obj)
24
26
  Mspec::Expect.new(obj)
25
27
  end
@@ -1,6 +1,8 @@
1
1
  module Mspec
2
2
  module Matchers
3
3
  class Equal
4
+ attr_reader :value
5
+
4
6
  def initialize(value)
5
7
  @value = value
6
8
  end
@@ -1,6 +1,8 @@
1
1
  module Mspec
2
2
  class SpecResult
3
- def initialize(error)
3
+ def initialize(expectation, matcher, error)
4
+ @expectation = expectation
5
+ @matcher = matcher
4
6
  @error = error
5
7
  end
6
8
 
@@ -8,8 +10,15 @@ module Mspec
8
10
  !@error
9
11
  end
10
12
 
11
- def simple_stack_trace
12
- [@error.backtrace[1]]
13
+ def failure_message
14
+ [
15
+ "Expected: #{@matcher.value}",
16
+ "Got: #{@expectation.value}",
17
+ ]
18
+ end
19
+
20
+ def trace
21
+ "#{@error.backtrace[1]}"
13
22
  end
14
23
  end
15
24
  end
@@ -1,3 +1,3 @@
1
1
  module Mspec
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Withers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler